clang-tidy: performance-type-promotion-in-math-fn
authorRoland Schulz <roland.schulz@intel.com>
Mon, 25 Jun 2018 07:34:55 +0000 (00:34 -0700)
committerRoland Schulz <roland.schulz@intel.com>
Thu, 28 Jun 2018 02:14:06 +0000 (19:14 -0700)
Change-Id: I7cca74e0c280c564f7a71cc1a68a5402172eefd1

28 files changed:
src/gromacs/CMakeLists.txt
src/gromacs/analysisdata/modules/histogram.cpp
src/gromacs/correlationfunctions/autocorr.cpp
src/gromacs/domdec/domdec.cpp
src/gromacs/domdec/domdec_setup.cpp
src/gromacs/essentialdynamics/edsam.cpp
src/gromacs/ewald/ewald.cpp
src/gromacs/ewald/long-range-correction.cpp
src/gromacs/fft/fft5d.cpp
src/gromacs/fileio/libxdrf.cpp
src/gromacs/fileio/matio.cpp
src/gromacs/gmxana/gmx_pme_error.cpp
src/gromacs/gmxpreprocess/readir.cpp
src/gromacs/gmxpreprocess/toppush.cpp
src/gromacs/mdlib/coupling.cpp
src/gromacs/mdlib/expanded.cpp
src/gromacs/mdlib/md_support.cpp
src/gromacs/mdlib/repl_ex.cpp
src/gromacs/mdlib/shellfc.cpp
src/gromacs/mdlib/sim_util.cpp
src/gromacs/mdrun/minimize.cpp
src/gromacs/pbcutil/pbc.cpp
src/gromacs/pulling/pullutil.cpp
src/gromacs/selection/centerofmass.cpp
src/gromacs/selection/sm_insolidangle.cpp
src/gromacs/tools/check.cpp
src/gromacs/trajectoryanalysis/modules/surfacearea.cpp
src/gromacs/utility/compare.cpp

index 7685806035618853b92771a89b3bb0c810fbfac6..6ce2470b84d98140a604f82ca23630cddd39c6b6 100644 (file)
@@ -284,10 +284,10 @@ if (GMX_CLANG_TIDY)
        -readability-misleading-indentation,-readability-container-size-empty,-misc-suspicious-string-compare,\
        -readability-redundant-control-flow,-performance-unnecessary-value-param,\
        -readability-static-definition-in-anonymous-namespace,-misc-suspicious-missing-comma,\
-       -readability-redundant-member-init,-misc-misplaced-const,-performance-type-promotion-in-math-fn,\
+       -readability-redundant-member-init,-misc-misplaced-const,\
        -misc-incorrect-roundings,-misc-macro-parentheses,-readability-function-size,-readability-else-after-return,\
        -readability-inconsistent-declaration-parameter-name,-misc-throw-by-value-catch-by-reference,\
-       -readability-non-const-parameter,-readability-implicit-bool-conversion;-warnings-as-errors=*")
+       -readability-non-const-parameter,-readability-implicit-bool-conversion;-warnings-as-errors=*;-fix")
 endif()
 
 gmx_write_installed_header_list()
index 1baa1dc0d7fa6118c6ba3e501650c946cf460fe6..1a1d1cb610609fd858254c3703e51e31e3890b51 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2018, 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.
@@ -138,8 +138,8 @@ AnalysisHistogramSettings::AnalysisHistogramSettings(
             GMX_RELEASE_ASSERT(isDefined(settings.binWidth_),
                                "Rounding only makes sense with defined binwidth");
             binWidth_  = settings.binWidth_;
-            firstEdge_ = binWidth_ * floor(settings.min_ / binWidth_);
-            lastEdge_  = binWidth_ * ceil(settings.max_ / binWidth_);
+            firstEdge_ = binWidth_ * std::floor(settings.min_ / binWidth_);
+            lastEdge_  = binWidth_ * std::ceil(settings.max_ / binWidth_);
             binCount_  = static_cast<int>((lastEdge_ - firstEdge_) / binWidth_ + 0.5);
         }
         else
index b61ad45bc51057102231ceb13d3f5b3548e95905..a9681ce2150925b99e588144af05bc96a6e83e49 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
@@ -172,7 +172,7 @@ static void do_ac_core(int nframes, int nout,
             else if (MODE(eacCos))
             {
                 /* Compute the cos (phi(t)-phi(t+dt)) */
-                corr[k] += cos(c1[j]-c1[j+k]);
+                corr[k] += std::cos(c1[j]-c1[j+k]);
             }
             else if (MODE(eacIden))
             {
index b80b0a522763c4a2e13910585dd416cec08ed389..d87137a7b19226a7f17c31c332fed57ce0c3dc53 100644 (file)
@@ -2464,7 +2464,7 @@ static void print_dd_load_av(FILE *fplog, gmx_domdec_t *dd)
         sprintf(buf, " Average PME mesh/force load: %5.3f\n", pmeForceRatio);
         fprintf(fplog, "%s", buf);
         fprintf(stderr, "%s", buf);
-        sprintf(buf, " Part of the total run time spent waiting due to PP/PME imbalance: %.1f %%\n", fabs(lossFractionPme)*100);
+        sprintf(buf, " Part of the total run time spent waiting due to PP/PME imbalance: %.1f %%\n", std::fabs(lossFractionPme)*100);
         fprintf(fplog, "%s", buf);
         fprintf(stderr, "%s", buf);
     }
@@ -2487,14 +2487,14 @@ static void print_dd_load_av(FILE *fplog, gmx_domdec_t *dd)
         fprintf(fplog, "%s\n", buf);
         fprintf(stderr, "%s\n", buf);
     }
-    if (numPmeRanks > 0 && fabs(lossFractionPme) >= DD_PERF_LOSS_WARN)
+    if (numPmeRanks > 0 && std::fabs(lossFractionPme) >= DD_PERF_LOSS_WARN)
     {
         sprintf(buf,
                 "NOTE: %.1f %% performance was lost because the PME ranks\n"
                 "      had %s work to do than the PP ranks.\n"
                 "      You might want to %s the number of PME ranks\n"
                 "      or %s the cut-off and the grid spacing.\n",
-                fabs(lossFractionPme*100),
+                std::fabs(lossFractionPme*100),
                 (lossFractionPme < 0) ? "less"     : "more",
                 (lossFractionPme < 0) ? "decrease" : "increase",
                 (lossFractionPme < 0) ? "decrease" : "increase");
index f22e7ecf092ad43bc2babceaa91632233b5b00c1..ee5cee93cde319e48a7e0157d4ef3bf06ebfd8bd 100644 (file)
@@ -463,7 +463,7 @@ static float comm_cost_est(real limit, real cutoff,
             /* Check if the box size is nearly identical,
              * in that case we prefer nx > ny  and ny > nz.
              */
-            if (fabs(bt[j] - bt[i]) < 0.01*bt[i] && nc[j] > nc[i])
+            if (std::fabs(bt[j] - bt[i]) < 0.01*bt[i] && nc[j] > nc[i])
             {
                 /* The XX/YY check is a bit compact. If nc[YY]==npme[YY]
                  * this means the swapped nc has nc[XX]==npme[XX],
index 2ead8c185a1a04b6242708b98f4be4c24b5d4089..e5513e9b9f298c60be16a7e8f872d04f7554256a 100644 (file)
@@ -42,6 +42,8 @@
 #include <string.h>
 #include <time.h>
 
+#include <cmath>
+
 #include "gromacs/commandline/filenm.h"
 #include "gromacs/domdec/domdec_struct.h"
 #include "gromacs/fileio/gmxfio.h"
@@ -771,7 +773,7 @@ static real flood_energy(t_edpar *edi, gmx_int64_t step)
     }
     else
     {
-        Vfl = edi->flood.Efl != 0 ? edi->flood.Efl*exp(-edi->flood.kT/2/edi->flood.Efl/edi->flood.alpha2*sum) : 0;
+        Vfl = edi->flood.Efl != 0 ? edi->flood.Efl*std::exp(-edi->flood.kT/2/edi->flood.Efl/edi->flood.alpha2*sum) : 0;
     }
 
     return Vfl;
index c4481a832b433e5eb7c2918096aea3968872de25..e27d793e5fa5bf9b402afe4ac8785515545d58c6 100644 (file)
@@ -123,8 +123,8 @@ static void tabulateStructureFactors(int natom, const rvec x[], int kmax, cvec *
 
         for (m = 0; (m < 3); m++)
         {
-            eir[1][i][m].re = cos(x[i][m]*lll[m]);
-            eir[1][i][m].im = sin(x[i][m]*lll[m]);
+            eir[1][i][m].re = std::cos(x[i][m]*lll[m]);
+            eir[1][i][m].im = std::sin(x[i][m]*lll[m]);
         }
         for (j = 2; (j < kmax); j++)
         {
@@ -242,7 +242,7 @@ real do_ewald(const t_inputrec *ir,
                 {
                     mz  = iz*lll[ZZ];
                     m2  = mx*mx+my*my+mz*mz;
-                    ak  = exp(m2*factor)/m2;
+                    ak  = std::exp(m2*factor)/m2;
                     akv = 2.0*ak*(1.0/m2-factor);
                     if (iz >= 0)
                     {
index 6bfc1c46a4d519cbaea5994cc851f1ad02d720e7..da0eaef89c120b566e09938e6042e971dbc09904 100644 (file)
@@ -282,7 +282,7 @@ void ewald_LRcorrection(int numAtomsLocal,
                                      * to normalise the relative position vector dx */
                                     if (ewcdr > R_ERF_R_INACC)
                                     {
-                                        fscal = rinv2*(vc - qqA*ewc_q*M_2_SQRTPI*exp(-ewcdr*ewcdr));
+                                        fscal = rinv2*(vc - qqA*ewc_q*M_2_SQRTPI*std::exp(-ewcdr*ewcdr));
                                     }
                                     else
                                     {
@@ -440,7 +440,7 @@ void ewald_LRcorrection(int numAtomsLocal,
                                     Vexcl_q     += vc;
                                     /* fscal is the scalar force pre-multiplied by rinv,
                                      * to normalise the relative position vector dx */
-                                    fscal        = rinv2*(vc-qqL*ewc_q*M_2_SQRTPI*exp(-ewc_q*ewc_q*dr2));
+                                    fscal        = rinv2*(vc-qqL*ewc_q*M_2_SQRTPI*std::exp(-ewc_q*ewc_q*dr2));
                                     dvdl_excl_q += (qqB - qqA)*v;
 
                                     /* The force vector is obtained by multiplication with
index 047a04de0c3161f7d4bbf7c59cb0fb31e862ef13..d25178fc776b81f1f730bacb5a7e162b2a3425ba 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2012,2013,2014,2015,2016,2017,2018, 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.
@@ -1418,7 +1418,7 @@ void fft5d_compare_data(const t_complex* lin, const t_complex* in, fft5d_plan pl
                     }
                     else
                     {
-                        if (fabs(a-b) > 2*NG[0]*NG[1]*NG[2]*GMX_REAL_EPS)
+                        if (std::fabs(a-b) > 2*NG[0]*NG[1]*NG[2]*GMX_REAL_EPS)
                         {
                             printf("result incorrect on %d,%d at %d,%d,%d: FFT5D:%f reference:%f\n", coor[0], coor[1], x, y, z, a, b);
                         }
index b6d17c649ad7c5f604d31367597f70668414c89a..a87b1df66cb908ad3fb5850d8c132e5b89e7baa7 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
@@ -494,7 +494,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision)
             {
                 lf = *lfp * *precision - 0.5;
             }
-            if (fabs(lf) > MAXABS)
+            if (std::fabs(lf) > MAXABS)
             {
                 /* scaling would cause overflow */
                 errval = 0;
@@ -518,7 +518,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision)
             {
                 lf = *lfp * *precision - 0.5;
             }
-            if (fabs(lf) > MAXABS)
+            if (std::fabs(lf) > MAXABS)
             {
                 /* scaling would cause overflow */
                 errval = 0;
index 8bf6934e41624fb113aeb7540d747d107246e7d0..26c1a06e36870f0ffd13a96948423ddf880f8b02 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2018, 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.
@@ -731,9 +731,9 @@ static void pr_simple_cmap(FILE *out, real lo, real hi, int nlevel, t_rgb rlo,
         fprintf(out, "\"%c%c c #%02X%02X%02X \" /* \"%.3g\" */,\n",
                 mapper[(i+i0) % NMAP],
                 (nlevel <= NMAP) ? ' ' : mapper[(i+i0)/NMAP],
-                static_cast<unsigned int>(round(255*r)),
-                static_cast<unsigned int>(round(255*g)),
-                static_cast<unsigned int>(round(255*b)),
+                static_cast<unsigned int>(std::round(255*r)),
+                static_cast<unsigned int>(std::round(255*g)),
+                static_cast<unsigned int>(std::round(255*b)),
                 lo+fac*(hi-lo));
     }
 }
@@ -839,9 +839,9 @@ static void write_xpm_map(FILE *out, int n_x, int n_y, int *nlevels,
         b   = (nlo*rlo.b+i*rhi.b)*invlevel;
         fprintf(out, "\"%c%c c #%02X%02X%02X \" /* \"%.3g\" */,\n",
                 mapper[i % NMAP], (*nlevels <= NMAP) ? ' ' : mapper[i/NMAP],
-                static_cast<unsigned int>(round(255*r)),
-                static_cast<unsigned int>(round(255*g)),
-                static_cast<unsigned int>(round(255*b)),
+                static_cast<unsigned int>(std::round(255*r)),
+                static_cast<unsigned int>(std::round(255*g)),
+                static_cast<unsigned int>(std::round(255*b)),
                 (nlo*lo+i*hi)*invlevel);
     }
 }
@@ -995,7 +995,7 @@ static void write_xpm_data_split(FILE *out, int n_x, int n_y, real **mat,
         {
             if (i < j)
             {
-                c = nlevel_bot+round((mat[i][j]-lo_top)*invlev_top);
+                c = nlevel_bot+std::round((mat[i][j]-lo_top)*invlev_top);
                 if ((c < nlevel_bot) || (c >= nlevel_bot+nlevel_top))
                 {
                     gmx_fatal(FARGS, "Range checking i = %d, j = %d, c = %d, bot = %d, top = %d matrix[i,j] = %f", i, j, c, nlevel_bot, nlevel_top, mat[i][j]);
@@ -1003,7 +1003,7 @@ static void write_xpm_data_split(FILE *out, int n_x, int n_y, real **mat,
             }
             else if (i > j)
             {
-                c = round((mat[i][j]-lo_bot)*invlev_bot);
+                c = std::round((mat[i][j]-lo_bot)*invlev_bot);
                 if ((c < 0) || (c >= nlevel_bot+nlevel_bot))
                 {
                     gmx_fatal(FARGS, "Range checking i = %d, j = %d, c = %d, bot = %d, top = %d matrix[i,j] = %f", i, j, c, nlevel_bot, nlevel_top, mat[i][j]);
index 55d35e0836339865a6d8a623486597e78c1302b9..255508ced2718b3e035ee6c1b404260d5974be51 100644 (file)
@@ -177,7 +177,7 @@ static real estimate_direct(
     r_coulomb = info->rcoulomb[0];
 
     e_dir  = 2.0 * info->q2all * gmx::invsqrt( info->q2allnr  *  r_coulomb * info->volume );
-    e_dir *= exp (-beta*beta*r_coulomb*r_coulomb);
+    e_dir *= std::exp (-beta*beta*r_coulomb*r_coulomb);
 
     return ONE_4PI_EPS0*e_dir;
 }
index e018f18273e77a508ede094f7412b8df0764dd6e..10abaa52aed0dbe780565f18e93952f6dea198fc 100644 (file)
@@ -3477,7 +3477,7 @@ void do_index(const char* mdparin, const char *ndx,
                         else
                         {
                             fprintf(stderr, "%9.1f      %5.1f\n", ir->opts.anneal_time[i][j], ir->opts.anneal_temp[i][j]);
-                            if (fabs(ir->opts.anneal_temp[i][j]-ir->opts.anneal_temp[i][0]) > GMX_REAL_EPS)
+                            if (std::fabs(ir->opts.anneal_temp[i][j]-ir->opts.anneal_temp[i][0]) > GMX_REAL_EPS)
                             {
                                 warning_note(wi, "There is a temperature jump when your annealing loops back.\n");
                             }
index 6cef9c2b501e93ac90697c16f873dcfc7d814dec..d3f065f42a56c58404134c0c029f27698fbd4222 100644 (file)
@@ -132,7 +132,7 @@ void generate_nbparams(int comb, int ftype, t_params *plist, gpp_atomtype_t atyp
                             cj0                  = get_atomtype_nbparam(j, 0, atype);
                             ci1                  = get_atomtype_nbparam(i, 1, atype);
                             cj1                  = get_atomtype_nbparam(j, 1, atype);
-                            plist->param[k].c[0] = std::sqrt(fabs(ci0*cj0));
+                            plist->param[k].c[0] = std::sqrt(std::fabs(ci0*cj0));
                             /* Negative sigma signals that c6 should be set to zero later,
                              * so we need to propagate that through the combination rules.
                              */
index 94b44bc60525c3df319b993c7300872b1c079c34..dae166b7542216530a6b59397092e98452faf36e 100644 (file)
@@ -38,6 +38,8 @@
 
 #include <assert.h>
 
+#include <cmath>
+
 #include <algorithm>
 
 #include "gromacs/domdec/domdec_struct.h"
@@ -506,7 +508,7 @@ void parrinellorahman_pcoupl(FILE *fplog, gmx_int64_t step,
                    to its current size.
                  */
 
-                change = fabs(dt*boxv[d][n]/box[d][d]);
+                change = std::fabs(dt*boxv[d][n]/box[d][d]);
 
                 if (change > maxchange)
                 {
@@ -1641,7 +1643,7 @@ void update_annealing_target_temp(t_inputrec *ir, real t, gmx_update_t *upd)
                 n     = static_cast<int>(t / pert);
                 thist = t - n*pert; /* modulo time */
                 /* Make sure rounding didn't get us outside the interval */
-                if (fabs(thist-pert) < GMX_REAL_EPS*100)
+                if (std::fabs(thist-pert) < GMX_REAL_EPS*100)
                 {
                     thist = 0;
                 }
index 22a76aadff6c56e80245d5a73493f7f82a3021e6..0fcf17a5d805f5124ce1a26aa4ac78e2c69c5a44 100644 (file)
@@ -587,7 +587,7 @@ static gmx_bool UpdateWeights(int nlim, t_expanded *expand, df_history_t *dfhist
             }
             else
             {
-                dwm_array[nval]  = fabs( cnval - lam_dg[fep_state-1] );
+                dwm_array[nval]  = std::fabs( cnval - lam_dg[fep_state-1] );
             }
 
             if (n0 > 0)
@@ -606,7 +606,7 @@ static gmx_bool UpdateWeights(int nlim, t_expanded *expand, df_history_t *dfhist
             }
             else
             {
-                dwp_array[nval]  = fabs( cnval - lam_dg[fep_state] );
+                dwp_array[nval]  = std::fabs( cnval - lam_dg[fep_state] );
             }
 
         }
index 7cf67001e15819c242430ab3697fc1a518dc2fcc..f4561d03217086bcda32924c2a31c66951284e10 100644 (file)
@@ -40,6 +40,7 @@
 #include "md_support.h"
 
 #include <climits>
+#include <cmath>
 
 #include <algorithm>
 
@@ -344,7 +345,7 @@ void setCurrentLambdasRerun(gmx_int64_t step, const t_lambda *fepvals,
         {
             /* find out between which two value of lambda we should be */
             real frac      = step*fepvals->delta_lambda;
-            int  fep_state = static_cast<int>(floor(frac*fepvals->n_lambda));
+            int  fep_state = static_cast<int>(std::floor(frac*fepvals->n_lambda));
             /* interpolate between this state and the next */
             /* this assumes that the initial lambda corresponds to lambda==0, which is verified in grompp */
             frac           = frac*fepvals->n_lambda - fep_state;
@@ -376,7 +377,7 @@ void setCurrentLambdasLocal(gmx_int64_t step, const t_lambda *fepvals,
         real frac = step*fepvals->delta_lambda;
         if (fepvals->n_lambda > 0)
         {
-            int fep_state = static_cast<int>(floor(frac*fepvals->n_lambda));
+            int fep_state = static_cast<int>(std::floor(frac*fepvals->n_lambda));
             /* interpolate between this state and the next */
             /* this assumes that the initial lambda corresponds to lambda==0, which is verified in grompp */
             frac          = frac*fepvals->n_lambda - fep_state;
index 71e1f49dc209d3d3c54b913e867b171d03a03872..b6662b13ae74c31cba41a55867d8fcc997d40685 100644 (file)
@@ -1282,7 +1282,7 @@ gmx_bool replica_exchange(FILE *fplog, const t_commrec *cr,
              * the velocities. */
             if (re->type == ereTEMP || re->type == ereTL)
             {
-                scale_velocities(state, sqrt(re->q[ereTEMP][replica_id]/re->q[ereTEMP][re->destinations[replica_id]]));
+                scale_velocities(state, std::sqrt(re->q[ereTEMP][replica_id]/re->q[ereTEMP][re->destinations[replica_id]]));
             }
 
         }
index 4243c371e8be02667dcf867f38cb5d51c7085c2c..26fe9446fca96be167de912f005019db12517e1c 100644 (file)
@@ -41,6 +41,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <cmath>
 #include <cstdint>
 
 #include <algorithm>
@@ -863,7 +864,7 @@ static void check_pbc(FILE *fp, gmx::ArrayRef<gmx::RVec> x, int shell)
     now = shell-4;
     for (m = 0; (m < DIM); m++)
     {
-        if (fabs(x[shell][m]-x[now][m]) > 0.3)
+        if (std::fabs(x[shell][m]-x[now][m]) > 0.3)
         {
             pr_rvecs(fp, 0, "SHELL-X", as_rvec_array(x.data())+now, 5);
             break;
index aa8eb9e48f243c4f3d4fce6037d26a087826928d..5da6ac6d74c821067b87274b4d48d976fb9226be 100644 (file)
@@ -2375,8 +2375,8 @@ void calc_enervirdiff(FILE *fplog, int eDispCorr, t_forcerec *fr)
             vdwtab = fr->dispersionCorrectionTable->data;
 
             /* Round the cut-offs to exact table values for precision */
-            ri0  = static_cast<int>(floor(ic->rvdw_switch*scale));
-            ri1  = static_cast<int>(ceil(ic->rvdw*scale));
+            ri0  = static_cast<int>(std::floor(ic->rvdw_switch*scale));
+            ri1  = static_cast<int>(std::ceil(ic->rvdw*scale));
 
             /* The code below has some support for handling force-switching, i.e.
              * when the force (instead of potential) is switched over a limited
index bca9db4aa649947c26587c8cc5d88b2e3f631335..b109ac7f1844bb9983c991b1cb679d71fd3aa954 100644 (file)
@@ -1313,7 +1313,7 @@ Integrator::do_cg()
         }
 
         /* This is the max amount of increase in energy we tolerate */
-        tmp = sqrt(GMX_REAL_EPS)*fabs(s_a->epot);
+        tmp = std::sqrt(GMX_REAL_EPS)*fabs(s_a->epot);
 
         /* Accept the step if the energy is lower, or if it is not significantly higher
          * and the line derivative is still negative.
@@ -1452,7 +1452,7 @@ Integrator::do_cg()
             while ((epot_repl > s_a->epot || epot_repl > s_c->epot) &&
                    (nminstep < 20));
 
-            if (fabs(epot_repl - s_min->epot) < fabs(s_min->epot)*GMX_REAL_EPS ||
+            if (std::fabs(epot_repl - s_min->epot) < fabs(s_min->epot)*GMX_REAL_EPS ||
                 nminstep >= 20)
             {
                 /* OK. We couldn't find a significantly lower energy.
@@ -2003,7 +2003,7 @@ Integrator::do_lbfgs()
         // This is the max amount of increase in energy we tolerate.
         // By allowing VERY small changes (close to numerical precision) we
         // frequently find even better (lower) final energies.
-        tmp = sqrt(GMX_REAL_EPS)*fabs(sa->epot);
+        tmp = std::sqrt(GMX_REAL_EPS)*fabs(sa->epot);
 
         // Accept the step if the energy is lower in the new position C (compared to A),
         // or if it is not significantly higher and the line derivative is still negative.
@@ -2115,7 +2115,7 @@ Integrator::do_lbfgs()
             }
             while ((sb->epot > sa->epot || sb->epot > sc->epot) && (nminstep < 20));
 
-            if (fabs(sb->epot - Epot0) < GMX_REAL_EPS || nminstep >= 20)
+            if (std::fabs(sb->epot - Epot0) < GMX_REAL_EPS || nminstep >= 20)
             {
                 /* OK. We couldn't find a significantly lower energy.
                  * If ncorr==0 this was steepest descent, and then we give up.
@@ -2637,7 +2637,7 @@ Integrator::do_nm()
 
     /* added with respect to mdrun */
     int                       row, col;
-    real                      der_range = 10.0*sqrt(GMX_REAL_EPS);
+    real                      der_range = 10.0*std::sqrt(GMX_REAL_EPS);
     real                      x_min;
     bool                      bIsMaster = MASTER(cr);
     auto                      mdatoms   = mdAtoms->mdatoms();
index cecbc2432d6a1cfb5e772b3c55221bd7b2f11f46..0d22530648ad7c617acdc53db0997a9a7ac29fcf 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
@@ -163,8 +163,8 @@ void matrix_convert(matrix box, const rvec vec, const rvec angleInDegrees)
     box[ZZ][XX] = vec[ZZ]*cos(angle[YY]);
     box[ZZ][YY] = vec[ZZ]
         *(cos(angle[XX])-cos(angle[YY])*cos(angle[ZZ]))/sin(angle[ZZ]);
-    box[ZZ][ZZ] = sqrt(gmx::square(vec[ZZ])
-                       -box[ZZ][XX]*box[ZZ][XX]-box[ZZ][YY]*box[ZZ][YY]);
+    box[ZZ][ZZ] = std::sqrt(gmx::square(vec[ZZ])
+                            -box[ZZ][XX]*box[ZZ][XX]-box[ZZ][YY]*box[ZZ][YY]);
 }
 
 real max_cutoff2(int ePBC, const matrix box)
index 276161c5bb7136c958020b902d607bf9cad245fe..60de897942e0c554f8a5552895f858b0b7878095 100644 (file)
@@ -41,6 +41,8 @@
 #include <assert.h>
 #include <stdlib.h>
 
+#include <cmath>
+
 #include "gromacs/domdec/domdec_struct.h"
 #include "gromacs/domdec/ga2la.h"
 #include "gromacs/fileio/confio.h"
@@ -792,8 +794,8 @@ void pull_calc_coms(const t_commrec *cr,
                 for (i = 0; i < pgrp->nat_loc; i++)
                 {
                     ii                  = pgrp->ind_loc[i];
-                    pgrp->weight_loc[i] = csw*cos(twopi_box*x[ii][pull->cosdim]) +
-                        snw*sin(twopi_box*x[ii][pull->cosdim]);
+                    pgrp->weight_loc[i] = csw*std::cos(twopi_box*x[ii][pull->cosdim]) +
+                        snw*std::sin(twopi_box*x[ii][pull->cosdim]);
                 }
                 if (xp)
                 {
index 0639890a0db148b09f437eda7c01997ed4340c81..84654590175bc04fb46c6d15bf3d211e78a00db1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2018, 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.
@@ -43,6 +43,8 @@
 
 #include "centerofmass.h"
 
+#include <cmath>
+
 #include "gromacs/math/vec.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/topology/block.h"
@@ -224,7 +226,7 @@ gmx_calc_cog_pbc(const gmx_mtop_t *top, rvec x[], const t_pbc *pbc,
                 rvec_add(xout, dx, xtest);
                 for (j = 0; j < DIM; ++j)
                 {
-                    if (fabs(xtest[j] - x[ai][j]) > tol)
+                    if (std::fabs(xtest[j] - x[ai][j]) > tol)
                     {
                         /* Here we have used the wrong image for contributing to the COM */
                         xout[j] += (xtest[j] - x[ai][j]) / nrefat;
@@ -293,7 +295,7 @@ gmx_calc_com_pbc(const gmx_mtop_t *top, rvec x[], const t_pbc *pbc,
                 rvec_add(xout, dx, xtest);
                 for (int j = 0; j < DIM; ++j)
                 {
-                    if (fabs(xtest[j] - x[ai][j]) > tol)
+                    if (std::fabs(xtest[j] - x[ai][j]) > tol)
                     {
                         /* Here we have used the wrong image for contributing to the COM */
                         xout[j] += mass * (xtest[j] - x[ai][j]);
index d9c23c5dab305f9559eb2fda8e7a8aefcd998e3e..933cc0ce928dc7a32ca0d251fedf482f5687bba5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017,2018, 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.
@@ -688,7 +688,7 @@ find_surface_bin(t_methoddata_insolidangle *surf, rvec x)
 
     theta = acos(x[ZZ]);
     phi   = atan2(x[YY], x[XX]);
-    tbin  = static_cast<int>(floor(theta / surf->tbinsize));
+    tbin  = static_cast<int>(std::floor(theta / surf->tbinsize));
     if (tbin >= surf->ntbins)
     {
         tbin = surf->ntbins - 1;
@@ -902,7 +902,7 @@ store_surface_point(t_methoddata_insolidangle *surf, rvec x)
         tmax      = std::acos(cos(theta) / cos(surf->angcut));
     }
     /* Find the first affected bin */
-    tbin   = max(static_cast<int>(floor((theta - surf->angcut) / surf->tbinsize)), 0);
+    tbin   = max(static_cast<int>(std::floor((theta - surf->angcut) / surf->tbinsize)), 0);
     theta1 = tbin * surf->tbinsize;
     if (theta1 < theta - surf->angcut)
     {
@@ -913,7 +913,7 @@ store_surface_point(t_methoddata_insolidangle *surf, rvec x)
         pdelta1 = M_PI;
     }
     /* Loop through all affected bins */
-    while (tbin < ceil((theta + surf->angcut) / surf->tbinsize)
+    while (tbin < std::ceil((theta + surf->angcut) / surf->tbinsize)
            && tbin < surf->ntbins)
     {
         /* Calculate the next boundaries */
@@ -939,7 +939,7 @@ store_surface_point(t_methoddata_insolidangle *surf, rvec x)
              * such that the case above catches this instead of falling through
              * here. */
             pdelta2 = 2*asin(std::sqrt(
-                                     (gmx::square(sin(surf->angcut/2)) - gmx::square(sin((theta2-theta)/2))) /
+                                     (gmx::square(std::sin(surf->angcut/2)) - gmx::square(std::sin((theta2-theta)/2))) /
                                      (sin(theta) * sin(theta2))));
         }
         /* Update the bin */
@@ -977,7 +977,7 @@ estimate_covered_fraction(t_methoddata_insolidangle *surf)
     cfrac = 0.0;
     for (t = 0; t < surf->ntbins; ++t)
     {
-        tfrac = cos(t * surf->tbinsize) - cos((t+1) * surf->tbinsize);
+        tfrac = std::cos(t * surf->tbinsize) - std::cos((t+1) * surf->tbinsize);
         for (p = 0; p < surf->tbin[t].n; ++p)
         {
             pfrac = surf->tbin[t].p[p+1].left - surf->tbin[t].p[p].left;
index 8ce34d5a76782c6fe1952d0a175da2d76b58642f..f6a7063756719adff1702ef2337b9e28b23877ee 100644 (file)
@@ -452,8 +452,8 @@ static void chk_trj(const gmx_output_env_t *oenv, const char *fn, const char *tp
         }
         if (j >= 2)
         {
-            if (fabs((fr.time-old_t1)-(old_t1-old_t2)) >
-                0.1*(fabs(fr.time-old_t1)+fabs(old_t1-old_t2)) )
+            if (std::fabs((fr.time-old_t1)-(old_t1-old_t2)) >
+                0.1*(std::fabs(fr.time-old_t1)+std::fabs(old_t1-old_t2)) )
             {
                 bShowTimestep = FALSE;
                 fprintf(stderr, "%sTimesteps at t=%g don't match (%g, %g)\n",
@@ -777,7 +777,7 @@ static void chk_enx(const char *fn)
         if (fnr >= 2)
         {
             if (fabs((fr->t-old_t1)-(old_t1-old_t2)) >
-                0.1*(fabs(fr->t-old_t1)+fabs(old_t1-old_t2)) )
+                0.1*(fabs(fr->t-old_t1)+std::fabs(old_t1-old_t2)) )
             {
                 bShowTStep = FALSE;
                 fprintf(stderr, "\nTimesteps at t=%g don't match (%g, %g)\n",
index d835b77a0dcd2c666a1c79d774e1bd7351edaaf3..3f7a4249fa293a3a02a4f990a9c36bf2e91fc333 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2007, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2017,2018, 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.
@@ -160,7 +160,7 @@ static std::vector<real> ico_dot_arc(int densit)
                 x = xus[3*i]-xus[3*j];
                 y = xus[1+3*i]-xus[1+3*j]; z = xus[2+3*i]-xus[2+3*j];
                 d = x*x+y*y+z*z;
-                if (fabs(a-d) > DP_TOL)
+                if (std::fabs(a-d) > DP_TOL)
                 {
                     continue;
                 }
@@ -182,7 +182,7 @@ static std::vector<real> ico_dot_arc(int densit)
                 x = xus[3*i]-xus[3*j];
                 y = xus[1+3*i]-xus[1+3*j]; z = xus[2+3*i]-xus[2+3*j];
                 d = x*x+y*y+z*z;
-                if (fabs(a-d) > DP_TOL)
+                if (std::fabs(a-d) > DP_TOL)
                 {
                     continue;
                 }
@@ -192,14 +192,14 @@ static std::vector<real> ico_dot_arc(int densit)
                     x = xus[3*i]-xus[3*k];
                     y = xus[1+3*i]-xus[1+3*k]; z = xus[2+3*i]-xus[2+3*k];
                     d = x*x+y*y+z*z;
-                    if (fabs(a-d) > DP_TOL)
+                    if (std::fabs(a-d) > DP_TOL)
                     {
                         continue;
                     }
                     x = xus[3*j]-xus[3*k];
                     y = xus[1+3*j]-xus[1+3*k]; z = xus[2+3*j]-xus[2+3*k];
                     d = x*x+y*y+z*z;
-                    if (fabs(a-d) > DP_TOL)
+                    if (std::fabs(a-d) > DP_TOL)
                     {
                         continue;
                     }
@@ -282,7 +282,7 @@ static std::vector<real> ico_dot_dod(int densit)
             x = xus[3*i]-xus[3*j];
             y = xus[1+3*i]-xus[1+3*j]; z = xus[2+3*i]-xus[2+3*j];
             d = x*x+y*y+z*z;
-            if (fabs(a-d) > DP_TOL)
+            if (std::fabs(a-d) > DP_TOL)
             {
                 continue;
             }
@@ -291,14 +291,14 @@ static std::vector<real> ico_dot_dod(int densit)
                 x = xus[3*i]-xus[3*k];
                 y = xus[1+3*i]-xus[1+3*k]; z = xus[2+3*i]-xus[2+3*k];
                 d = x*x+y*y+z*z;
-                if (fabs(a-d) > DP_TOL)
+                if (std::fabs(a-d) > DP_TOL)
                 {
                     continue;
                 }
                 x = xus[3*j]-xus[3*k];
                 y = xus[1+3*j]-xus[1+3*k]; z = xus[2+3*j]-xus[2+3*k];
                 d = x*x+y*y+z*z;
-                if (fabs(a-d) > DP_TOL)
+                if (std::fabs(a-d) > DP_TOL)
                 {
                     continue;
                 }
@@ -333,7 +333,7 @@ static std::vector<real> ico_dot_dod(int densit)
                 x = xus[3*i]-xus[3*j];
                 y = xus[1+3*i]-xus[1+3*j]; z = xus[2+3*i]-xus[2+3*j];
                 d = x*x+y*y+z*z;
-                if (fabs(a-d) > DP_TOL)
+                if (std::fabs(a-d) > DP_TOL)
                 {
                     continue;
                 }
@@ -356,7 +356,7 @@ static std::vector<real> ico_dot_dod(int densit)
                 x = xus[3*i]-xus[3*j];
                 y = xus[1+3*i]-xus[1+3*j]; z = xus[2+3*i]-xus[2+3*j];
                 d = x*x+y*y+z*z;
-                if (fabs(ai_d-d) > DP_TOL)
+                if (std::fabs(ai_d-d) > DP_TOL)
                 {
                     continue;
                 }
@@ -366,14 +366,14 @@ static std::vector<real> ico_dot_dod(int densit)
                     x = xus[3*i]-xus[3*k];
                     y = xus[1+3*i]-xus[1+3*k]; z = xus[2+3*i]-xus[2+3*k];
                     d = x*x+y*y+z*z;
-                    if (fabs(ai_d-d) > DP_TOL)
+                    if (std::fabs(ai_d-d) > DP_TOL)
                     {
                         continue;
                     }
                     x = xus[3*j]-xus[3*k];
                     y = xus[1+3*j]-xus[1+3*k]; z = xus[2+3*j]-xus[2+3*k];
                     d = x*x+y*y+z*z;
-                    if (fabs(adod-d) > DP_TOL)
+                    if (std::fabs(adod-d) > DP_TOL)
                     {
                         continue;
                     }
index 3f170b59e9cc5f8f5b9104d536d55ea844bfad48..416d260158f6dd9560dd5f3858a845d67bb05850 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
@@ -154,12 +154,12 @@ void cmp_str(FILE *fp, const char *s, int index, const char *s1, const char *s2)
 
 gmx_bool equal_real(real i1, real i2, real ftol, real abstol)
 {
-    return ( ( 2*fabs(i1 - i2) <= (fabs(i1) + fabs(i2))*ftol ) || fabs(i1-i2) <= abstol );
+    return ( ( 2*std::fabs(i1 - i2) <= (fabs(i1) + fabs(i2))*ftol ) || std::fabs(i1-i2) <= abstol );
 }
 
 gmx_bool equal_float(float i1, float i2, float ftol, float abstol)
 {
-    return ( ( 2*fabs(i1 - i2) <= (fabs(i1) + fabs(i2))*ftol ) || fabs(i1-i2) <= abstol );
+    return ( ( 2*std::fabs(i1 - i2) <= (std::fabs(i1) + std::fabs(i2))*ftol ) || std::fabs(i1-i2) <= abstol );
 }
 
 gmx_bool equal_double(double i1, double i2, real ftol, real abstol)