|
Peano
|
My collection of tiny vector operations. More...
Namespaces | |
| namespace | tests |
Data Structures | |
| class | DynamicMatrix |
| My standard matrix is a matrix where the size is fixed at compile time. More... | |
| class | Matrix |
| Static (i.e. More... | |
| class | ShallowMatrix |
| Shallow matrix wrapping an existing array. More... | |
| struct | SmartPointerVector |
| Simple SmartPointerVector class. More... | |
| struct | Vector |
| Simple vector class. More... | |
| struct | VectorCompare |
| Comparison operator for boolean vectors. More... | |
Functions | |
| DynamicMatrix | transpose (const DynamicMatrix &matrix) |
| template<int Rows, int Cols, typename Scalar > | |
| void | modifiedGramSchmidt (Matrix< Rows, Cols, Scalar > A, Matrix< Rows, Cols, Scalar > &Q, Matrix< Cols, Cols, Scalar > &R) |
| Produces an economy-size QR decomposition of a matrix A, A is changed. | |
| void | modifiedGramSchmidt (DynamicMatrix A, DynamicMatrix &Q, DynamicMatrix &R) |
| template<int Rows, typename Scalar > | |
| void | lu (Matrix< Rows, Rows, Scalar > &A, Vector< Rows, int > &pivots) |
| Performs an in-situ LU-decomposition of the square matrix A. | |
| template<int Rows, typename Scalar > | |
| void | lu (Matrix< Rows, Rows, Scalar > &A) |
| In-situ LU without pivoting. | |
| template<int Rows, typename Scalar > | |
| Vector< Rows, Scalar > | backSubstitution (const Matrix< Rows, Rows, Scalar > &R, const Vector< Rows, Scalar > &f) |
| Back substitution following LU decomposition. | |
| void | backSubstitution (const DynamicMatrix &R, const double *f, double *x) |
| DynamicMatrix | invertUpperTriangular (const DynamicMatrix &R) |
| template<int Rows, typename Scalar > | |
| Matrix< Rows, Rows, Scalar > | invert (const Matrix< Rows, Rows, Scalar > &M) |
| Invert matrix with LU decomposition. | |
| template<typename Scalar > | |
| Matrix< 2, 2, Scalar > | invert (const Matrix< 2, 2, Scalar > &M) |
| Specialisation of inversion. | |
| template<typename Scalar > | |
| Matrix< 3, 3, Scalar > | invert (const Matrix< 3, 3, Scalar > &M) |
| Specialisation of inversion. | |
| template<typename Scalar > | |
| double | det (const Matrix< 2, 2, Scalar > &R) |
| template<typename Scalar > | |
| double | det (const Matrix< 3, 3, Scalar > &R) |
| template<int Rows, int Cols, typename Scalar > | |
| Matrix< Rows, Cols, Scalar > | buildMatrix (const Scalar *values) |
| Deep copy builder function. | |
| template<int Rows, int Cols, int X, typename Scalar > | |
| Matrix< Rows, Cols, Scalar > | multiply (const Matrix< Rows, X, Scalar > &lhs, const Matrix< X, Cols, Scalar > &rhs) |
| Performs a matrix x matrix multiplication. | |
| template<int Rows, int Cols, int X, typename Scalar > | |
| Matrix< Rows, Cols, Scalar > | multiplyComponents (const Matrix< Rows, X, Scalar > &lhs, const Matrix< X, Cols, Scalar > &rhs) |
| template<int Rows, int Cols, int X, typename Scalar > | |
| Matrix< Rows, Cols, Scalar > | operator* (const Matrix< Rows, X, Scalar > &lhs, const Matrix< X, Cols, Scalar > &rhs) |
| template<int Rows, int Cols, typename Scalar > | |
| bool | operator== (const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs) |
| Bitwise comparison of the components of two matrices on equality. | |
| template<int Rows, int Cols, typename Scalar > | |
| bool | equals (const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs, const Scalar &tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| Compares to matrices on equality by means of a numerical accuracy. | |
| template<int Rows, int Cols, typename Scalar > | |
| Matrix< Rows, Cols, Scalar > | operator+ (const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs) |
| template<int Rows, int Cols, typename Scalar > | |
| Matrix< Rows, Cols, Scalar > | operator- (const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs) |
| template<int Rows, int Cols, typename Scalar > | |
| std::pair< int, int > | equalsReturnIndex (const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs, const Scalar &tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| Return Index of element which is not equals. | |
| template<int Rows, int Cols, typename Scalar > | |
| Scalar | sum (const Matrix< Rows, Cols, Scalar > &matrix) |
| Computes the sum of all entries of the matrix. | |
| template<int Rows, int Cols, typename Scalar > | |
| Matrix< Cols, Rows, Scalar > | transpose (const Matrix< Rows, Cols, Scalar > &matrix) |
| template<int Rows, typename Scalar > | |
| static Matrix< Rows, Rows, Scalar > | identity () |
| Returns the identity matrix. | |
| template<int Rows, typename Scalar > | |
| Vector< Rows, Scalar > | diag (const Matrix< Rows, Rows, Scalar > &matrix) |
| Extract diagonal vector from matrix. | |
| template<int Rows, int Cols, typename Scalar > | |
| Vector< Cols, Scalar > | row (const Matrix< Rows, Cols, Scalar > &matrix, int whichRow) |
| Extract row from matrix. | |
| template<int Rows, int Cols, typename Scalar > | |
| Vector< Rows, Scalar > | col (const Matrix< Rows, Cols, Scalar > &matrix, int whichColumn) |
| Extract row from matrix. | |
| template<int Rows, int Cols, typename Scalar > | |
| Matrix< Rows, Cols, Scalar > | invertEntries (const Matrix< Rows, Cols, Scalar > &matrix) |
| Inverts each individual entry. | |
| template<int Rows, int Cols, typename Scalar > | |
| Scalar | frobeniusNorm (const Matrix< Rows, Cols, Scalar > &matrix) |
| template<int Rows, int Cols, typename Scalar > | |
| Scalar | elementMax (const Matrix< Rows, Cols, Scalar > &matrix) |
| Max norm. | |
| template<int Rows, int Cols, typename Scalar > | |
| Matrix< Rows, Cols, Scalar > & | operator*= (Matrix< Rows, Cols, Scalar > &matrix, const Scalar &scalar) |
| template<int Rows, int Cols, typename Scalar > | |
| Matrix< Rows, Cols, Scalar > | operator* (const Matrix< Rows, Cols, Scalar > &matrix, const Scalar &scalar) |
| Multiplies every component of the matrix with the scalar. | |
| template<int Rows, int Cols, typename Scalar > | |
| Matrix< Rows, Cols, Scalar > | operator* (const Scalar &scalar, const Matrix< Rows, Cols, Scalar > &matrix) |
| Multiplies every component of the matrix with the scalar. | |
| template<int Rows, int Cols> | |
| Matrix< Rows, Cols, std::complex< double > > | operator* (const double &scalar, const Matrix< Rows, Cols, std::complex< double > > &matrix) |
| template<int Rows, int Cols, typename Scalar > | |
| Vector< Rows, Scalar > | multiply (const Matrix< Rows, Cols, Scalar > &matrix, const Vector< Cols, Scalar > &vector) |
| Performs a matrix x vector multiplication. | |
| template<int Rows, int Cols, typename Scalar > | |
| void | matVec (const Matrix< Rows, Cols, Scalar > &matrix, Scalar alpha, const Vector< Cols, Scalar > &v, Vector< Rows, Scalar > &r) |
| Compute r = r + alpha * M * v in-situ. | |
| template<int Rows, int Cols, typename Scalar > | |
| Vector< Rows, Scalar > | operator* (const Matrix< Rows, Cols, Scalar > &matrix, const Vector< Cols, Scalar > &vector) |
| Performs a matrix x vector multiplication. | |
| template<int Size, typename Scalar > | |
| Matrix< Size, Size, Scalar > | outerDot (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Outer dot product. | |
| double | relativeEpsNormalisedAgainstValueGreaterOne (double valueA, double valueB=std::numeric_limits< double >::min(), double eps=NUMERICAL_ZERO_DIFFERENCE) |
| Determine a relative tolerance from one or two values. | |
| double | relativeEps (double valueA, double valueB=std::numeric_limits< double >::min(), double eps=NUMERICAL_ZERO_DIFFERENCE) |
| Determine a relative tolerance from one or two values. | |
| double | max (double a, double b, double c) |
| I need the maximum of three values all the time, to I decided to write a function for this. | |
| double | pow (double base, double exponent) |
| Wrapper around std::pow which is redirected to Intel's implementation on Intel machines. | |
| double | convertAbsoluteIntoRelativeValue (double referenceValue, double value) |
| Convert an absolute value into a relative one. | |
| double | abs (double value) |
| Returns the absolute value of a type by redirecting to std::abs. | |
| int | abs (int value) |
| Returns the absolute value of the given int. | |
| double | abs (const std::complex< double > &value) |
| int | aPowI (int i, int a) |
| Computes the i-th power of a in integer arithmetic. | |
| bool | greater (double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| bool | greaterEquals (double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| bool | equals (double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| static InlineMethod bool | smaller (double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| Smaller operator for floating point values. | |
| bool | smallerEquals (double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| bool | equals (const std::complex< double > &lhs, const std::complex< double > &rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| int | sign (double value, double tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| int | round (double value) |
| int | round (float value) |
| template<int Rows, int Cols, typename Scalar > | |
| Vector< Rows, Scalar > | multiply (const ShallowMatrix< Rows, Cols, Scalar > &matrix, const Vector< Cols, Scalar > &vector) |
| Performs a matrix x vector multiplication. | |
| template<int Rows, int Cols, typename Scalar > | |
| Vector< Rows, Scalar > | multiply (const ShallowMatrix< Rows, Cols, Scalar > &matrix, const SmartPointerVector< Cols, Scalar > &vector) |
| template<typename NewScalarType , int Size, typename Scalar > | |
| tarch::la::SmartPointerVector< Size, NewScalarType > | convertScalar (const tarch::la::SmartPointerVector< Size, Scalar > &SmartPointerVector) |
| template<typename NewScalarType , int Size, typename Scalar > | |
| tarch::la::Vector< Size, NewScalarType > | convertScalar (const tarch::la::Vector< Size, Scalar > &vector) |
| Convert the scalar type underlying a vector. | |
| template<int Size, typename Scalar > | |
| Scalar | norm1 (const Vector< Size, Scalar > &vector) |
| Computes the 1-norm of the vector, i.e. | |
| template<int Size> | |
| double | norm1 (const Vector< Size, std::complex< double > > &vector) |
| Specialisation that is different to standard definition. | |
| template<int Size, typename Scalar > | |
| Scalar | norm2 (const Vector< Size, Scalar > &vector) |
| Computes the 2-norm of the vector, i.e. | |
| template<int Size, typename Scalar > | |
| Scalar | norm2Squared (const Vector< Size, Scalar > &vector) |
| template<int Size> | |
| double | norm2 (const Vector< Size, std::complex< double > > &vector) |
| Specialisation that is different to standard definition. | |
| template<int Size> | |
| double | norm2Squared (const Vector< Size, std::complex< double > > &vector) |
| template<int Size, typename Scalar > | |
| Scalar | normMax (const Vector< Size, Scalar > &vector) |
| Computes the max-norm of the vector. | |
| template<int Size> | |
| double | normMax (const Vector< Size, std::complex< double > > &vector) |
| Specialisation that is different to standard definition. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | abs (const Vector< Size, Scalar > &vector) |
| Computes the absolute component values of the vector, creating a temporary vector to hold the result. | |
| template<int Size> | |
| Vector< Size, double > | abs (const Vector< Size, std::complex< double > > &vector) |
| Specialisation that is different to standard definition. | |
| template<int Size, typename Scalar > | |
| Scalar | sum (const Vector< Size, Scalar > &vector) |
| Sums up the component values of the vector. | |
| template<int Size, typename Scalar > | |
| Scalar | volume (const Vector< Size, Scalar > &vector) |
| Computes the volume of the tetrahedron spanned by the Cartesian unit vectors scaled by the corresponding components of the given vector. | |
| template<int Size, typename Scalar > | |
| bool | allEntriesAreTheSame (const Vector< Size, Scalar > &vector) |
| template<int Size, typename Scalar > | |
| Scalar | average (const Vector< Size, Scalar > &vector) |
| Computes the volume of the tetrahedron spanned by the Cartesian unit vectors scaled by the corresponding components of the given vector. | |
| template<int Size, typename Scalar > | |
| int | indexMax (const Vector< Size, Scalar > &vector) |
| Returns the index of the element with maximal value (NOT absolute value). | |
| template<int Size, typename Scalar > | |
| int | indexMin (const Vector< Size, Scalar > &vector) |
| Returns the index of the element with minimal value (NOT absolute value). | |
| template<int Size, typename Scalar > | |
| Scalar | max (const Vector< Size, Scalar > &vector) |
| Returns the element with maximal value (NOT absolute value). | |
| template<int Size, typename Scalar > | |
| Scalar | maxAbs (const Vector< Size, Scalar > &vector) |
| Returns the element with maximal absolute value. | |
| template<int Size, typename Scalar > | |
| Scalar | min (const Vector< Size, Scalar > &vector) |
| Returns the element with minimal value (NOT absolute value). | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | invertEntries (const Vector< Size, Scalar > &vector) |
| template<int Size> | |
| Vector< Size, double > | real (const Vector< Size, std::complex< double > > &vector) |
| template<int Size> | |
| Vector< Size, double > | imag (const Vector< Size, std::complex< double > > &vector) |
| template<int Size> | |
| double | maxReal (const Vector< Size, std::complex< double > > &vector) |
| template<int Size> | |
| double | maxImag (const Vector< Size, std::complex< double > > &vector) |
| template<int Size, typename Scalar > | |
| bool | contains (const Vector< Size, Scalar > &vector, const Scalar &value) |
| template<int Size, typename Scalar > | |
| int | count (const Vector< Size, Scalar > &vector, const Scalar &value) |
| template<int Size, typename Scalar > | |
| int | isEntryNan (const Vector< Size, Scalar > &vector) |
| template<int Size, typename Scalar > | |
| int | isEntryFinite (const Vector< Size, Scalar > &vector) |
| template<int Size, typename Scalar > | |
| std::vector< Scalar > | toSTLVector (const Vector< Size, Scalar > &vector) |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > & | operator*= (Vector< Size, Scalar > &vector, const Scalar &scalar) |
| Multiplies every component of the vector with the scalar and assigns the result to the vector. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > & | operator/= (Vector< Size, Scalar > &vector, const Scalar &scalar) |
| Divides every component of the vector by the scalar and assigns the result to the vector. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > & | operator+= (Vector< Size, Scalar > &vector, const Scalar &scalar) |
| Adds every component of the vector to the scalar and assigns the result to the vector. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > & | operator-= (Vector< Size, Scalar > &vector, const Scalar &scalar) |
| Subtracts the scalar from every component of the vector and assigns the result to the vector. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | operator* (const Vector< Size, Scalar > &vector, const Scalar &scalar) |
| Multiplies every component of the vector with the scalar and returns the result. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | operator* (const Scalar &scalar, const Vector< Size, Scalar > &vector) |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | operator/ (const Vector< Size, Scalar > &vector, const Scalar &scalar) |
| Divides every component of the vector by the scalar and returns the result. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | operator+ (const Vector< Size, Scalar > &vector, const Scalar &scalar) |
| Adds the scalar to every component of the vector and returns the result. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | operator+ (const Scalar &scalar, const Vector< Size, Scalar > &vector) |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | operator- (const Vector< Size, Scalar > &vector, const Scalar &scalar) |
| Subtracts the scalar from every component of the vector and returns the result. | |
| template<int Size, typename Scalar > | |
| bool | equals (const Vector< Size, Scalar > &lhs, const Scalar &cmp, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| !!! Vectorisation remark | |
| template<int Size, typename Scalar > | |
| bool | oneEquals (const Vector< Size, Scalar > &lhs, const Scalar &cmp, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size, typename Scalar > | |
| bool | oneGreater (const Vector< Size, Scalar > &lhs, const Scalar &cmp, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size, typename Scalar > | |
| bool | oneGreaterEquals (const Vector< Size, Scalar > &lhs, const Scalar &cmp, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size, typename Scalar > | |
| bool | allGreater (const Vector< Size, Scalar > &lhs, const Scalar &cmp, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size, typename Scalar > | |
| bool | allGreaterEquals (const Vector< Size, Scalar > &lhs, const Scalar &cmp, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size, typename Scalar > | |
| bool | oneSmaller (const Vector< Size, Scalar > &lhs, const Scalar &cmp, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size, typename Scalar > | |
| bool | oneSmallerEquals (const Vector< Size, Scalar > &lhs, const Scalar &cmp, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size, typename Scalar > | |
| bool | allSmaller (const Vector< Size, Scalar > &lhs, const Scalar &cmp, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size, typename Scalar > | |
| bool | allSmallerEquals (const Vector< Size, Scalar > &lhs, const Scalar &cmp, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size> | |
| bool | equals (const Vector< Size, int > &lhs, const int &cmp) |
| Specialisation for int. | |
| template<int Size> | |
| bool | oneEquals (const Vector< Size, int > &lhs, const int &cmp) |
| template<int Size> | |
| bool | oneGreater (const Vector< Size, int > &lhs, const int &cmp) |
| template<int Size> | |
| bool | oneGreaterEquals (const Vector< Size, int > &lhs, const int &cmp) |
| template<int Size> | |
| bool | oneSmaller (const Vector< Size, int > &lhs, const int &cmp) |
| template<int Size> | |
| bool | oneSmallerEquals (const Vector< Size, int > &lhs, const int &cmp) |
| template<int Size> | |
| bool | allGreater (const Vector< Size, int > &lhs, const int &cmp) |
| template<int Size> | |
| bool | allGreaterEquals (const Vector< Size, int > &lhs, const int &cmp) |
| template<int Size> | |
| bool | allSmaller (const Vector< Size, int > &lhs, const int &cmp) |
| template<int Size> | |
| bool | allSmallerEquals (const Vector< Size, int > &lhs, const int &cmp) |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | remainder (const Vector< Size, Scalar > &vector, double h) |
| Return the remainder of a division. | |
| template<int SizeLhs, int SizeRhs, typename Scalar > | |
| Vector< SizeLhs, Scalar > | slice (const Vector< SizeRhs, Scalar > &vector, int fromIndex, int stride=1) |
| Returns subpart of the vector. | |
| template<int SizeLhs, int SizeRhs, typename Scalar > | |
| void | slice (Vector< SizeLhs, Scalar > &toVector, const Vector< SizeRhs, Scalar > &fromVector, int fromIndexInToVector, int strideInToVector=1) |
| Setter. | |
| template<int SizeLhs, int SizeRhs, typename Scalar > | |
| Vector< SizeLhs, Scalar > | expandOrSlice (const Vector< SizeRhs, Scalar > &vector) |
| Take a scalar or vector and map it onto a vector. | |
| template<int SizeLhs, typename Scalar > | |
| Vector< SizeLhs, Scalar > | expandOrSlice (const Scalar &scalar) |
| Delegates to slice(). | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > & | operator+= (Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Adds rVector to lVector and assigns the result to lVector. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > & | operator-= (Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Subtracts rVector from lVector and assigns the result to lVector. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | operator+ (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Adds rVector to lVector. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | operator- (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Subtracts rVector from lVector. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | multiplyComponents (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Multiplies every component of the vectors with each other and writes the results into result. | |
| template<int Size, typename Scalar > | |
| Scalar | operator* (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Performs the dot (=inner) product of two vectors. | |
| template<int Size, typename Scalar > | |
| Scalar | dot (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Performs the dot (=inner) product of two vectors. | |
| template<int Size, typename Scalar > | |
| Scalar | innerDot (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Performs the dot (=inner) product of two vectors. | |
| template<typename Scalar > | |
| Vector< 3, Scalar > | cross (const Vector< 3, Scalar > &lhs, const Vector< 3, Scalar > &rhs) |
| Performs the cross product of two 3D vectors into result. | |
| template<int Size, typename Scalar > | |
| bool | equals (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| Compares to vectors on equality by means of a numerical accuracy. | |
| template<int Size, typename Scalar > | |
| bool | firstGreater (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| Compares sequentially every component pair of lVector and rVector, and stops as soon as one is greater than the other. | |
| template<int Size, typename Scalar > | |
| bool | oneGreater (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| Returns true, if one component of lVector is greater than the corresponding component in rVector up to numerical accuracy. | |
| template<int Size, typename Scalar > | |
| bool | oneGreaterEquals (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| Returns true, if one component of lVector is greater or equals than the corresponding component in rVector up to numerical accuracy. | |
| template<int Size, typename Scalar > | |
| bool | allGreater (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| Returns true, if all components of lVector are greater than the corresponding components in rVector up to numerical accuracy. | |
| template<int Size, typename Scalar > | |
| bool | allGreaterEquals (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| Returns true, if all components of lVector are greater or equals than the corresponding components in rVector up to numerical accuracy. | |
| template<int Size, typename Scalar > | |
| bool | allSmaller (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size, typename Scalar > | |
| bool | allSmallerEquals (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size, typename Scalar > | |
| bool | oneSmaller (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size, typename Scalar > | |
| bool | oneSmallerEquals (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | max (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Component-wise max evaluation. | |
| template<int Size, typename Scalar > | |
| Vector< Size, Scalar > | min (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Component-wise min evaluation. | |
| template<int Size, typename Scalar > | |
| bool | operator== (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Bit-wise comparison of the components of two vectors for equality. | |
| template<int Size, typename Scalar > | |
| bool | operator!= (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs) |
| Bit-wise comparison of the components of two vectors for inequality. | |
| template<int Size, typename Scalar > | |
| int | equalsReturnIndex (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
| Return Index of element which is not equals. | |
| template<int Size> | |
| int | equalsReturnIndex (const Vector< Size, int > &lhs, const Vector< Size, int > &rhs) |
| template<int Size> | |
| int | countEqualEntries (const Vector< Size, int > &lhs, const Vector< Size, int > &rhs) |
| Run through both vectors and count how many entries are the same. | |
| template<int Size, typename Scalar > | |
| int | countEqualEntries (const Vector< Size, Scalar > &lhs, const Vector< Size, Scalar > &rhs, const Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE) |
Variables | |
| constexpr double | PI = 3.1415926535897932384626433832795028841972 |
| constexpr double | E = 2.7182818284590452353602874713526624977572 |
| constexpr double | NUMERICAL_ZERO_DIFFERENCE = 1.0e-8 |
My collection of tiny vector operations.
The coolest thing about this one is that it supports Matlab/Python-ensque vector notations. Otherwise, it is pretty trivial.
| double tarch::la::abs | ( | const std::complex< double > & | value | ) |
| Vector< Size, Scalar > tarch::la::abs | ( | const Vector< Size, Scalar > & | vector | ) |
Computes the absolute component values of the vector, creating a temporary vector to hold the result.
| Vector< Size, double > tarch::la::abs | ( | const Vector< Size, std::complex< double > > & | vector | ) |
Specialisation that is different to standard definition.
Works as result type is not part of the signature
| double tarch::la::abs | ( | double | value | ) |
Returns the absolute value of a type by redirecting to std::abs.
| int tarch::la::abs | ( | int | value | ) |
Returns the absolute value of the given int.
| bool tarch::la::allEntriesAreTheSame | ( | const Vector< Size, Scalar > & | vector | ) |
| bool tarch::la::allGreater | ( | const Vector< Size, int > & | lhs, |
| const int & | cmp ) |
| bool tarch::la::allGreater | ( | const Vector< Size, Scalar > & | lhs, |
| const Scalar & | cmp, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| bool tarch::la::allGreater | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Returns true, if all components of lVector are greater than the corresponding components in rVector up to numerical accuracy.
| tolerance | Absolute tolerance. If you prefer to use a relative measure, you might want to use tarch::la::relativeEps() |
| bool tarch::la::allGreaterEquals | ( | const Vector< Size, int > & | lhs, |
| const int & | cmp ) |
| bool tarch::la::allGreaterEquals | ( | const Vector< Size, Scalar > & | lhs, |
| const Scalar & | cmp, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| bool tarch::la::allGreaterEquals | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Returns true, if all components of lVector are greater or equals than the corresponding components in rVector up to numerical accuracy.
| bool tarch::la::allSmaller | ( | const Vector< Size, int > & | lhs, |
| const int & | cmp ) |
| bool tarch::la::allSmaller | ( | const Vector< Size, Scalar > & | lhs, |
| const Scalar & | cmp, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| bool tarch::la::allSmaller | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| bool tarch::la::allSmallerEquals | ( | const Vector< Size, int > & | lhs, |
| const int & | cmp ) |
| bool tarch::la::allSmallerEquals | ( | const Vector< Size, Scalar > & | lhs, |
| const Scalar & | cmp, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| bool tarch::la::allSmallerEquals | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| int tarch::la::aPowI | ( | int | i, |
| int | a ) |
Computes the i-th power of a in integer arithmetic.
| Scalar tarch::la::average | ( | const Vector< Size, Scalar > & | vector | ) |
Computes the volume of the tetrahedron spanned by the Cartesian unit vectors scaled by the corresponding components of the given vector.
| void tarch::la::backSubstitution | ( | const DynamicMatrix & | R, |
| const double * | f, | ||
| double * | x ) |
| Vector< Rows, Scalar > tarch::la::backSubstitution | ( | const Matrix< Rows, Rows, Scalar > & | R, |
| const Vector< Rows, Scalar > & | f ) |
Back substitution following LU decomposition.
Accepts an upper triangular matrix and a rhs. It then returns the solution x to \( Rx=f \) i.e. \( x=R^{-1}f \). We assume that R is a proper, non-normalised upper triangular matrix. It does not have to have 1s on the diagonals.
| R | the upper matrix from the LU decomposition |
| Matrix< Rows, Cols, Scalar > tarch::la::buildMatrix | ( | const Scalar * | values | ) |
Deep copy builder function.
Become friend of builder mechanism.
We faced issues with some compiler versions with offering a constructor that simply takes a pointer to scalars. Further to that, it is not clear if such a constructor would create a deep copy or a shallow copy. Therefore, I decided to introduce an explicit builder function.
| Vector< Rows, Scalar > tarch::la::col | ( | const Matrix< Rows, Cols, Scalar > & | matrix, |
| int | whichColumn ) |
Extract row from matrix.
Referenced by tarch::la::DynamicMatrix::operator==(), tarch::la::DynamicMatrix::serialise(), and tarch::la::DynamicMatrix::serialise().

| bool tarch::la::contains | ( | const Vector< Size, Scalar > & | vector, |
| const Scalar & | value ) |
| double tarch::la::convertAbsoluteIntoRelativeValue | ( | double | referenceValue, |
| double | value ) |
Convert an absolute value into a relative one.
That is if the referenceValue is smaller than one, then we do nothing. Otherwise, we divide the absolute value by the reference value.
| tarch::la::SmartPointerVector< Size, NewScalarType > tarch::la::convertScalar | ( | const tarch::la::SmartPointerVector< Size, Scalar > & | SmartPointerVector | ) |
| tarch::la::Vector< Size, NewScalarType > tarch::la::convertScalar | ( | const tarch::la::Vector< Size, Scalar > & | vector | ) |
Convert the scalar type underlying a vector.
This routine takes a vector of size Size over type Scalar and returns a new vector of the same size but with type NewScalarType. A typical usage looks similar to
The conversion assumes that C++ natively supports a conversion from Scalar to NewScalarType. We do not employ any explicit typecasting under the hood.
| int tarch::la::count | ( | const Vector< Size, Scalar > & | vector, |
| const Scalar & | value ) |
| int tarch::la::countEqualEntries | ( | const Vector< Size, int > & | lhs, |
| const Vector< Size, int > & | rhs ) |
Run through both vectors and count how many entries are the same.
| int tarch::la::countEqualEntries | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| Vector< 3, Scalar > tarch::la::cross | ( | const Vector< 3, Scalar > & | lhs, |
| const Vector< 3, Scalar > & | rhs ) |
Performs the cross product of two 3D vectors into result.
| double tarch::la::det | ( | const Matrix< 2, 2, Scalar > & | R | ) |
| double tarch::la::det | ( | const Matrix< 3, 3, Scalar > & | R | ) |
| Vector< Rows, Scalar > tarch::la::diag | ( | const Matrix< Rows, Rows, Scalar > & | matrix | ) |
Extract diagonal vector from matrix.
| Scalar tarch::la::dot | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Performs the dot (=inner) product of two vectors.
For the outer dot product consult the file MatrixVectorOperations.h.
| Scalar tarch::la::elementMax | ( | const Matrix< Rows, Cols, Scalar > & | matrix | ) |
Max norm.
| bool tarch::la::equals | ( | const Matrix< Rows, Cols, Scalar > & | lhs, |
| const Matrix< Rows, Cols, Scalar > & | rhs, | ||
| const Scalar & | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Compares to matrices on equality by means of a numerical accuracy.
Referenced by Numerics::computeAbsA(), Refinement::StaticAMR< Shortcuts >::eval(), Numerics::hllem(), ContextCurvilinear< Shortcuts, basisSize >::initUnknownsPatch(), Context< Shortcuts, basisSize >::initUnknownsPointwise(), tarch::la::DynamicMatrix::operator==(), exahype2::removeTimeStepAccumulationErrorsFromCell(), and exahype2::runTimeStepOnCell().

| bool tarch::la::equals | ( | const std::complex< double > & | lhs, |
| const std::complex< double > & | rhs, | ||
| double | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| tolerance | Absolute tolerance when we compare two values. |
| bool tarch::la::equals | ( | const Vector< Size, int > & | lhs, |
| const int & | cmp ) |
Specialisation for int.
| bool tarch::la::equals | ( | const Vector< Size, Scalar > & | lhs, |
| const Scalar & | cmp, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
!!! Vectorisation remark
The Intel compiler refuses to vectorise these code fragments if they exit early. As a consequence, we have to remove early exit instructions though they might be faster for very long vectors. In Peano, vectors typically are pretty short and thus we have no early exit condition if you use the Intel compiler.
| bool tarch::la::equals | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Compares to vectors on equality by means of a numerical accuracy.
| tolerance | Absolute tolerance. If you prefer to use a relative measure, you might want to use tarch::la::relativeEps() |
| bool tarch::la::equals | ( | double | lhs, |
| double | rhs, | ||
| double | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| tolerance | Absolute tolerance when we compare two values. |
| std::pair< int, int > tarch::la::equalsReturnIndex | ( | const Matrix< Rows, Cols, Scalar > & | lhs, |
| const Matrix< Rows, Cols, Scalar > & | rhs, | ||
| const Scalar & | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Return Index of element which is not equals.
| int tarch::la::equalsReturnIndex | ( | const Vector< Size, int > & | lhs, |
| const Vector< Size, int > & | rhs ) |
| int tarch::la::equalsReturnIndex | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Return Index of element which is not equals.
| Vector< SizeLhs, Scalar > tarch::la::expandOrSlice | ( | const Scalar & | scalar | ) |
Delegates to slice().
| Vector< SizeLhs, Scalar > tarch::la::expandOrSlice | ( | const Vector< SizeRhs, Scalar > & | vector | ) |
Take a scalar or vector and map it onto a vector.
expandOrSlice() is a variant of the slice() operation that I need within for loops, e.g.. It is either given a scalar or a vector with N' entries, and it delivers a vector with N entries. N<N'. That is, if we hand in a scalar, expandOrSlice() expands it into a proper vector. It maps expandOrSlide() onto the constructor with one scalar argument. If we pass in a vector, it slices, i.e. takes the first N entries of this vector to create a new one. The case distinction is realised via overloading.
This version here equals slice().
| bool tarch::la::firstGreater | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Compares sequentially every component pair of lVector and rVector, and stops as soon as one is greater than the other.
Defines an absolute pairwise ordering between (unequal) vectors.
| tolerance | Absolute tolerance. If you prefer to use a relative measure, you might want to use tarch::la::relativeEps() |
Referenced by tarch::la::VectorCompare< N >::operator()().

| Scalar tarch::la::frobeniusNorm | ( | const Matrix< Rows, Cols, Scalar > & | matrix | ) |
| bool tarch::la::greater | ( | double | lhs, |
| double | rhs, | ||
| double | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| tolerance | Absolute tolerance when we compare two values. |
Definition at line 46 of file ScalarOperations.h.
Referenced by exahype2::getMinTimeStampOfNeighboursAhead().

| bool tarch::la::greaterEquals | ( | double | lhs, |
| double | rhs, | ||
| double | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| tolerance | Absolute tolerance when we compare two values. |
Referenced by exahype2::removeTimeStepAccumulationErrorsFromCell(), and exahype2::runTimeStepOnCell().

|
static |
Returns the identity matrix.
| Vector< Size, double > tarch::la::imag | ( | const Vector< Size, std::complex< double > > & | vector | ) |
| int tarch::la::indexMax | ( | const Vector< Size, Scalar > & | vector | ) |
Returns the index of the element with maximal value (NOT absolute value).
| int tarch::la::indexMin | ( | const Vector< Size, Scalar > & | vector | ) |
Returns the index of the element with minimal value (NOT absolute value).
| Scalar tarch::la::innerDot | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Performs the dot (=inner) product of two vectors.
For the outer dot product consult the file MatrixVectorOperations.h.
| Matrix< 2, 2, Scalar > tarch::la::invert | ( | const Matrix< 2, 2, Scalar > & | M | ) |
Specialisation of inversion.
This one inverts directly and is usually faster than BLAS.
| Matrix< 3, 3, Scalar > tarch::la::invert | ( | const Matrix< 3, 3, Scalar > & | M | ) |
Specialisation of inversion.
This one inverts directly and is usually faster than BLAS.
| Matrix< Rows, Rows, Scalar > tarch::la::invert | ( | const Matrix< Rows, Rows, Scalar > & | M | ) |
Invert matrix with LU decomposition.
We first invoke the LU decomposition through a call to lu(). After that, we compute the mat vec and return the result. This is not an optimised version in any way. For small matrices, it should be pretty fast. For larger matrices, you might want to consider the Lapack version available through the alternative invert() version.
| Matrix< Rows, Cols, Scalar > tarch::la::invertEntries | ( | const Matrix< Rows, Cols, Scalar > & | matrix | ) |
Inverts each individual entry.
Works if and only if the matrix does not contain any zeroes, as this routine yields
\( A_{ij} \gets A_{ij}^{-1} \)
which is not \( A^{-1} \). If you want to have the inverse, you have to look, for example, into LUDecomposition.
| Vector< Size, Scalar > tarch::la::invertEntries | ( | const Vector< Size, Scalar > & | vector | ) |
| DynamicMatrix tarch::la::invertUpperTriangular | ( | const DynamicMatrix & | R | ) |
| int tarch::la::isEntryFinite | ( | const Vector< Size, Scalar > & | vector | ) |
| int tarch::la::isEntryNan | ( | const Vector< Size, Scalar > & | vector | ) |
| void tarch::la::lu | ( | Matrix< Rows, Rows, Scalar > & | A | ) |
In-situ LU without pivoting.
See the other LU routine.
| void tarch::la::lu | ( | Matrix< Rows, Rows, Scalar > & | A, |
| Vector< Rows, int > & | pivots ) |
Performs an in-situ LU-decomposition of the square matrix A.
Returns pivot values, too. The storage format is normalised such that the diagonal values of the lower triangular matrix are one.
| void tarch::la::matVec | ( | const Matrix< Rows, Cols, Scalar > & | matrix, |
| Scalar | alpha, | ||
| const Vector< Cols, Scalar > & | v, | ||
| Vector< Rows, Scalar > & | r ) |
Compute r = r + alpha * M * v in-situ.
| Vector< Size, Scalar > tarch::la::max | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Component-wise max evaluation.
| Scalar tarch::la::max | ( | const Vector< Size, Scalar > & | vector | ) |
Returns the element with maximal value (NOT absolute value).
| double tarch::la::max | ( | double | a, |
| double | b, | ||
| double | c ) |
I need the maximum of three values all the time, to I decided to write a function for this.
| Scalar tarch::la::maxAbs | ( | const Vector< Size, Scalar > & | vector | ) |
Returns the element with maximal absolute value.
| double tarch::la::maxImag | ( | const Vector< Size, std::complex< double > > & | vector | ) |
| double tarch::la::maxReal | ( | const Vector< Size, std::complex< double > > & | vector | ) |
| Vector< Size, Scalar > tarch::la::min | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Component-wise min evaluation.
| Scalar tarch::la::min | ( | const Vector< Size, Scalar > & | vector | ) |
Returns the element with minimal value (NOT absolute value).
Referenced by swift2::kernels::legacy::updateSmoothingLengthAndRerunIfRequired().

| void tarch::la::modifiedGramSchmidt | ( | DynamicMatrix | A, |
| DynamicMatrix & | Q, | ||
| DynamicMatrix & | R ) |
| void tarch::la::modifiedGramSchmidt | ( | Matrix< Rows, Cols, Scalar > | A, |
| Matrix< Rows, Cols, Scalar > & | Q, | ||
| Matrix< Cols, Cols, Scalar > & | R ) |
Produces an economy-size QR decomposition of a matrix A, A is changed.
Preconditions:
Postconditions:
The algorithm is taken from the book Numerical Mathematics, Second Edition, by Alfio Querteroni, Riccardo Sacco, and Fausto Saleri, Springer, 2007, pages 85-87.
Classic usage:
modifiedGramSchmidt(M, Q, R); tarch::la::Vector<9, double> p = tarch::la::backSubstitution(R,tarch::la::transpose(Q)*f);
| Vector< Rows, Scalar > tarch::la::multiply | ( | const Matrix< Rows, Cols, Scalar > & | matrix, |
| const Vector< Cols, Scalar > & | vector ) |
Performs a matrix x vector multiplication.
The result vector has to be created outside and given as a parameter.
| Matrix< Rows, Cols, Scalar > tarch::la::multiply | ( | const Matrix< Rows, X, Scalar > & | lhs, |
| const Matrix< X, Cols, Scalar > & | rhs ) |
Performs a matrix x matrix multiplication.
The resulting matrix has to be created outside and given as a parameter.
| Vector< Rows, Scalar > tarch::la::multiply | ( | const ShallowMatrix< Rows, Cols, Scalar > & | matrix, |
| const SmartPointerVector< Cols, Scalar > & | vector ) |
| Vector< Rows, Scalar > tarch::la::multiply | ( | const ShallowMatrix< Rows, Cols, Scalar > & | matrix, |
| const Vector< Cols, Scalar > & | vector ) |
Performs a matrix x vector multiplication.
The result vector has to be created outside and given as a parameter.
| Matrix< Rows, Cols, Scalar > tarch::la::multiplyComponents | ( | const Matrix< Rows, X, Scalar > & | lhs, |
| const Matrix< X, Cols, Scalar > & | rhs ) |
| Vector< Size, Scalar > tarch::la::multiplyComponents | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Multiplies every component of the vectors with each other and writes the results into result.
| Scalar tarch::la::norm1 | ( | const Vector< Size, Scalar > & | vector | ) |
Computes the 1-norm of the vector, i.e.
it sums up abs. component values.
| double tarch::la::norm1 | ( | const Vector< Size, std::complex< double > > & | vector | ) |
Specialisation that is different to standard definition.
Works as result type is not part of the signature
| Scalar tarch::la::norm2 | ( | const Vector< Size, Scalar > & | vector | ) |
Computes the 2-norm of the vector, i.e.
it takes the square-root of summed up squared component values.
| double tarch::la::norm2 | ( | const Vector< Size, std::complex< double > > & | vector | ) |
Specialisation that is different to standard definition.
Works as result type is not part of the signature
| Scalar tarch::la::norm2Squared | ( | const Vector< Size, Scalar > & | vector | ) |
| double tarch::la::norm2Squared | ( | const Vector< Size, std::complex< double > > & | vector | ) |
| Scalar tarch::la::normMax | ( | const Vector< Size, Scalar > & | vector | ) |
Computes the max-norm of the vector.
| double tarch::la::normMax | ( | const Vector< Size, std::complex< double > > & | vector | ) |
Specialisation that is different to standard definition.
Works as result type is not part of the signature
| bool tarch::la::oneEquals | ( | const Vector< Size, int > & | lhs, |
| const int & | cmp ) |
| bool tarch::la::oneEquals | ( | const Vector< Size, Scalar > & | lhs, |
| const Scalar & | cmp, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| bool tarch::la::oneGreater | ( | const Vector< Size, int > & | lhs, |
| const int & | cmp ) |
| bool tarch::la::oneGreater | ( | const Vector< Size, Scalar > & | lhs, |
| const Scalar & | cmp, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| bool tarch::la::oneGreater | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Returns true, if one component of lVector is greater than the corresponding component in rVector up to numerical accuracy.
| tolerance | Absolute tolerance. If you prefer to use a relative measure, you might want to use tarch::la::relativeEps() |
| bool tarch::la::oneGreaterEquals | ( | const Vector< Size, int > & | lhs, |
| const int & | cmp ) |
| bool tarch::la::oneGreaterEquals | ( | const Vector< Size, Scalar > & | lhs, |
| const Scalar & | cmp, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| bool tarch::la::oneGreaterEquals | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Returns true, if one component of lVector is greater or equals than the corresponding component in rVector up to numerical accuracy.
| bool tarch::la::oneSmaller | ( | const Vector< Size, int > & | lhs, |
| const int & | cmp ) |
| bool tarch::la::oneSmaller | ( | const Vector< Size, Scalar > & | lhs, |
| const Scalar & | cmp, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| bool tarch::la::oneSmaller | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| bool tarch::la::oneSmallerEquals | ( | const Vector< Size, int > & | lhs, |
| const int & | cmp ) |
| bool tarch::la::oneSmallerEquals | ( | const Vector< Size, Scalar > & | lhs, |
| const Scalar & | cmp, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| bool tarch::la::oneSmallerEquals | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs, | ||
| const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| bool tarch::la::operator!= | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Bit-wise comparison of the components of two vectors for inequality.
This method should not be used for floating-point valued vectors. Instead, !equals() is the suitable comparison.
| Matrix< Rows, Cols, std::complex< double > > tarch::la::operator* | ( | const double & | scalar, |
| const Matrix< Rows, Cols, std::complex< double > > & | matrix ) |
| Matrix< Rows, Cols, Scalar > tarch::la::operator* | ( | const Matrix< Rows, Cols, Scalar > & | matrix, |
| const Scalar & | scalar ) |
Multiplies every component of the matrix with the scalar.
No temporary objects are created during the operation.
| Vector< Rows, Scalar > tarch::la::operator* | ( | const Matrix< Rows, Cols, Scalar > & | matrix, |
| const Vector< Cols, Scalar > & | vector ) |
Performs a matrix x vector multiplication.
The result vector is created inside, multiply is used to execute the multiplication.
| Matrix< Rows, Cols, Scalar > tarch::la::operator* | ( | const Matrix< Rows, X, Scalar > & | lhs, |
| const Matrix< X, Cols, Scalar > & | rhs ) |
| Matrix< Rows, Cols, Scalar > tarch::la::operator* | ( | const Scalar & | scalar, |
| const Matrix< Rows, Cols, Scalar > & | matrix ) |
Multiplies every component of the matrix with the scalar.
No temporary objects are created during the operation.
| Vector< Size, Scalar > tarch::la::operator* | ( | const Scalar & | scalar, |
| const Vector< Size, Scalar > & | vector ) |
| Scalar tarch::la::operator* | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Performs the dot (=inner) product of two vectors.
For the outer dot product consult the file MatrixVectorOperations.h.
| Vector< Size, Scalar > tarch::la::operator* | ( | const Vector< Size, Scalar > & | vector, |
| const Scalar & | scalar ) |
Multiplies every component of the vector with the scalar and returns the result.
A temporary vector is created during the operation and copied as result.
| Matrix< Rows, Cols, Scalar > & tarch::la::operator*= | ( | Matrix< Rows, Cols, Scalar > & | matrix, |
| const Scalar & | scalar ) |
| Vector< Size, Scalar > & tarch::la::operator*= | ( | Vector< Size, Scalar > & | vector, |
| const Scalar & | scalar ) |
Multiplies every component of the vector with the scalar and assigns the result to the vector.
No temporary objects are created during the operation.
| Matrix< Rows, Cols, Scalar > tarch::la::operator+ | ( | const Matrix< Rows, Cols, Scalar > & | lhs, |
| const Matrix< Rows, Cols, Scalar > & | rhs ) |
| Vector< Size, Scalar > tarch::la::operator+ | ( | const Scalar & | scalar, |
| const Vector< Size, Scalar > & | vector ) |
| Vector< Size, Scalar > tarch::la::operator+ | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Adds rVector to lVector.
A temporary vector is created and copied to store return back the result.
| Vector< Size, Scalar > tarch::la::operator+ | ( | const Vector< Size, Scalar > & | vector, |
| const Scalar & | scalar ) |
Adds the scalar to every component of the vector and returns the result.
A temporary vector is created during the operation and copied as result.
| Vector< Size, Scalar > & tarch::la::operator+= | ( | Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Adds rVector to lVector and assigns the result to lVector.
No temporary vector is created.
| Vector< Size, Scalar > & tarch::la::operator+= | ( | Vector< Size, Scalar > & | vector, |
| const Scalar & | scalar ) |
Adds every component of the vector to the scalar and assigns the result to the vector.
No temporary objects are created during the operation.
| Matrix< Rows, Cols, Scalar > tarch::la::operator- | ( | const Matrix< Rows, Cols, Scalar > & | lhs, |
| const Matrix< Rows, Cols, Scalar > & | rhs ) |
| Vector< Size, Scalar > tarch::la::operator- | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Subtracts rVector from lVector.
A temporary vector is created and copied to store return back the result.
| Vector< Size, Scalar > tarch::la::operator- | ( | const Vector< Size, Scalar > & | vector, |
| const Scalar & | scalar ) |
Subtracts the scalar from every component of the vector and returns the result.
A temporary vector is created during the operation and copied as result.
| Vector< Size, Scalar > & tarch::la::operator-= | ( | Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Subtracts rVector from lVector and assigns the result to lVector.
No temporary vector is created.
| Vector< Size, Scalar > & tarch::la::operator-= | ( | Vector< Size, Scalar > & | vector, |
| const Scalar & | scalar ) |
Subtracts the scalar from every component of the vector and assigns the result to the vector.
No temporary objects are created during the operation.
| Vector< Size, Scalar > tarch::la::operator/ | ( | const Vector< Size, Scalar > & | vector, |
| const Scalar & | scalar ) |
Divides every component of the vector by the scalar and returns the result.
A temporary vector is created during the operation and copied as result.
| Vector< Size, Scalar > & tarch::la::operator/= | ( | Vector< Size, Scalar > & | vector, |
| const Scalar & | scalar ) |
Divides every component of the vector by the scalar and assigns the result to the vector.
No temporary objects are created during the operation.
| bool tarch::la::operator== | ( | const Matrix< Rows, Cols, Scalar > & | lhs, |
| const Matrix< Rows, Cols, Scalar > & | rhs ) |
Bitwise comparison of the components of two matrices on equality.
| bool tarch::la::operator== | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Bit-wise comparison of the components of two vectors for equality.
This method should not be used for floating-point valued vectors. Instead, equals() is the suitable comparison.
| Matrix< Size, Size, Scalar > tarch::la::outerDot | ( | const Vector< Size, Scalar > & | lhs, |
| const Vector< Size, Scalar > & | rhs ) |
Outer dot product.
| double tarch::la::pow | ( | double | base, |
| double | exponent ) |
Wrapper around std::pow which is redirected to Intel's implementation on Intel machines.
| Vector< Size, double > tarch::la::real | ( | const Vector< Size, std::complex< double > > & | vector | ) |
| double tarch::la::relativeEps | ( | double | valueA, |
| double | valueB = std::numeric_limits< double >::min(), | ||
| double | eps = NUMERICAL_ZERO_DIFFERENCE ) |
Determine a relative tolerance from one or two values.
This routine takes eps and scales it with the maximum of the absolute values of the arguments.
The version with two arguments can be seen as wrapper around a 'scalar' relativeEps() variant which forwards the bigger value. This is very often used in combination with the greater and smaller macros, where you wanna compare prescribing a comparison tolerance.
If you have only one argument, set valueB=valueA.
| double tarch::la::relativeEpsNormalisedAgainstValueGreaterOne | ( | double | valueA, |
| double | valueB = std::numeric_limits< double >::min(), | ||
| double | eps = NUMERICAL_ZERO_DIFFERENCE ) |
Determine a relative tolerance from one or two values.
This routine equals relativeEps, but if the normalisation quantities become smaller than 1.0, then we pick eps instead of eps times this value smaller than 1.0. So basically the normalisation with valueA (and valueB) kicks in iff the bigger value of the two is bigger than 1.0.
| Vector< Size, Scalar > tarch::la::remainder | ( | const Vector< Size, Scalar > & | vector, |
| double | h ) |
Return the remainder of a division.
Per component x_i, the function computes x_i/h and then returns the remaining fraction of x_i which did not fit into h. The function therefore resembles modulo.
| int tarch::la::round | ( | double | value | ) |
| int tarch::la::round | ( | float | value | ) |
| Vector< Cols, Scalar > tarch::la::row | ( | const Matrix< Rows, Cols, Scalar > & | matrix, |
| int | whichRow ) |
Extract row from matrix.
Referenced by tarch::la::DynamicMatrix::operator==(), tarch::la::DynamicMatrix::serialise(), and tarch::la::DynamicMatrix::serialise().

| int tarch::la::sign | ( | double | value, |
| double | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| Vector< SizeLhs, Scalar > tarch::la::slice | ( | const Vector< SizeRhs, Scalar > & | vector, |
| int | fromIndex, | ||
| int | stride = 1 ) |
Returns subpart of the vector.
The name is due to historical reasons and compability with Bernhard Gatzhammer's PreCiSE code. But the implementation is extended such that one can also retrieve discontinuous parts of a vector.
!!! Examples
Take first 3 element from a vector:
Take the elements 2,3,5,6 from a vector:
| void tarch::la::slice | ( | Vector< SizeLhs, Scalar > & | toVector, |
| const Vector< SizeRhs, Scalar > & | fromVector, | ||
| int | fromIndexInToVector, | ||
| int | strideInToVector = 1 ) |
Setter.
|
static |
Smaller operator for floating point values.
This operation is a header-only operation on purpose, as we use it in some SPH compute kernels which we want to vectorise aggressively.
The static here is required to avoid multiple definition errors.
We originally had the signature
but that one gives a compiler warning:
It seems that the inlining flag has to be used prior to the result data type, if we also add the implementation to the header.
Further to that, we add maybe_unused, as the compiler otherwise warns about the inline function unused if no extension is enabled that uses it.
| tolerance | Absolute tolerance when we compare two values. |
Definition at line 90 of file ScalarOperations.h.
Referenced by exahype2::getMinTimeStampOfNeighboursAhead().

| bool tarch::la::smallerEquals | ( | double | lhs, |
| double | rhs, | ||
| double | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
| tolerance | Absolute tolerance when we compare two values. |
| Scalar tarch::la::sum | ( | const Matrix< Rows, Cols, Scalar > & | matrix | ) |
Computes the sum of all entries of the matrix.
| Scalar tarch::la::sum | ( | const Vector< Size, Scalar > & | vector | ) |
Sums up the component values of the vector.
| std::vector< Scalar > tarch::la::toSTLVector | ( | const Vector< Size, Scalar > & | vector | ) |
| DynamicMatrix tarch::la::transpose | ( | const DynamicMatrix & | matrix | ) |
| Matrix< Cols, Rows, Scalar > tarch::la::transpose | ( | const Matrix< Rows, Cols, Scalar > & | matrix | ) |
| Scalar tarch::la::volume | ( | const Vector< Size, Scalar > & | vector | ) |
Computes the volume of the tetrahedron spanned by the Cartesian unit vectors scaled by the corresponding components of the given vector.
|
constexpr |
|
constexpr |
Definition at line 17 of file Scalar.h.
Referenced by swift2::kernels::localParticleCanBeUpdatedInCellKernel(), swift2::kernels::localParticleCanBeUpdatedInCellKernelFromAnyOtherParticle(), swift2::kernels::localParticleCanBeUpdatedInCellKernelFromAnyOtherParticleWithinIterationRange(), swift2::markAllParticlesAsUpdatedWithinCell(), and exahype2::removeTimeStepAccumulationErrorsFromCell().