*/
#include "gmxpre.h"
-#include <math.h>
-#include <string.h>
+#include <cmath>
+#include <cstring>
+
+#include <algorithm>
#include "gromacs/commandline/pargs.h"
#include "gromacs/correlationfunctions/autocorr.h"
#include "gromacs/topology/index.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/futil.h"
+#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
static void dump_dih_trr(int nframes, int nangles, real **dih, const char *fn,
{
for (m = 0; (m < 2); m++)
{
- x[k][l] = (m == 0) ? cos(dih[j][i]) : sin(dih[j][i]);
+ // This is just because the compler and static-analyzer cannot
+ // know that dih[j][i] is always valid. Since it occurs in the innermost
+ // loop over angles and will only trigger on coding errors, we
+ // only enable it for debug builds.
+ GMX_ASSERT(dih != NULL && dih[j] != NULL, "Incorrect dihedral array data");
+ x[k][l] = (m == 0) ? std::cos(dih[j][i]) : std::sin(dih[j][i]);
l++;
if (l == DIM)
{
};
FILE *out;
- real tmp, dt;
- int status, isize;
+ real dt;
+ int isize;
atom_id *index;
char *grpname;
- real maxang, Jc, S2, norm_fac, maxstat;
+ real maxang, S2, norm_fac, maxstat;
unsigned long mode;
int nframes, maxangstat, mult, *angstat;
- int i, j, total, nangles, natoms, nat2, first, last, angind;
+ int i, j, nangles, first, last;
gmx_bool bAver, bRb, bPeriodic,
- bFrac, /* calculate fraction too? */
- bTrans, /* worry about transtions too? */
- bCorr; /* correlation function ? */
- real t, aa, aver, aver2, aversig, fraction; /* fraction trans dihedrals */
+ bFrac, /* calculate fraction too? */
+ bTrans, /* worry about transtions too? */
+ bCorr; /* correlation function ? */
+ real aver, aver2, aversig; /* fraction trans dihedrals */
double tfrac = 0;
char title[256];
real **dih = NULL; /* mega array with all dih. angles at all times*/
- char buf[80];
real *time, *trans_frac, *aver_angle;
t_filenm fnm[] = {
{ efTRX, "-f", NULL, ffREAD },
mult = 4;
maxang = 360.0;
bRb = FALSE;
+
+ GMX_RELEASE_ASSERT(opt[0] != NULL, "Internal option inconsistency; opt[0]==NULL after processing");
+
switch (opt[0][0])
{
case 'a':
}
/* Calculate bin size */
- maxangstat = (int)(maxang/binwidth+0.5);
+ maxangstat = static_cast<int>(maxang/binwidth+0.5);
binwidth = maxang/maxangstat;
rd_index(ftp2fn(efNDX, NFILE, fnm), 1, &isize, &index, &grpname);
if (bPBC)
{
real dd = dih[j][i];
- fprintf(out, " %8.3f", atan2(sin(dd), cos(dd))*RAD2DEG);
+ fprintf(out, " %8.3f", std::atan2(std::sin(dd), std::cos(dd))*RAD2DEG);
}
else
{
aver += RAD2DEG*aver_angle[i];
aver2 += sqr(RAD2DEG*aver_angle[i]);
}
- aver /= (real) nframes;
- aver2 /= (real) nframes;
- aversig = sqrt(aver2-sqr(aver));
+ aver /= nframes;
+ aver2 /= nframes;
+ aversig = std::sqrt(aver2-sqr(aver));
printf("Found points in the range from %d to %d (max %d)\n",
first, last, maxangstat);
printf(" < angle > = %g\n", aver);
maxstat = 0;
for (i = first; (i <= last); i++)
{
- maxstat = max(maxstat, angstat[i]*norm_fac);
+ maxstat = std::max(maxstat, angstat[i]*norm_fac);
}
if (output_env_get_print_xvgr_codes(oenv))
{