#include #include #include #include "nbgenerator.hh" #include "nbio.hh" #include "nbtypes.hh" #include "nbstopwatch.hh" /* * Global constants */ /* set gravity constant to one */ const double G = 1.0; /* The epsilon^2 for the softening */ const double epsilon2 = 1E-14; /** * Compute acceleration * * \param[in] n Number of bodies * \param[in] r Positions of the bodies * \param[in] m Masses of the bodies * \param[out] a The computed accelerations of the bodies * * The inner loop executes 26 floating point operations and is executed * ((n*n)-n)/2 times, resulting in 13*n*(n-1) floating point operations total * per call to acceleration(). */ void acceleration (int n, vector3 r[], double m[], vector3 a[]) { int i,j; double d0,d1,d2,d,d_sq,factori,factorj; double invfact; /* compute acceleration exploiting symmetry */ for (i=0; i