*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015,2016,2017,2018,2019, 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.
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
-real calc_similar_ind(gmx_bool bRho, int nind, const int *index, const real mass[],
- rvec x[], rvec xp[])
+real calc_similar_ind(gmx_bool bRho, int nind, const int* index, const real mass[], rvec x[], rvec xp[])
{
int i, j, d;
real m, tm, xs, xd, rs, rd;
{
i = j;
}
- m = mass[i];
+ m = mass[i];
tm += m;
for (d = 0; d < DIM; d++)
{
- xd = x[i][d] - xp[i][d];
+ xd = x[i][d] - xp[i][d];
rd += m * gmx::square(xd);
if (bRho)
{
- xs = x[i][d] + xp[i][d];
+ xs = x[i][d] + xp[i][d];
rs += m * gmx::square(xs);
}
}
}
if (bRho)
{
- return 2*std::sqrt(rd/rs);
+ return 2 * std::sqrt(rd / rs);
}
else
{
- return std::sqrt(rd/tm);
+ return std::sqrt(rd / tm);
}
}
return calc_similar_ind(TRUE, natoms, nullptr, mass, x, xp);
}
-void calc_fit_R(int ndim, int natoms, const real *w_rls, const rvec *xp, rvec *x, matrix R)
+void calc_fit_R(int ndim, int natoms, const real* w_rls, const rvec* xp, rvec* x, matrix R)
{
int c, r, n, j, i, irot, s;
double **omega, **om;
- double d[2*DIM], xnr, xpc;
+ double d[2 * DIM], xnr, xpc;
matrix vh, vk, u;
real mn;
int index;
gmx_fatal(FARGS, "calc_fit_R called with ndim=%d instead of 3 or 2", ndim);
}
- snew(omega, 2*ndim);
- snew(om, 2*ndim);
- for (i = 0; i < 2*ndim; i++)
+ snew(omega, 2 * ndim);
+ snew(om, 2 * ndim);
+ for (i = 0; i < 2 * ndim; i++)
{
- snew(omega[i], 2*ndim);
- snew(om[i], 2*ndim);
+ snew(omega[i], 2 * ndim);
+ snew(om[i], 2 * ndim);
}
- for (i = 0; i < 2*ndim; i++)
+ for (i = 0; i < 2 * ndim; i++)
{
d[i] = 0;
- for (j = 0; j < 2*ndim; j++)
+ for (j = 0; j < 2 * ndim; j++)
{
omega[i][j] = 0;
om[i][j] = 0;
xpc = xp[n][c];
for (r = 0; (r < ndim); r++)
{
- xnr = x[n][r];
- u[c][r] += mn*xnr*xpc;
+ xnr = x[n][r];
+ u[c][r] += mn * xnr * xpc;
}
}
}
/*construct omega*/
/*omega is symmetric -> omega==omega' */
- for (r = 0; r < 2*ndim; r++)
+ for (r = 0; r < 2 * ndim; r++)
{
for (c = 0; c <= r; c++)
{
if (r >= ndim && c < ndim)
{
- omega[r][c] = u[r-ndim][c];
- omega[c][r] = u[r-ndim][c];
+ omega[r][c] = u[r - ndim][c];
+ omega[c][r] = u[r - ndim][c];
}
else
{
}
/*determine h and k*/
- jacobi(omega, 2*ndim, d, om, &irot);
+ jacobi(omega, 2 * ndim, d, om, &irot);
/*real **omega = input matrix a[0..n-1][0..n-1] must be symmetric
* int natoms = number of rows and columns
* real NULL = d[0]..d[n-1] are the eigenvalues of a[][]
index = 0; /* For the compiler only */
/* Copy only the first ndim-1 eigenvectors */
- for (j = 0; j < ndim-1; j++)
+ for (j = 0; j < ndim - 1; j++)
{
max_d = -1000;
- for (i = 0; i < 2*ndim; i++)
+ for (i = 0; i < 2 * ndim; i++)
{
if (d[i] > max_d)
{
d[index] = -10000;
for (i = 0; i < ndim; i++)
{
- vh[j][i] = M_SQRT2*om[i][index];
- vk[j][i] = M_SQRT2*om[i+ndim][index];
+ vh[j][i] = M_SQRT2 * om[i][index];
+ vk[j][i] = M_SQRT2 * om[i + ndim][index];
}
}
if (ndim == 3)
{
/* Calculate the last eigenvector from the first one */
vh[1][XX] = -vh[0][YY];
- vh[1][YY] = vh[0][XX];
+ vh[1][YY] = vh[0][XX];
vk[1][XX] = -vk[0][YY];
- vk[1][YY] = vk[0][XX];
+ vk[1][YY] = vk[0][XX];
}
/* determine R */
{
for (s = 0; s < ndim; s++)
{
- R[r][c] += vk[s][r]*vh[s][c];
+ R[r][c] += vk[s][r] * vh[s][c];
}
}
}
R[r][r] = 1;
}
- for (i = 0; i < 2*ndim; i++)
+ for (i = 0; i < 2 * ndim; i++)
{
sfree(omega[i]);
sfree(om[i]);
sfree(om);
}
-void do_fit_ndim(int ndim, int natoms, real *w_rls, const rvec *xp, rvec *x)
+void do_fit_ndim(int ndim, int natoms, real* w_rls, const rvec* xp, rvec* x)
{
int j, m, r, c;
matrix R;
x[j][r] = 0;
for (c = 0; c < DIM; c++)
{
- x[j][r] += R[r][c]*x_old[c];
+ x[j][r] += R[r][c] * x_old[c];
}
}
}
}
-void do_fit(int natoms, real *w_rls, const rvec *xp, rvec *x)
+void do_fit(int natoms, real* w_rls, const rvec* xp, rvec* x)
{
do_fit_ndim(3, natoms, w_rls, xp, x);
}
-void reset_x_ndim(int ndim, int ncm, const int *ind_cm,
- int nreset, const int *ind_reset,
- rvec x[], const real mass[])
+void reset_x_ndim(int ndim, int ncm, const int* ind_cm, int nreset, const int* ind_reset, rvec x[], const real mass[])
{
int i, m, ai;
rvec xcm;
mm = mass[ai];
for (m = 0; m < ndim; m++)
{
- xcm[m] += mm*x[ai][m];
+ xcm[m] += mm * x[ai][m];
}
tm += mm;
}
mm = mass[i];
for (m = 0; m < ndim; m++)
{
- xcm[m] += mm*x[i][m];
+ xcm[m] += mm * x[i][m];
}
tm += mm;
}
}
}
-void reset_x(int ncm, const int *ind_cm,
- int nreset, const int *ind_reset,
- rvec x[], const real mass[])
+void reset_x(int ncm, const int* ind_cm, int nreset, const int* ind_reset, rvec x[], const real mass[])
{
reset_x_ndim(3, ncm, ind_cm, nreset, ind_reset, x, mass);
}