Merge branch 'master' into pygromacs
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_nmeig.cpp
similarity index 96%
rename from src/gromacs/gmxana/gmx_nmeig.c
rename to src/gromacs/gmxana/gmx_nmeig.cpp
index 4560444e68827885052559546f1ce325b3c30aa9..fbfb008c863fd7222b8538bbf9dcde3e7dd0a49d 100644 (file)
@@ -36,8 +36,8 @@
  */
 #include "gmxpre.h"
 
-#include <math.h>
-#include <string.h>
+#include <cmath>
+#include <cstring>
 
 #include "gromacs/commandline/pargs.h"
 #include "gromacs/fileio/mtxio.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/topology/mtop_util.h"
 #include "gromacs/utility/futil.h"
+#include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/smalloc.h"
 
 static double cv_corr(double nu, double T)
 {
     double x  = PLANCK*nu/(BOLTZ*T);
-    double ex = exp(x);
+    double ex = std::exp(x);
 
     if (nu <= 0)
     {
@@ -75,7 +76,7 @@ static double cv_corr(double nu, double T)
 static double u_corr(double nu, double T)
 {
     double x  = PLANCK*nu/(BOLTZ*T);
-    double ex = exp(x);
+    double ex = std::exp(x);
 
     if (nu <= 0)
     {
@@ -145,7 +146,7 @@ nma_full_hessian(real     *           hess,
                  real     *           eigenvectors)
 {
     int  i, j, k, l;
-    real mass_fac, rdum;
+    real mass_fac;
     int  natoms;
 
     natoms = top->atoms.nr;
@@ -217,6 +218,8 @@ nma_sparse_hessian(gmx_sparsematrix_t     *     sparse_hessian,
     /* Cannot check symmetry since we only store half matrix */
     /* divide elements hess[i][j] by sqrt(mas[i])*sqrt(mas[j]) when required */
 
+    GMX_RELEASE_ASSERT(sparse_hessian != NULL, "NULL matrix pointer provided to nma_sparse_hessian");
+
     if (bM)
     {
         for (iatom = 0; (iatom < natoms); iatom++)
@@ -312,20 +315,16 @@ int gmx_nmeig(int argc, char *argv[])
           "Width (sigma) of the gaussian peaks (1/cm) when generating a spectrum" }
     };
     FILE                  *out, *qc, *spec;
-    int                    status, trjout;
     t_topology             top;
     gmx_mtop_t             mtop;
-    int                    ePBC;
     rvec                  *top_x;
     matrix                 box;
     real                  *eigenvalues;
     real                  *eigenvectors;
-    real                   rdum, mass_fac, qcvtot, qutot, qcv, qu;
-    int                    natoms, ndim, nrow, ncol, count, nharm, nvsite;
-    char                  *grpname;
-    int                    i, j, k, l, d, gnx;
+    real                   qcvtot, qutot, qcv, qu;
+    int                    natoms, ndim, nrow, ncol, nharm, nvsite;
+    int                    i, j, k;
     gmx_bool               bSuck;
-    atom_id               *index;
     t_tpxheader            tpx;
     int                    version, generation;
     real                   value, omega, nu;
@@ -455,7 +454,7 @@ int gmx_nmeig(int argc, char *argv[])
     bSuck = FALSE;
     for (i = begin-1; (i < 6); i++)
     {
-        if (fabs(eigenvalues[i]) > 1.0e-3)
+        if (std::abs(eigenvalues[i]) > 1.0e-3)
         {
             bSuck = TRUE;
         }
@@ -551,16 +550,16 @@ int gmx_nmeig(int argc, char *argv[])
         {
             value = 0;
         }
-        omega = sqrt(value*factor_gmx_to_omega2);
+        omega = std::sqrt(value*factor_gmx_to_omega2);
         nu    = 1e-12*omega/(2*M_PI);
         value = omega*factor_omega_to_wavenumber;
         fprintf (out, "%6d %15g\n", i, value);
         if (NULL != spec)
         {
-            wfac = eigenvalues[i-begin]/(width*sqrt(2*M_PI));
+            wfac = eigenvalues[i-begin]/(width*std::sqrt(2*M_PI));
             for (j = 0; (j < maxspec); j++)
             {
-                spectrum[j] += wfac*exp(-sqr(j-value)/(2*sqr(width)));
+                spectrum[j] += wfac*std::exp(-sqr(j-value)/(2*sqr(width)));
             }
         }
         if (NULL != qc)