NDDEM
|
Static class to handle multi-dimensional mathematics, and more. It gets specialised for speed with template parameter d:dimension. More...
#include <Tools.h>
Public Member Functions | |
double | det (cv2d &M) |
double | det (cv2d &M) |
double | det (cv1d &M) |
double | det (cv1d &M) |
double | det (double M[2][2]) |
double | det (double M[1][1]) |
Static Public Member Functions | |
static int | getdim (void) |
Return the dimension. More... | |
static void | initialise () |
static void | clear () |
static void | matvecmult (v1d &res, cv1d &A, cv1d &v) |
static double | hyperspherical_xtophi (cv1d &x, v1d &phi) |
static void | hyperspherical_phitox (double r, cv1d &phi, v1d &x) |
static double | normsq (const vector< double > &a) |
static int | sgn (uint8_t a) |
static v1d | transpose (cv1d &a) |
static void | transpose_inplace (v1d &a) |
General functions | |
static void | initialise () |
Initialise the member variables, in particular the variables to handle skew-symmetric flattened matrix, cf. the class detailed description. More... | |
static void | clear () |
Get the class ready for a different dimension. More... | |
static bool | check_initialised (int dd) |
static int | sgn (uint8_t a) |
Sign function. More... | |
static int | sgn (double a) |
Sign function. More... | |
static std::pair< double, double > | two_max_element (cv1d &v) |
Return the two largest elements of v. More... | |
Vector and matrix initialisation and normalisation | |
static void | unitvec (vector< double > &v, int n) |
Construct a unit vector in place. More... | |
static v1d | unitvec (int n) |
Construct & return a unit vector. More... | |
static void | setzero (v2d &a) |
Set a matrix to zero in-place. More... | |
static void | setzero (v1d &a) |
Set a vector to zero in-place. More... | |
static double | norm (const vector< double > &a) |
Norm of a vector. More... | |
static void | norm (v1d &res, cv2d &a) |
Norm of a 2D-matrix, returns a 1D vector with the norms of the individual vectors. More... | |
static double | normdiff (cv1d &a, cv1d &b) |
Norm of a vector difference ![]() | |
static double | normsq (const vector< double > &a) |
Norm squared. More... | |
static double | normdiffsq (cv1d &a, cv1d &b) |
Norm squared of a vector difference ![]() | |
static void | orthonormalise (v1d &A) |
Orthonormalise A using the Gram-Shmidt process, in place. More... | |
static double | skewnorm (cv1d &a) |
Norm of a skew-symetric matrix. More... | |
static double | skewnormsq (cv1d &a) |
Norm squared of a skew-symetrix matrix. More... | |
static double | dot (cv1d &a, cv1d &b) |
Dot product. More... | |
static v1f | vsqrt (cv1f &a) |
Component-wise square root. More... | |
static v1f | vsq (cv1f &a) |
Component-wise squaring. More... | |
static void | surfacevelocity (v1d &res, cv1d &p, double *com, double *vel_com, double *omega_com) |
static void | setgravity (v2d &a, v1d &g, v1d &m) |
Set the gravity. ![]() | |
static v1d | randomize_vec (cv1d v) |
Produce a random vector. More... | |
Coordinate system change | |
static double | hyperspherical_xtophi (cv1d &x, v1d &phi) |
Convert from cartesian to hyperspherical coordinates. More... | |
static void | hyperspherical_phitox (double r, cv1d &phi, v1d &x) |
Convert from hyperspherical to cartesian coordinates. More... | |
Special physics computation | |
static double | Volume (double R) |
Compute the hypersphere volume. More... | |
static double | InertiaMomentum (double R, double rho) |
Compute the hypersphere moment of inertia. More... | |
Faster vector operations | |
These vector or matrix operations are working in place, and sometimes perform multiple operations at once | |
static void | vMul (v1d &res, cv1d &a, double b) |
Multiply a vector by a scalar in-place. More... | |
static void | vMul (v1d &res, cv1d &a, cv1d &b) |
Component-wise multiply 2 vectors in-place. More... | |
static void | vMinus (v1d &res, cv1d &a, cv1d &b) |
Difference of 2 vectors in-place ![]() | |
static void | vPlus (v1d &res, cv1d &a, double b) |
Addition of a vector by a scalar in-place. More... | |
static void | vPlus (v1d &res, cv1d &a, cv1d &b) |
Addition of 2 vectors in-place. More... | |
static void | vDiv (v1d &res, cv1d &a, double b) |
Division of a vector by a scalar in-place. More... | |
static void | vDiv (v1d &res, cv1d &a, cv1d &b) |
Component-wise discrete of 2 vectors in-place. More... | |
static void | vAddFew (v1d &res, cv1d &a, cv1d &b) |
static void | vAddScaled (v1d &res, double v, cv1d &a, cv1d &b) |
Addition of 3 vectors in-place. More... | |
static void | vAddScaled (v1d &res, double v, cv1d &a) |
Addition of a scaled vector ![]() | |
static void | vSubFew (v1d &res, cv1d &a, cv1d &b) |
Subtraction of 2 vectors ![]() | |
static void | vSubScaled (v1d &res, double v, cv1d &a) |
Subtraction of a scaled vector ![]() | |
Faster vector operations with error corrections (Kahan summation algorithm) | |
These vector or matrix operations are working in place, perform multiple operations at once, and are designed to use error correction across multiple calls. | |
static void | vAddFew (v1d &res, cv1d &a, cv1d &b, v1d &Corr) |
Addition of 3 vectors in-place with error correction (Kahan summation algorithm) More... | |
static void | vSubFew (v1d &res, cv1d &a, cv1d &b, v1d &Corr) |
Subtraction of 2 vectors ![]() | |
static void | vAddOne (v1d &res, cv1d &a, v1d &Corr) |
Addition of 2 vectors in-place with error correction (Kahan summation algorithm) More... | |
static void | vSubOne (v1d &res, cv1d &a, v1d &Corr) |
Subtraction of 2 vectors in-place with error correction (Kahan summation algorithm) More... | |
Matrix operations, usually operating on flattened matrices, cf. the description for more information on matrix storage | |
static v1d | skewmatvecmult (cv1d &M, cv1d &v) |
Multiply the skew symetric matrix M with vector v. More... | |
static v1d | skewmatvecmult (const double *M, cv1d &v) |
Multiply the skew symetric matrix M with vector v. More... | |
static void | skewmatvecmult (v1d &r, cv1d &M, cv1d &v) |
Multiply the skew symetric matrix M with vector v in place. More... | |
static void | skewmatvecmult (v1d &r, const double *M, cv1d &v) |
Multiply the skew symetric matrix M with vector v in place (overload) More... | |
static v1d | skewmatsquare (cv1d &A) |
Square the skew symetric matrix M. More... | |
static void | skewmatsquare (v1d &r, cv1d &A) |
Square the skew symetric matrix M in place. More... | |
static v1d | skewexpand (cv1d &A) |
Return the skew symetrix matrix M stored on d(d-1)/2 component as a full flattened matrix with d^2 components. More... | |
static void | skewexpand (v1d &r, cv1d &A) |
Return the skew symetrix matrix M stored on d(d-1)/2 component as a full flattened matrix with d^2 components in place. More... | |
static v1d | matmult (cv1d &A, cv1d &B) |
Multiply 2 matrix together. More... | |
static void | matmult (v1d &r, cv1d &A, cv1d &B) |
Multiply 2 matrix together in place. More... | |
static void | matvecmult (v1d &res, cv1d &A, cv1d &B) |
Multiply a matrix with a vector, in place. More... | |
static v1d | wedgeproduct (cv1d &a, cv1d &b) |
Wedge product of vectors. More... | |
static void | wedgeproduct (v1d &res, cv1d &a, cv1d &b) |
Wedge product in-place. More... | |
static v1d | transpose (cv1d &a) |
Transposition. More... | |
static void | transpose_inplace (v1d &a) |
Transpose in-place. More... | |
static double | det (cv2d &M) |
compute the matrix determinant (probably quite slow, but doesn't really really matters for the usage) More... | |
static double | det (cv1d &M) |
compute the matrix determinant (probably quite slow, but shouldn't really really matters for the usage) More... | |
static double | det (double M[d][d]) |
compute the matrix determinant using array on the stack (avoids malloc/free) More... | |
static v1d | inverse (cv1d &M) |
compute the matrix inverse (very slow and redundant calculation of the determinant for the comatrix, but shouldn't really really matters for the usage) More... | |
Saving and writing functions | |
static int | savetxt (char path[], const v2d &table, char const header[]) |
static void | savecsv (char path[], cv2d &X, cv1d &r, const vector< uint32_t > &PBCFlags, cv1d &Vmag, cv1d &OmegaMag, [[maybe_unused]] cv1d &Z) |
Save the location and a few more informations in a CSV file. More... | |
static void | savecsv (char path[], cv2d &X, cv2d &V, cv1d &r, const vector< uint32_t > &PBCFlags, cv1d &Vmag, cv1d &OmegaMag, [[maybe_unused]] cv1d &Z) |
Save the location and a few more informations in a CSV file. More... | |
static void | savecsv (char path[], cv2d &A) |
Save the orientation in a CSV file. More... | |
static void | savevtk (char path[], int N, cv2d &Boundaries, cv2d &X, cv1d &r, vector< TensorInfos > data) |
Save as a vtk file. Dimensions higher than 3 are stored as additional scalars. Additional informations can be passed as a vector of TensorInfos. More... | |
static void | print (cv1d M) |
static int | write1D (char path[], v1d table) |
static int | writeinline (initializer_list< v1d >) |
static int | writeinline_close (void) |
Static Public Attributes | |
static v1d | Eye |
The identity matrix in dimension <d> More... | |
static boost::random::mt19937 | rng |
Random number generator. More... | |
static boost::random::uniform_01< boost::mt19937 > | rand |
Returns a random number between 0 and 1. More... | |
static vector< pair< int, int > > | MASIndex |
For skew symmetric matrix, make the correspondance between linear index and (row,column) index. More... | |
Static Private Attributes | |
static vector< vector< int > > | MSigns |
For skew symetric matrix. -1 below the diagonal, 0 on the diagonal, +1 above the diagnal. More... | |
static vector< vector< int > > | MIndexAS |
For skew symmetric matrix, make the correspondance between linear index of a full matrix with the linear index of the skew-symetric storage. More... | |
static vector< FILE * > | outs |
Store the output file descriptors. More... | |
Static class to handle multi-dimensional mathematics, and more. It gets specialised for speed with template parameter d:dimension.
double Tools< 1 >::det | ( | double | M[1][1] | ) |
double Tools< 2 >::det | ( | double | M[2][2] | ) |
Return the dimension.
|
static |
|
inlinestatic |
Addition of 3 vectors in-place with error correction (Kahan summation algorithm)
Addition of 2 vectors in-place with error correction (Kahan summation algorithm)
Addition of a scaled vector .
|
inlinestatic |
Addition of 3 vectors in-place.
Addition of two scaled vector
Component-wise discrete of 2 vectors in-place.
Division of a vector by a scalar in-place.
Difference of 2 vectors in-place .
Component-wise multiply 2 vectors in-place.
Multiply a vector by a scalar in-place.
Addition of 2 vectors in-place.
Addition of a vector by a scalar in-place.
Subtraction of 2 vectors .
|
inlinestatic |
Subtraction of 2 vectors with error correction.
Subtraction of 2 vectors in-place with error correction (Kahan summation algorithm)
Subtraction of a scaled vector .