#include "gromacs/domdec/domdec.h"
#include "gromacs/domdec/domdec_struct.h"
#include "gromacs/gmxlib/network.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/perf_est.h"
#include "gromacs/mdtypes/commrec.h"
#include "gromacs/gmxlib/nrnb.h"
#include "gromacs/linearalgebra/nrjac.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/math/vectypes.h"
#include "gromacs/mdlib/groupcoord.h"
{
/* Remove PBC, make molecule(s) subject to ED whole. */
snew(x_pbc, mtop->natoms);
- m_rveccopy(mtop->natoms, x, x_pbc);
+ copy_rvecn(x, x_pbc, 0, mtop->natoms);
do_pbc_first_mtop(NULL, ir->ePBC, box, mtop, x_pbc);
}
/* Reset pointer to first ED data set which contains the actual ED data */
#include <algorithm>
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/math/functions.h"
#include "gromacs/math/gmxcomplex.h"
+#include "gromacs/math/units.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/math/vectypes.h"
#include "gromacs/mdtypes/commrec.h"
(*et)->tab_qxyz = NULL;
}
+//! Calculates wave vectors.
+static void calc_lll(const rvec box, rvec lll)
+{
+ lll[XX] = 2.0*M_PI/box[XX];
+ lll[YY] = 2.0*M_PI/box[YY];
+ lll[ZZ] = 2.0*M_PI/box[ZZ];
+}
+
//! Make tables for the structure factor parts
static void tabulateStructureFactors(int natom, rvec x[], int kmax, cvec **eir, rvec lll)
{
#include <cmath>
#include "gromacs/fft/parallel_3dfft.h"
+#include "gromacs/math/units.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/simd/simd.h"
#include "gromacs/simd/simd_math.h"
if (norm2(box[YY])*norm2(box[ZZ]) != 0)
{
- alpha = RAD2DEG*std::acos(cos_angle_no_table(box[YY], box[ZZ]));
+ alpha = RAD2DEG*gmx_angle(box[YY], box[ZZ]);
}
else
{
}
if (norm2(box[XX])*norm2(box[ZZ]) != 0)
{
- beta = RAD2DEG*std::acos(cos_angle_no_table(box[XX], box[ZZ]));
+ beta = RAD2DEG*gmx_angle(box[XX], box[ZZ]);
}
else
{
}
if (norm2(box[XX])*norm2(box[YY]) != 0)
{
- gamma = RAD2DEG*std::acos(cos_angle_no_table(box[XX], box[YY]));
+ gamma = RAD2DEG*gmx_angle(box[XX], box[YY]);
}
else
{
#include "gromacs/fileio/filetypes.h"
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/fileio/gmxfio-xdr.h"
+#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/md_enums.h"
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/pbc.h"
#include "gromacs/trajectory/trajectoryframe.h"
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/gmxana/gstat.h"
#include "gromacs/linearalgebra/matrix.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/statistics/statistics.h"
#include "gromacs/utility/arraysize.h"
{
rvec_sub(bun.end[0][i], bun.end[2][i], va);
rvec_sub(bun.end[2][i], bun.end[1][i], vb);
- unitv_no_table(va, va);
- unitv_no_table(vb, vb);
+ unitv(va, va);
+ unitv(vb, vb);
fprintf(fkink, " %6g", RAD2DEG*acos(iprod(va, vb)));
cprod(va, vb, vc);
copy_rvec(bun.mid[i], vr);
vr[ZZ] = 0;
- unitv_no_table(vr, vr);
+ unitv(vr, vr);
fprintf(fkinkr, " %6g", RAD2DEG*std::asin(iprod(vc, vr)));
vl[XX] = vr[YY];
vl[YY] = -vr[XX];
#include "gromacs/gmxana/gmx_ana.h"
#include "gromacs/math/do_fit.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/rmpbc.h"
#include "gromacs/topology/index.h"
#include "gromacs/fileio/trxio.h"
#include "gromacs/gmxana/gmx_ana.h"
#include "gromacs/gmxana/gstat.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/topology/index.h"
norm(box[XX]), norm(box[YY]), norm(box[ZZ]));
printf(" box angles :%7.2f%7.2f%7.2f (degrees)\n",
norm2(box[ZZ]) == 0 ? 0 :
- RAD2DEG*std::acos(cos_angle_no_table(box[YY], box[ZZ])),
+ RAD2DEG*gmx_angle(box[YY], box[ZZ]),
norm2(box[ZZ]) == 0 ? 0 :
- RAD2DEG*std::acos(cos_angle_no_table(box[XX], box[ZZ])),
+ RAD2DEG*gmx_angle(box[XX], box[ZZ]),
norm2(box[YY]) == 0 ? 0 :
- RAD2DEG*std::acos(cos_angle_no_table(box[XX], box[YY])));
+ RAD2DEG*gmx_angle(box[XX], box[YY]));
printf(" box volume :%7.2f (nm^3)\n", det(box));
}
norm(box[XX]), norm(box[YY]), norm(box[ZZ]));
printf("new box angles :%7.2f%7.2f%7.2f (degrees)\n",
norm2(box[ZZ]) == 0 ? 0 :
- RAD2DEG*std::acos(cos_angle_no_table(box[YY], box[ZZ])),
+ RAD2DEG*gmx_angle(box[YY], box[ZZ]),
norm2(box[ZZ]) == 0 ? 0 :
- RAD2DEG*std::acos(cos_angle_no_table(box[XX], box[ZZ])),
+ RAD2DEG*gmx_angle(box[XX], box[ZZ]),
norm2(box[YY]) == 0 ? 0 :
- RAD2DEG*std::acos(cos_angle_no_table(box[XX], box[YY])));
+ RAD2DEG*gmx_angle(box[XX], box[YY]));
printf("new box volume :%7.2f (nm^3)\n", det(box));
}
#include "gromacs/gmxana/gmx_ana.h"
#include "gromacs/gmxana/princ.h"
#include "gromacs/math/do_fit.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/rmpbc.h"
#include "gromacs/topology/index.h"
#include "gromacs/commandline/pargs.h"
#include "gromacs/fileio/confio.h"
#include "gromacs/gmxana/gmx_ana.h"
+#include "gromacs/math/units.h"
#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/force.h"
#include "gromacs/gmxana/gstat.h"
#include "gromacs/gmxana/princ.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/rmpbc.h"
#include "gromacs/topology/index.h"
#include "gromacs/gmxana/gmx_ana.h"
#include "gromacs/gmxana/gstat.h"
#include "gromacs/math/do_fit.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/pbcutil/rmpbc.h"
#include "gromacs/gmxana/gmx_ana.h"
#include "gromacs/gmxana/gstat.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/pbcutil/rmpbc.h"
#include "gromacs/gmxana/gmx_ana.h"
#include "gromacs/gmxana/princ.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/rmpbc.h"
#include "gromacs/topology/index.h"
#include "gromacs/gmxana/princ.h"
#include "gromacs/math/do_fit.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/rmpbc.h"
#include "gromacs/topology/ifunc.h"
#include "gromacs/linearalgebra/eigensolver.h"
#include "gromacs/math/do_fit.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/rmpbc.h"
#include "gromacs/topology/index.h"
#include "gromacs/gmxpreprocess/vsite_parm.h"
#include "gromacs/imd/imd.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/calc_verletbuf.h"
#include "gromacs/mdlib/compute_io.h"
#include "gromacs/gmxlib/conformation-utilities.h"
#include "gromacs/gmxpreprocess/read-conformation.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/selection/nbsearch.h"
#include "gromacs/fileio/xvgr.h"
#include "gromacs/gmxlib/network.h"
#include "gromacs/imd/imdsocket.h"
+#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/groupcoord.h"
#include "gromacs/mdlib/mdrun.h"
#include <algorithm>
#include "gromacs/math/functions.h"
+#include "gromacs/math/units.h"
#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/ishift.h"
#include <cmath>
#include <cstdint>
+#include "gromacs/utility/real.h"
+
namespace gmx
{
return square(power6(x));
}
+/*! \brief Maclaurin series for sinh(x)/x.
+ *
+ * Used for NH chains and MTTK pressure control.
+ * Here, we compute it to 10th order, which might be an overkill.
+ * 8th is probably enough, but it's not very much more expensive.
+ */
+static inline real series_sinhx(real x)
+{
+ real x2 = x*x;
+ return (1 + (x2/6.0)*(1 + (x2/20.0)*(1 + (x2/42.0)*(1 + (x2/72.0)*(1 + (x2/110.0))))));
+}
+
} // namespace gmx
void dprod(rvec a,rvec b,rvec c) c = a x b (cross product)
void dprod(rvec a,rvec b,rvec c) c = a * b (direct product)
real cos_angle(rvec a,rvec b)
- real cos_angle_no_table(rvec a,rvec b)
real distance2(rvec v1, rvec v2) = | v2 - v1 |^2
void unitv(rvec src,rvec dest) dest = src / |src|
- void unitv_no_table(rvec src,rvec dest) dest = src / |src|
matrix (3x3) operations:
! indicates that dest should not be the same as a, b or src
real trace(matrix m) = trace(m)
*/
-#include <math.h>
+#include <cmath>
#include "gromacs/math/functions.h"
-#include "gromacs/math/units.h"
-#include "gromacs/math/utilities.h"
#include "gromacs/math/vectypes.h"
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/real.h"
-#ifdef __cplusplus
-extern "C" {
-#elif 0
-} /* avoid screwing up indentation */
-#endif
-
-/* Maclaurin series for sinh(x)/x, useful for NH chains and MTTK pressure control
- Here, we compute it to 10th order, which might be overkill, 8th is probably enough,
- but it's not very much more expensive. */
-
-static gmx_inline real series_sinhx(real x)
-{
- real x2 = x*x;
- return (1 + (x2/6.0)*(1 + (x2/20.0)*(1 + (x2/42.0)*(1 + (x2/72.0)*(1 + (x2/110.0))))));
-}
-
static gmx_inline void rvec_add(const rvec a, const rvec b, rvec c)
{
real x, y, z;
* don't need 1/dnorm(), otherwise use dnorm2()*dinvnorm(). */
static gmx_inline double dnorm(const dvec a)
{
- return sqrt(diprod(a, a));
+ return std::sqrt(diprod(a, a));
}
/* WARNING:
* don't need 1/norm(), otherwise use norm2()*invnorm(). */
static gmx_inline real norm(const rvec a)
{
- return sqrt(iprod(a, a));
+ return std::sqrt(iprod(a, a));
}
static gmx_inline real invnorm(const rvec a)
return cosval;
}
-/* WARNING:
- * Do _not_ use these routines to calculate the angle between two vectors
- * as acos(cos_angle(u,v)). While it might seem obvious, the acos function
- * is very flat close to -1 and 1, which will lead to accuracy-loss.
- * Instead, use the new gmx_angle() function directly.
- */
-static gmx_inline real
-cos_angle_no_table(const rvec a, const rvec b)
-{
- /* This version does not need the invsqrt lookup table */
- real cosval;
- int m;
- double aa, bb, ip, ipa, ipb; /* For accuracy these must be double! */
-
- ip = ipa = ipb = 0.0;
- for (m = 0; (m < DIM); m++) /* 18 */
- {
- aa = a[m];
- bb = b[m];
- ip += aa*bb;
- ipa += aa*aa;
- ipb += bb*bb;
- }
- cosval = ip/sqrt(ipa*ipb); /* 12 */
- /* 30 TOTAL */
- if (cosval > 1.0)
- {
- return 1.0;
- }
- if (cosval < -1.0)
- {
- return -1.0;
- }
-
- return cosval;
-}
-
-
static gmx_inline void cprod(const rvec a, const rvec b, rvec c)
{
c[XX] = a[YY]*b[ZZ]-a[ZZ]*b[YY];
dest[XX][YY] = 0.0;
dest[XX][ZZ] = 0.0;
dest[YY][XX] = a[YY][XX]*b[XX][XX]+a[YY][YY]*b[YY][XX];
- dest[YY][YY] = a[YY][YY]*b[YY][YY];
+ dest[YY][YY] = a[YY][YY]*b[YY][YY];
dest[YY][ZZ] = 0.0;
dest[ZZ][XX] = a[ZZ][XX]*b[XX][XX]+a[ZZ][YY]*b[YY][XX]+a[ZZ][ZZ]*b[ZZ][XX];
- dest[ZZ][YY] = a[ZZ][YY]*b[YY][YY]+a[ZZ][ZZ]*b[ZZ][YY];
- dest[ZZ][ZZ] = a[ZZ][ZZ]*b[ZZ][ZZ];
+ dest[ZZ][YY] = a[ZZ][YY]*b[YY][YY]+a[ZZ][ZZ]*b[ZZ][YY];
+ dest[ZZ][ZZ] = a[ZZ][ZZ]*b[ZZ][ZZ];
}
static gmx_inline void mmul(gmx_cxx_const matrix a, gmx_cxx_const matrix b, matrix dest)
dest[ZZ] = linv*src[ZZ];
}
-static gmx_inline void unitv_no_table(const rvec src, rvec dest)
-{
- real linv;
-
- linv = 1.0/sqrt(norm2(src));
- dest[XX] = linv*src[XX];
- dest[YY] = linv*src[YY];
- dest[ZZ] = linv*src[ZZ];
-}
-
-static void calc_lll(const rvec box, rvec lll)
-{
- lll[XX] = 2.0*M_PI/box[XX];
- lll[YY] = 2.0*M_PI/box[YY];
- lll[ZZ] = 2.0*M_PI/box[ZZ];
-}
-
static gmx_inline real trace(gmx_cxx_const matrix m)
{
return (m[XX][XX]+m[YY][YY]+m[ZZ][ZZ]);
}
-/* Operations on multidimensional rvecs, used e.g. in edsam.c */
-static gmx_inline void m_rveccopy(int dim, gmx_cxx_const rvec *a, rvec *b)
-{
- /* b = a */
- int i;
-
- for (i = 0; i < dim; i++)
- {
- copy_rvec(a[i], b[i]);
- }
-}
-
-/*computer matrix vectors from base vectors and angles */
-static gmx_inline void matrix_convert(matrix box, const rvec vec, rvec angle)
-{
- svmul(DEG2RAD, angle, angle);
- box[XX][XX] = vec[XX];
- box[YY][XX] = vec[YY]*cos(angle[ZZ]);
- box[YY][YY] = vec[YY]*sin(angle[ZZ]);
- 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]);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
#endif
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/fileio/pdbio.h"
#include "gromacs/gmxlib/nrnb.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/gmx_omp_nthreads.h"
#include "gromacs/mdlib/mdrun.h"
#ifndef GMX_MDLIB_GENBORN_H
#define GMX_MDLIB_GENBORN_H
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vectypes.h"
struct gmx_genborn_t;
#include "md_support.h"
+#include <climits>
+
#include <algorithm>
#include "gromacs/domdec/domdec.h"
#include "thread_mpi/atomic.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/gmx_omp_nthreads.h"
#include "gromacs/mdlib/nb_verlet.h"
#include <cmath>
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/nbnxn_consts.h"
#include "gromacs/mdlib/nbnxn_search.h"
{
g = 0.25*dt*veta*alpha;
mv1 = exp(-g);
- mv2 = series_sinhx(g);
+ mv2 = gmx::series_sinhx(g);
}
else
{
{
g = 0.5*dt*veta;
mr1 = exp(g);
- mr2 = series_sinhx(g);
+ mr2 = gmx::series_sinhx(g);
}
else
{
#include <algorithm>
#include "gromacs/math/functions.h"
+#include "gromacs/math/units.h"
#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/math/vecdump.h"
return ptr;
}
+void matrix_convert(matrix box, const rvec vec, const rvec angleInDegrees)
+{
+ rvec angle;
+ svmul(DEG2RAD, angleInDegrees, angle);
+ box[XX][XX] = vec[XX];
+ box[YY][XX] = vec[YY]*cos(angle[ZZ]);
+ box[YY][YY] = vec[YY]*sin(angle[ZZ]);
+ 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]);
+}
+
real max_cutoff2(int ePBC, const matrix box)
{
real min_hv2, min_ss;
*/
const char *check_box(int ePBC, const matrix box);
+/*! \brief Creates box matrix from edge lengths and angles. */
+void matrix_convert(matrix box, const rvec vec, const rvec angleInDegrees);
+
/*! \brief Compute the maximum cutoff for the box
* Returns the square of the maximum cut-off allowed for the box,
#include "gromacs/gmxlib/network.h"
#include "gromacs/linearalgebra/nrjac.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/groupcoord.h"
#include "gromacs/mdlib/mdrun.h"
/* Remove pbc, make molecule whole.
* When ir->bContinuation=TRUE this has already been done, but ok. */
snew(x_pbc, mtop->natoms);
- m_rveccopy(mtop->natoms, x, x_pbc);
+ copy_rvecn(x, x_pbc, 0, mtop->natoms);
do_pbc_first_mtop(NULL, ir->ePBC, box, mtop, x_pbc);
/* All molecules will be whole now, but not necessarily in the home box.
* Additionally, if a rotation group consists of more than one molecule
#include "gromacs/fileio/confio.h"
#include "gromacs/gmxlib/network.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdtypes/commrec.h"
#include "gromacs/mdtypes/md_enums.h"
#include <algorithm>
#include <string>
+#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
#include "gromacs/selection/position.h"
#include "gromacs/utility/cstringutil.h"
#include <vector>
+#include "gromacs/math/utilities.h"
#include "gromacs/options/basicoptions.h"
#include "gromacs/simd/simd.h"
/* Remove pbc, make molecule whole. */
snew(x_pbc, mtop->natoms);
- m_rveccopy(mtop->natoms, x, x_pbc);
+ copy_rvecn(x, x_pbc, 0, mtop->natoms);
/* This can only make individual molecules whole, not multimers */
do_pbc_mtop(NULL, ePBC, box, mtop, x_pbc);
#include "gromacs/analysisdata/modules/average.h"
#include "gromacs/analysisdata/modules/histogram.h"
#include "gromacs/analysisdata/modules/plot.h"
+#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
#include "gromacs/options/basicoptions.h"
#include "gromacs/options/filenameoption.h"
#include "gromacs/analysisdata/modules/average.h"
#include "gromacs/analysisdata/modules/plot.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
#include "gromacs/options/basicoptions.h"
#include "gromacs/options/filenameoption.h"
#include <vector>
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/selection/nbsearch.h"
#include "gromacs/listed-forces/orires.h"
#include "gromacs/math/calculate-ewald-splitting-coefficient.h"
#include "gromacs/math/functions.h"
+#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/calc_verletbuf.h"
#include "gromacs/mdlib/constr.h"