*/
#include "gmxpre.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include <algorithm>
#include "gromacs/correlationfunctions/expfit.h"
#include "gromacs/correlationfunctions/integrate.h"
int calc_nbegin(int nx, real x[], real tbegin)
{
int nbegin;
- real dt, dtt;
/* Assume input x is sorted */
for (nbegin = 0; (nbegin < nx) && (x[nbegin] <= tbegin); nbegin++)
}
/* Take the one closest to tbegin */
- if (fabs(x[nbegin]-tbegin) > fabs(x[nbegin-1]-tbegin))
+ if (std::abs(x[nbegin]-tbegin) > std::abs(x[nbegin-1]-tbegin))
{
nbegin--;
}
}
else
{
- i0 = max(0, nbegin);
- i1 = min(nx-1, nbegin+nsmooth);
+ i0 = std::max(0, nbegin);
+ i1 = std::min(nx-1, nbegin+nsmooth);
printf("Making smooth transition from %d through %d\n", i0, i1);
for (i = 0; (i < i0); i++)
{
}
for (i = i0; (i <= i1); i++)
{
- fx = (i1-i)/(real)(i1-i0);
- fy = (i-i0)/(real)(i1-i0);
+ fx = static_cast<real>(i1-i)/(i1-i0);
+ fy = static_cast<real>(i-i0)/(i1-i0);
if (debug)
{
fprintf(debug, "x: %g factors for smoothing: %10g %10g\n", x[i], fx, fy);
FILE *fp, *cp;
t_complex *tmp, gw, hw, kw;
int i, nnx, nxsav;
- real fac, nu, dt, *ptr, maxeps, numax;
+ real fac, nu, dt, maxeps, numax;
gmx_fft_t fft;
int fftcode;
nx = read_xvg(opt2fn("-f", NFILE, fnm), &yd, &ny);
dt = yd[0][1] - yd[0][0];
- nxtail = min(tail/dt, nx);
+ nxtail = std::min(static_cast<int>(tail/dt), nx);
printf("Read data set containing %d colums and %d rows\n", ny, nx);
printf("Assuming (from data) that timestep is %g, nxtail = %d\n",
snew(y, 6);
for (i = 0; (i < ny); i++)
{
- snew(y[i], max(nx, nxtail));
+ snew(y[i], std::max(nx, nxtail));
}
for (i = 0; (i < nx); i++)
{
srenew(y, 3);
snew(y[2], nx);
- fac = 1.0/((real)nx);
+ fac = 1.0/nx;
for (i = 0; (i < nx); i++)
{
y[2][i] = fac;