X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=blobdiff_plain;f=src%2Fgromacs%2Fgmxana%2Fnsfactor.cpp;fp=src%2Fgromacs%2Fgmxana%2Fnsfactor.c;h=18b682fc4aade39d753bb2b91efdb55755f83a70;hb=8a9ed358b11c7181e46129f811c6f9a9805cbdd3;hp=5525de64df0ab07d8de18f05cbaa56e1cc2a95b6;hpb=87823c5ebe2ecab05a07cfdfd5165e53cb07c30d;p=alexxy%2Fgromacs.git diff --git a/src/gromacs/gmxana/nsfactor.c b/src/gromacs/gmxana/nsfactor.cpp similarity index 86% rename from src/gromacs/gmxana/nsfactor.c rename to src/gromacs/gmxana/nsfactor.cpp index 5525de64df..18b682fc4a 100644 --- a/src/gromacs/gmxana/nsfactor.c +++ b/src/gromacs/gmxana/nsfactor.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -38,7 +38,8 @@ #include "config.h" -#include +#include +#include #include "gromacs/fileio/strdb.h" #include "gromacs/math/vec.h" @@ -208,7 +209,7 @@ gmx_radial_distribution_histogram_t *calc_radial_distribution_histogram ( int nthreads; gmx_rng_t *trng = NULL; #endif - gmx_int64_t mc = 0, max; + gmx_int64_t mc = 0, mc_max; gmx_rng_t rng = NULL; /* allocate memory for pr */ @@ -225,8 +226,7 @@ gmx_radial_distribution_histogram_t *calc_radial_distribution_histogram ( rmax = norm(dist); - pr->grn = (int)floor(rmax/pr->binwidth)+1; - rmax = pr->grn*pr->binwidth; + pr->grn = static_cast(std::floor(rmax/pr->binwidth)+1); snew(pr->gr, pr->grn); @@ -235,11 +235,11 @@ gmx_radial_distribution_histogram_t *calc_radial_distribution_histogram ( /* Special case for setting automaticaly number of mc iterations to 1% of total number of direct iterations */ if (mcover == -1) { - max = (gmx_int64_t)floor(0.5*0.01*isize*(isize-1)); + mc_max = static_cast(std::floor(0.5*0.01*isize*(isize-1))); } else { - max = (gmx_int64_t)floor(0.5*mcover*isize*(isize-1)); + mc_max = static_cast(std::floor(0.5*mcover*isize*(isize-1))); } rng = gmx_rng_init(seed); #ifdef GMX_OPENMP @@ -256,13 +256,13 @@ gmx_radial_distribution_histogram_t *calc_radial_distribution_histogram ( tid = gmx_omp_get_thread_num(); /* now starting parallel threads */ #pragma omp for - for (mc = 0; mc < max; mc++) + for (mc = 0; mc < mc_max; mc++) { - i = (int)floor(gmx_rng_uniform_real(trng[tid])*isize); - j = (int)floor(gmx_rng_uniform_real(trng[tid])*isize); + i = static_cast(std::floor(gmx_rng_uniform_real(trng[tid])*isize)); + j = static_cast(std::floor(gmx_rng_uniform_real(trng[tid])*isize)); if (i != j) { - tgr[tid][(int)floor(sqrt(distance2(x[index[i]], x[index[j]]))/binwidth)] += gsans->slength[index[i]]*gsans->slength[index[j]]; + tgr[tid][static_cast(std::floor(std::sqrt(distance2(x[index[i]], x[index[j]]))/binwidth))] += gsans->slength[index[i]]*gsans->slength[index[j]]; } } } @@ -283,13 +283,13 @@ gmx_radial_distribution_histogram_t *calc_radial_distribution_histogram ( sfree(tgr); sfree(trng); #else - for (mc = 0; mc < max; mc++) + for (mc = 0; mc < mc_max; mc++) { - i = (int)floor(gmx_rng_uniform_real(rng)*isize); - j = (int)floor(gmx_rng_uniform_real(rng)*isize); + i = static_cast(std::floor(gmx_rng_uniform_real(rng)*isize)); + j = static_cast(std::floor(gmx_rng_uniform_real(rng)*isize)); if (i != j) { - pr->gr[(int)floor(sqrt(distance2(x[index[i]], x[index[j]]))/binwidth)] += gsans->slength[index[i]]*gsans->slength[index[j]]; + pr->gr[static_cast(std::floor(std::sqrt(distance2(x[index[i]], x[index[j]]))/binwidth))] += gsans->slength[index[i]]*gsans->slength[index[j]]; } } #endif @@ -314,7 +314,7 @@ gmx_radial_distribution_histogram_t *calc_radial_distribution_histogram ( { for (j = 0; j < i; j++) { - tgr[tid][(int)floor(sqrt(distance2(x[index[i]], x[index[j]]))/binwidth)] += gsans->slength[index[i]]*gsans->slength[index[j]]; + tgr[tid][static_cast(std::floor(std::sqrt(distance2(x[index[i]], x[index[j]]))/binwidth))] += gsans->slength[index[i]]*gsans->slength[index[j]]; } } } @@ -337,7 +337,7 @@ gmx_radial_distribution_histogram_t *calc_radial_distribution_histogram ( { for (j = 0; j < i; j++) { - pr->gr[(int)floor(sqrt(distance2(x[index[i]], x[index[j]]))/binwidth)] += gsans->slength[index[i]]*gsans->slength[index[j]]; + pr->gr[static_cast(std::floor(std::sqrt(distance2(x[index[i]], x[index[j]]))/binwidth))] += gsans->slength[index[i]]*gsans->slength[index[j]]; } } #endif @@ -364,7 +364,7 @@ gmx_static_structurefactor_t *convert_histogram_to_intensity_curve (gmx_radial_d int i, j; /* init data */ snew(sq, 1); - sq->qn = (int)floor((end_q-start_q)/q_step); + sq->qn = static_cast(std::floor((end_q-start_q)/q_step)); snew(sq->q, sq->qn); snew(sq->s, sq->qn); for (i = 0; i < sq->qn; i++)