Peano
|
My collection of tiny vector operations. More...
Namespaces | |
namespace | tests |
Data Structures | |
class | CompressedFloat |
class | DynamicMatrix |
My standard matrix is a matrix where the size is fixed at compile time. More... | |
class | Matrix |
Static (i.e. 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, 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) |
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 > | |
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 | relativeEpsNormaledAgainstValueGreaterOne (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 bool | smaller (double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE) InlineMethod |
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<typename NewScalarType , int Size, typename Scalar > | |
tarch::la::Vector< Size, NewScalarType > | convertScalar (const tarch::la::Vector< Size, Scalar > &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.
Definition at line 9 of file ScalarOperations.cpp.
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
Returns the absolute value of a type by redirecting to std::abs.
Definition at line 13 of file ScalarOperations.cpp.
References std::abs().
Referenced by swift2::kernels::legacy::hydro_prepare_force(), norm1(), norm1(), toolbox::particles::assignmentchecks::internal::Database::shiftIdentifierCoordinates(), tarch::la::tests::ScalarTest::testAbs(), toolbox::particles::tests::MultiscaleTransitionsTest::testSievePredicate(), and tarch::la::Matrix< Rows, Cols, Scalar >::toPrettyString().
Returns the absolute value of the given int.
Definition at line 5 of file ScalarOperations.cpp.
bool tarch::la::allEntriesAreTheSame | ( | const Vector< Size, Scalar > & | vector | ) |
Definition at line 24 of file VectorOperations.cpph.
References equals().
Definition at line 429 of file VectorScalarOperations.cpph.
bool tarch::la::allGreater | ( | const Vector< Size, Scalar > & | lhs, |
const Scalar & | cmp, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 263 of file VectorScalarOperations.cpph.
References greater().
Referenced by toolbox::particles::assignmentchecks::tests::internal::dropParticle(), and tarch::la::tests::VectorTest::testVectorVectorOperations().
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() |
Definition at line 232 of file VectorVectorOperations.cpph.
References greater().
bool tarch::la::allGreaterEquals | ( | const Vector< Size, int > & | lhs, |
const int & | cmp ) |
Definition at line 450 of file VectorScalarOperations.cpph.
bool tarch::la::allGreaterEquals | ( | const Vector< Size, Scalar > & | lhs, |
const Scalar & | cmp, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 273 of file VectorScalarOperations.cpph.
References greaterEquals().
Referenced by peano4::grid::Spacetree::evaluateGridControlEvents(), toolbox::finiteelements::BSplinesStencilFactory::getElementWiseAssemblyMatrix(), toolbox::finiteelements::BSplinesStencilFactory::getElementWiseAssemblyMatrix(), peano4::grid::isContained(), peano4::grid::overlaps(), peano4::grid::overlaps(), and toolbox::particles::particleWillStayWithinComputationalDomain().
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.
Definition at line 246 of file VectorVectorOperations.cpph.
References greaterEquals().
Definition at line 471 of file VectorScalarOperations.cpph.
bool tarch::la::allSmaller | ( | const Vector< Size, Scalar > & | lhs, |
const Scalar & | cmp, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 283 of file VectorScalarOperations.cpph.
Referenced by toolbox::particles::assignmentchecks::tests::internal::dropParticle(), peano4::grid::Spacetree::evaluateGridControlEvents(), toolbox::finiteelements::BSplinesStencilFactory::getElementWiseAssemblyMatrix(), and toolbox::finiteelements::BSplinesStencilFactory::getElementWiseAssemblyMatrix().
bool tarch::la::allSmaller | ( | const Vector< Size, Scalar > & | lhs, |
const Vector< Size, Scalar > & | rhs, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 260 of file VectorVectorOperations.cpph.
bool tarch::la::allSmallerEquals | ( | const Vector< Size, int > & | lhs, |
const int & | cmp ) |
Definition at line 492 of file VectorScalarOperations.cpph.
bool tarch::la::allSmallerEquals | ( | const Vector< Size, Scalar > & | lhs, |
const Scalar & | cmp, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 293 of file VectorScalarOperations.cpph.
References smallerEquals().
Referenced by peano4::grid::isContained(), peano4::grid::overlaps(), peano4::grid::overlaps(), and toolbox::particles::particleWillStayWithinComputationalDomain().
bool tarch::la::allSmallerEquals | ( | const Vector< Size, Scalar > & | lhs, |
const Vector< Size, Scalar > & | rhs, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 274 of file VectorVectorOperations.cpph.
References smallerEquals().
Computes the i-th power of a in integer arithmetic.
Definition at line 17 of file ScalarOperations.cpp.
References a.
Referenced by convert::filter::ConvertTreeIdIntoDataField::apply(), convert::data::PatchData::copyData(), tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::CellDataWriter::getCellsPerPatch(), convert::data::Variable::getTotalNumberOfCellsInCartesianMesh(), convert::data::Variable::getTotalNumberOfDofsPerPatch(), convert::data::Variable::getTotalNumberOfVerticesInCartesianMesh(), tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter::getVerticesPerPatch(), and convert::data::PatchData::PatchData().
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.
Definition at line 160 of file VectorOperations.cpph.
void tarch::la::backSubstitution | ( | const DynamicMatrix & | R, |
const double * | f, | ||
double * | x ) |
Definition at line 4 of file LUDecompositionDynamic.cpp.
References f().
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 |
Referenced by invertUpperTriangular().
Vector< Rows, Scalar > tarch::la::col | ( | const Matrix< Rows, Cols, Scalar > & | matrix, |
int | whichColumn ) |
Extract row from matrix.
Referenced by tarch::la::DynamicMatrix::batchedMultiplyAoS(), elementMax(), frobeniusNorm(), tarch::la::DynamicMatrix::insertEmptyColumns(), tarch::la::DynamicMatrix::insertEmptyRows(), invertUpperTriangular(), tarch::la::DynamicMatrix::multiply(), tarch::la::DynamicMatrix::multiplyBySmallMatrix(), tarch::la::DynamicMatrix::operator()(), tarch::la::DynamicMatrix::operator()(), operator*(), tarch::la::DynamicMatrix::operator==(), tarch::la::DynamicMatrix::operator==(), tarch::la::DynamicMatrix::removeColumn(), tarch::la::DynamicMatrix::replicateRows(), tarch::la::DynamicMatrix::scale(), tarch::la::DynamicMatrix::serialise(), tarch::la::DynamicMatrix::serialise(), tarch::la::DynamicMatrix::shiftColumnsRight(), tarch::la::DynamicMatrix::shiftRowsDown(), and tarch::la::DynamicMatrix::toString().
bool tarch::la::contains | ( | const Vector< Size, Scalar > & | vector, |
const Scalar & | value ) |
Definition at line 51 of file VectorOperations.cpph.
Referenced by peano4::grid::GridTraversalEventGenerator::createEnterCellTraversalEvent(), peano4::grid::Spacetree::isCellSplitCandidate(), peano4::grid::Spacetree::mergeGridVertexRefinementStateAtHorizontalDomainBoundary(), peano4::grid::Spacetree::receiveAndMergeGridVertexAtVerticalBoundary(), peano4::grid::Spacetree::sendUserData(), and peano4::grid::Spacetree::shouldEraseAdjacencyInformation().
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.
Definition at line 26 of file Scalar.cpp.
References std::abs().
tarch::la::Vector< Size, NewScalarType > tarch::la::convertScalar | ( | const tarch::la::Vector< Size, Scalar > & | vector | ) |
Definition at line 94 of file Vector.cpph.
Referenced by toolbox::blockstructured::interpolateCellDataAssociatedToVolumesIntoOverlappingCell_secondOrder(), and toolbox::blockstructured::internal::projectCells_AoS().
int tarch::la::count | ( | const Vector< Size, Scalar > & | vector, |
const Scalar & | value ) |
Definition at line 13 of file VectorOperations.cpph.
References equals().
Referenced by exahype2::fv::plotPatch().
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.
Definition at line 366 of file VectorVectorOperations.cpph.
Referenced by peano4::grid::Spacetree::mergeGridVertexRefinementStateAtHorizontalDomainBoundary().
int tarch::la::countEqualEntries | ( | const Vector< Size, Scalar > & | lhs, |
const Vector< Size, Scalar > & | rhs, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 381 of file VectorVectorOperations.cpph.
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.
Referenced by tarch::la::tests::VectorTest::testVectorVectorOperations().
Definition at line 75 of file LUDecomposition.cpph.
Definition at line 157 of file LUDecomposition.cpph.
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.
Definition at line 145 of file VectorVectorOperations.cpph.
References innerDot().
Referenced by swift2::kernels::legacy::density_kernel(), swift2::kernels::legacy::force_kernel(), swift2::kernels::legacy::forceKernelWithMasking(), and tarch::la::tests::VectorTest::testVectorVectorOperations().
Scalar tarch::la::elementMax | ( | const Matrix< Rows, Cols, Scalar > & | matrix | ) |
Max norm.
Definition at line 29 of file MatrixOperations.cpph.
References std::abs(), col(), and row().
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.
Definition at line 100 of file MatrixMatrixOperations.cpph.
Referenced by examples::exahype2::gprdr::GPRDR::adjustSolution(), examples::exahype2::mgccz4::FiniteVolumeMGCCZ4::adjustSolution(), examples::exahype2::ccz4::ADERDGCCZ4::adjustSolution(), examples::exahype2::mgccz4::ADERDGMGCCZ4::adjustSolution(), allEntriesAreTheSame(), tarch::plotter::PVDTimeSeriesWriter::appendNewData(), swift2::boundaryconditions::applyFixedBoundaryCondition(), exahype2::fd::applySommerfeldConditions(), toolbox::loadbalancing::AbstractLoadBalancing::areRanksUnemployed(), Numerics::computeAbsA(), swift2::timestepping::computeAdmissibleTimeStepSizeFromGlobalMeshSizeAndMaximumVelocity(), count(), toolbox::particles::createParticlesAlignedWithGlobalCartesianMesh(), peano4::grid::internal::equals(), Refinement::StaticAMR< Shortcuts >::eval(), applications::exahype2::euler::sphericalaccretion::MassAccumulator::finishAccumulation(), toolbox::particles::TrajectoryDatabase::getAction(), toolbox::particles::TrajectoryDatabase::getAction(), toolbox::blockstructured::GlobalDatabase::getAction(), toolbox::finiteelements::getElementWiseAssemblyMatrix(), applications::exahype2::euler::sphericalaccretion::SSInfall::getForceDensityNorm(), exahype2::getInterpolationWeights(), Numerics::hllem(), benchmarks::swift2::hydro::kernel_throughput::initNohProblemIC(), ContextCurvilinear< Shortcuts, basisSize >::initUnknownsPatch(), Context< Shortcuts, basisSize >::initUnknownsPointwise(), peano4::grid::Spacetree::mergeGridVertexRefinementStateAtHorizontalDomainBoundary(), toolbox::particles::mirrorParticleAlongPeriodicDomains(), toolbox::particles::assignmentchecks::internal::ParticleIdentifier::numericalEquals(), tarch::la::DynamicMatrix::operator==(), tarch::la::DynamicMatrix::operator==(), tarch::plotter::PVDTimeSeriesWriter::parseFile(), toolbox::particles::particleIsDuplicate(), tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::CellDataWriter::plotCell(), tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::CellDataWriter::plotCell(), tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter::plotVertex(), tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter::plotVertex(), applications::exahype2::ccz4::CCZ4::refinementCriterion(), applications::exahype2::ccz4::FiniteVolumeCCZ4::refinementCriterion(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFD4::refinementCriterion(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFV::refinementCriterion(), applications::exahype2::elastic::elastic::refinementCriterion(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallDG::refinementCriterion(), exahype2::removeTimeStepAccumulationErrorsFromCell(), exahype2::runTimeStepOnCell(), convert::data::PatchData::samePatch(), applications::exahype2::euler::sphericalaccretion::SSInfall::sourceTerm(), applications::exahype2::euler::sphericalaccretion::SSInfall::startTimeStep(), mghype::matrixfree::solvers::Solver::terminationCriterionHolds(), tarch::la::tests::ScalarTest::testComparison(), peano4::grid::tests::GridControlEventTest::testMerge1(), tarch::la::tests::GramSchmidtTest::testModifiedGramSchmidt(), tarch::la::tests::VectorTest::testVectorVectorOperations(), peano4::grid::internal::twoEventsAreAdjacent(), and validateOutcome().
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. |
Definition at line 68 of file ScalarOperations.cpp.
References std::abs().
Specialisation for int.
Definition at line 303 of file VectorScalarOperations.cpph.
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.
Definition at line 137 of file VectorScalarOperations.cpph.
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() |
Definition at line 169 of file VectorVectorOperations.cpph.
bool tarch::la::equals | ( | double | lhs, |
double | rhs, | ||
double | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
tolerance | Absolute tolerance when we compare two values. |
Definition at line 60 of file ScalarOperations.cpp.
References std::abs().
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.
Definition at line 153 of file MatrixMatrixOperations.cpph.
References std::abs().
Referenced by tarch::la::tests::MatrixTest::testMatrixMatrixOperations(), and tarch::la::tests::VectorTest::testVectorVectorOperations().
int tarch::la::equalsReturnIndex | ( | const Vector< Size, int > & | lhs, |
const Vector< Size, int > & | rhs ) |
Definition at line 354 of file VectorVectorOperations.cpph.
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.
Definition at line 341 of file VectorVectorOperations.cpph.
References std::abs().
Vector< SizeLhs, Scalar > tarch::la::expandOrSlice | ( | const Scalar & | scalar | ) |
Delegates to slice().
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() |
Definition at line 184 of file VectorVectorOperations.cpph.
Referenced by tarch::la::VectorCompare< N >::operator()(), and tarch::la::tests::VectorTest::testVectorVectorOperations().
Scalar tarch::la::frobeniusNorm | ( | const Matrix< Rows, Cols, Scalar > & | matrix | ) |
Definition at line 14 of file MatrixOperations.cpph.
Referenced by examples::regulargridupscaling::MyObserver::enterCell().
bool tarch::la::greater | ( | double | lhs, |
double | rhs, | ||
double | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
tolerance | Absolute tolerance when we compare two values. |
Definition at line 25 of file ScalarOperations.cpp.
Referenced by applications::exahype2::euler::sphericalaccretion::addGravitationalSource_AlphaCDM(), allGreater(), allGreater(), toolbox::particles::applyPeriodicBoundaryConditions(), swift2::kernels::gravity::computeGravitationalForce(), toolbox::particles::createParticlesAlignedWithGlobalCartesianMesh(), swift2::kernels::legacy::densityKernelPairEvaluationPredicate(), exahype2::discretiseAndTruncateTimeStepSizes(), toolbox::blockstructured::GlobalDatabase::dumpDatabaseSnapshot(), toolbox::particles::TrajectoryDatabase::dumpDatabaseSnapshot(), swift2::kernels::legacy::force_kernel(), swift2::kernels::legacy::forceKernelWithMasking(), applications::exahype2::swe::fwave(), exahype2::getMinTimeStampOfNeighboursAhead(), applications::exahype2::euler::sphericalaccretion::SSInfall::mass_interpolate(), convert::data::PatchData::overlaps(), applications::exahype2::euler::sphericalaccretion::SSInfall::patchCanUseStatelessPDETerms(), applications::exahype2::swe::rusanov(), applications::exahype2::swe::TopologyParser::sampleBathymetry(), applications::exahype2::swe::TopologyParser::sampleDisplacement(), sign(), peano4::grid::internal::sort(), and tarch::la::tests::ScalarTest::testComparison().
bool tarch::la::greaterEquals | ( | double | lhs, |
double | rhs, | ||
double | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
tolerance | Absolute tolerance when we compare two values. |
Definition at line 33 of file ScalarOperations.cpp.
Referenced by allGreaterEquals(), allGreaterEquals(), toolbox::particles::internal::fitsIntoLevel(), toolbox::particles::internal::fitsIntoLevel(), toolbox::loadbalancing::AbstractLoadBalancing::getIdOfHeaviestLocalSpacetree(), exahype2::getInterpolationWeights(), applications::exahype2::euler::sphericalaccretion::MassAccumulator::getMass_linearInterpolation(), toolbox::particles::internal::getParticleAssociationWithinCell(), toolbox::particles::FileReader::getParticlesWithinVoxel(), toolbox::particles::FileReaderHDF5::getParticlesWithinVoxel(), swift2::boundaryconditions::getUpdateDueToFixedBoundaryCondition(), toolbox::particles::insertParticleIntoCell(), toolbox::blockstructured::interpolateCellDataAssociatedToVolumesIntoOverlappingCell_linear(), peano4::datamanagement::CellMarker::isContained(), peano4::datamanagement::CellMarker::overlaps(), exahype2::removeTimeStepAccumulationErrorsFromCell(), exahype2::runTimeStepOnCell(), and tarch::la::tests::ScalarTest::testComparison().
|
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).
Definition at line 183 of file VectorOperations.cpph.
References indexMax().
Referenced by indexMax(), and tarch::la::tests::VectorTest::testVectorOperations().
int tarch::la::indexMin | ( | const Vector< Size, Scalar > & | vector | ) |
Returns the index of the element with minimal value (NOT absolute value).
Definition at line 192 of file VectorOperations.cpph.
References indexMin().
Referenced by indexMin(), and tarch::la::tests::VectorTest::testVectorOperations().
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.
Definition at line 132 of file VectorVectorOperations.cpph.
Referenced by dot(), and operator*().
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 without
Referenced by tarch::la::tests::LUDecompositionTest::testInversion0(), and tarch::la::tests::LUDecompositionTest::testInversion1().
Matrix< Rows, Cols, Scalar > tarch::la::invertEntries | ( | const Matrix< Rows, Cols, Scalar > & | matrix | ) |
Vector< Size, Scalar > tarch::la::invertEntries | ( | const Vector< Size, Scalar > & | vector | ) |
tarch::la::DynamicMatrix tarch::la::invertUpperTriangular | ( | const DynamicMatrix & | R | ) |
Definition at line 19 of file LUDecompositionDynamic.cpp.
References backSubstitution(), and col().
Referenced by toolbox::blockstructured::interpolateCellDataAssociatedToVolumesIntoOverlappingCell_secondOrder().
int tarch::la::isEntryFinite | ( | const Vector< Size, Scalar > & | vector | ) |
Definition at line 42 of file VectorOperations.cpph.
Referenced by swift2::kernels::legacy::leapfrog_drift_global_time_step_size(), and swift2::timestepping::leapfrogDriftWithGlobalTimeStepSize().
int tarch::la::isEntryNan | ( | const Vector< Size, Scalar > & | vector | ) |
Definition at line 33 of file VectorOperations.cpph.
Referenced by swift2::kernels::legacy::force_kernel(), and swift2::kernels::legacy::forceKernelWithMasking().
In-situ LU without pivoting.
See the other LU routine.
Definition at line 57 of file LUDecomposition.cpph.
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.
Definition at line 21 of file LUDecomposition.cpph.
References std::abs(), max(), and temp.
Referenced by tarch::la::tests::LUDecompositionTest::testLU().
Vector< Size, Scalar > tarch::la::max | ( | const Vector< Size, Scalar > & | lhs, |
const Vector< Size, Scalar > & | rhs ) |
Component-wise max evaluation.
Returns the element with maximal value (NOT absolute value).
Definition at line 201 of file VectorOperations.cpph.
I need the maximum of three values all the time, to I decided to write a function for this.
Definition at line 8 of file Scalar.cpp.
References a.
Referenced by peano4::grid::internal::createBoundingBoxEvent(), applications::exahype2::euler::sphericalaccretion::SSInfall::isOutsideOfLargestRadius(), lu(), applications::exahype2::ccz4::CCZ4::refinementCriterion(), applications::exahype2::ccz4::FiniteVolumeCCZ4::refinementCriterion(), applications::exahype2::euler::sphericalaccretion::SSInfall::refinementCriterion(), toolbox::particles::internal::relativeGrabOwnershipSpatialSortingTolerance(), toolbox::particles::internal::relativeGrabOwnershipSpatialSortingTolerance(), toolbox::particles::internal::relativeReleaseOwnershipSpatialSortingTolerance(), toolbox::particles::internal::relativeReleaseOwnershipSpatialSortingTolerance(), selectNextAlgorithmicStep(), tarch::la::tests::VectorTest::testVectorOperations(), peano4::grid::internal::twoEventsAreAdjacent(), and mghype::matrixfree::solvers::Solver::updateMinMaxMeshSize().
Scalar tarch::la::maxAbs | ( | const Vector< Size, Scalar > & | vector | ) |
Returns the element with maximal absolute value.
Definition at line 212 of file VectorOperations.cpph.
References std::abs().
double tarch::la::maxImag | ( | const Vector< Size, std::complex< double > > & | vector | ) |
Definition at line 254 of file VectorOperations.cpph.
double tarch::la::maxReal | ( | const Vector< Size, std::complex< double > > & | vector | ) |
Definition at line 245 of file VectorOperations.cpph.
Vector< Size, Scalar > tarch::la::min | ( | const Vector< Size, Scalar > & | lhs, |
const Vector< Size, Scalar > & | rhs ) |
Component-wise min evaluation.
Returns the element with minimal value (NOT absolute value).
Definition at line 263 of file VectorOperations.cpph.
Referenced by swift2::boundaryconditions::applyFixedBoundaryCondition(), peano4::grid::internal::createBoundingBoxEvent(), toolbox::particles::createEquallySpacedParticles(), toolbox::particles::createParticlesAlignedWithGlobalCartesianMesh(), peano4::grid::Spacetree::descend(), toolbox::particles::internal::fitsIntoLevel(), toolbox::particles::internal::fitsIntoLevel(), toolbox::particles::insertParticleIntoCell(), operator+(), tarch::la::tests::VectorTest::testVectorOperations(), peano4::grid::internal::twoEventsAreAdjacent(), mghype::matrixfree::solvers::Solver::updateMinMaxMeshSize(), and swift2::kernels::legacy::updateSmoothingLengthAndRerunIfRequired().
void tarch::la::modifiedGramSchmidt | ( | DynamicMatrix | A, |
DynamicMatrix & | Q, | ||
DynamicMatrix & | R ) |
Definition at line 3 of file GramSchmidt.cpp.
References tarch::la::DynamicMatrix::cols(), and tarch::la::DynamicMatrix::rows().
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);
Definition at line 2 of file GramSchmidt.cpph.
Referenced by toolbox::blockstructured::interpolateCellDataAssociatedToVolumesIntoOverlappingCell_secondOrder(), and tarch::la::tests::GramSchmidtTest::testModifiedGramSchmidt().
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.
Referenced by tarch::la::tests::GramSchmidtTest::testModifiedGramSchmidt(), and tarch::la::tests::MatrixVectorTest::testMultiplication().
Matrix< Rows, Cols, Scalar > tarch::la::multiplyComponents | ( | const Matrix< Rows, X, Scalar > & | lhs, |
const Matrix< X, Cols, Scalar > & | rhs ) |
Referenced by exahype2::fd::applyBoundaryConditions(), exahype2::fv::applyBoundaryConditions(), exahype2::fd::applySommerfeldConditions(), toolbox::particles::getAdjacentCellsOwningParticle(), toolbox::finiteelements::getPoissonMatrixWithJumpingCoefficient(), exahype2::dg::getQuadraturePoint(), toolbox::particles::insertParticleIntoCell(), toolbox::blockstructured::interpolateCellDataAssociatedToVolumesIntoOverlappingCell_linear(), peano4::grid::Spacetree::loadVertices(), peano4::grid::TraversalVTKPlotter::plotCell(), toolbox::blockstructured::internal::projectCells_AoS(), and peano4::datamanagement::reconstructXOfParentVertex().
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.
Definition at line 73 of file VectorOperations.cpph.
References abs().
Referenced by tarch::la::tests::VectorTest::testVectorOperations().
Specialisation that is different to standard definition.
Works as result type is not part of the signature
Definition at line 82 of file VectorOperations.cpph.
References abs().
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.
Definition at line 100 of file VectorOperations.cpph.
References norm2Squared().
Referenced by benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFD4::addDensity(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFV::addDensity(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallDG::addDensity(), applications::exahype2::euler::sphericalaccretion::addGravitationalSource_AlphaCDM(), exahype2::fd::applySommerfeldConditions(), swift2::kernels::gravity::computeGravitationalForce(), swift2::kernels::legacy::density_kernel(), swift2::kernels::legacy::force_kernel(), swift2::kernels::legacy::forceKernelWithMasking(), toolbox::particles::TrajectoryDatabase::getAction(), swift2::kernels::legacy::hydro_prepare_force(), applications::exahype2::CompressibleNavierStokes::NavierStokesSolver::initialCondition(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFV::initialCondition(), applications::exahype2::euler::sphericalaccretion::initialiseOverdensity_bumpFunction(), applications::exahype2::euler::sphericalaccretion::initialiseOverdensity_Gaussian(), applications::exahype2::euler::sphericalaccretion::initialiseOverdensity_hyperbolicSecant(), applications::exahype2::euler::sphericalaccretion::initialiseOverdensity_topHat(), benchmarks::swift2::hydro::kernel_throughput::initNohProblemIC(), benchmarks::exahype2::ccz4::CCZ4SBH_FV::isCellOverlappingWithBHImpactArea(), applications::exahype2::euler::sphericalaccretion::SSInfall::isOutsideOfLargestRadius(), swift2::statistics::reduceVelocityAndSearchRadius_without_check(), benchmarks::exahype2::ccz4::CCZ4SBH_FD4::refinementCriterion(), applications::exahype2::ccz4::CCZ4::refinementCriterion(), applications::exahype2::ccz4::FiniteVolumeCCZ4::refinementCriterion(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFD4::refinementCriterion(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFV::refinementCriterion(), applications::exahype2::elastic::elastic::refinementCriterion(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallDG::refinementCriterion(), applications::exahype2::euler::sphericalaccretion::SSInfall::sourceTerm(), and toolbox::particles::potentials::springPotential().
Specialisation that is different to standard definition.
Works as result type is not part of the signature
Definition at line 115 of file VectorOperations.cpph.
References norm2Squared().
Scalar tarch::la::norm2Squared | ( | const Vector< Size, Scalar > & | vector | ) |
Definition at line 91 of file VectorOperations.cpph.
Referenced by swift2::kernels::adoptInteractionRadiusAndTriggerRerun(), swift2::kernels::legacy::densityKernelPairEvaluationPredicate(), norm2(), and norm2().
double tarch::la::norm2Squared | ( | const Vector< Size, std::complex< double > > & | vector | ) |
Definition at line 105 of file VectorOperations.cpph.
Scalar tarch::la::normMax | ( | const Vector< Size, Scalar > & | vector | ) |
Computes the max-norm of the vector.
Definition at line 120 of file VectorOperations.cpph.
References std::abs().
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
Definition at line 131 of file VectorOperations.cpph.
References std::abs().
Definition at line 324 of file VectorScalarOperations.cpph.
bool tarch::la::oneEquals | ( | const Vector< Size, Scalar > & | lhs, |
const Scalar & | cmp, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 158 of file VectorScalarOperations.cpph.
Definition at line 345 of file VectorScalarOperations.cpph.
bool tarch::la::oneGreater | ( | const Vector< Size, Scalar > & | lhs, |
const Scalar & | cmp, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 179 of file VectorScalarOperations.cpph.
Referenced by swift2::kernels::flagBoundaryParticles(), swift2::kernels::coalesced::forAllParticlePairs(), swift2::kernels::forAllParticlePairs(), swift2::kernels::internal::identifyInteractingParticles(), toolbox::particles::assignmentchecks::tests::internal::liftParticle(), toolbox::particles::assignmentchecks::internal::Database::shiftIdentifierCoordinates(), and tarch::la::tests::VectorTest::testVectorVectorOperations().
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() |
Definition at line 202 of file VectorVectorOperations.cpph.
bool tarch::la::oneGreaterEquals | ( | const Vector< Size, int > & | lhs, |
const int & | cmp ) |
Definition at line 366 of file VectorScalarOperations.cpph.
bool tarch::la::oneGreaterEquals | ( | const Vector< Size, Scalar > & | lhs, |
const Scalar & | cmp, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 200 of file VectorScalarOperations.cpph.
Referenced by swift2::boundaryconditions::isVertexOnGlobalBoundary(), and tarch::la::tests::VectorTest::testVectorVectorOperations().
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.
Definition at line 217 of file VectorVectorOperations.cpph.
Definition at line 387 of file VectorScalarOperations.cpph.
bool tarch::la::oneSmaller | ( | const Vector< Size, Scalar > & | lhs, |
const Scalar & | cmp, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 221 of file VectorScalarOperations.cpph.
Referenced by swift2::kernels::flagBoundaryParticles(), toolbox::particles::assignmentchecks::tests::internal::liftParticle(), and toolbox::particles::assignmentchecks::tests::TestHelpers::testPeriodicBoundaryConditions().
bool tarch::la::oneSmaller | ( | const Vector< Size, Scalar > & | lhs, |
const Vector< Size, Scalar > & | rhs, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 288 of file VectorVectorOperations.cpph.
bool tarch::la::oneSmallerEquals | ( | const Vector< Size, int > & | lhs, |
const int & | cmp ) |
Definition at line 408 of file VectorScalarOperations.cpph.
bool tarch::la::oneSmallerEquals | ( | const Vector< Size, Scalar > & | lhs, |
const Scalar & | cmp, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 242 of file VectorScalarOperations.cpph.
Referenced by swift2::boundaryconditions::isVertexOnGlobalBoundary(), and peano4::grid::internal::refinementEventOverrulesCoarsening().
bool tarch::la::oneSmallerEquals | ( | const Vector< Size, Scalar > & | lhs, |
const Vector< Size, Scalar > & | rhs, | ||
const Scalar | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 303 of file VectorVectorOperations.cpph.
References smallerEquals().
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.
Definition at line 332 of file VectorVectorOperations.cpph.
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.
Definition at line 123 of file VectorVectorOperations.cpph.
References innerDot().
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.
Definition at line 84 of file MatrixMatrixOperations.cpph.
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.
Definition at line 318 of file VectorVectorOperations.cpph.
Matrix< Size, Size, Scalar > tarch::la::outerDot | ( | const Vector< Size, Scalar > & | lhs, |
const Vector< Size, Scalar > & | rhs ) |
Outer dot product.
Wrapper around std::pow which is redirected to Intel's implementation on Intel machines.
Definition at line 23 of file Scalar.cpp.
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.
Definition at line 14 of file Scalar.cpp.
References std::abs().
Referenced by peano4::grid::internal::twoEventsAreAdjacent().
double tarch::la::relativeEpsNormaledAgainstValueGreaterOne | ( | 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 NUMERICAL_ZERO_DIFFERENCE or any other quantity and scales it with value if value is bigger than one. If it falls below one, then it returns the original eps.
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.
Definition at line 10 of file Scalar.cpp.
References std::abs().
Referenced by tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::PeanoTextPatchFileWriter(), tarch::plotter::griddata::unstructured::vtk::VTKBinaryFileWriter::VTKBinaryFileWriter(), tarch::plotter::griddata::unstructured::vtk::VTKTextFileWriter::VTKTextFileWriter(), and tarch::plotter::griddata::unstructured::vtk::VTUTextFileWriter::VTUTextFileWriter().
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.
Referenced by toolbox::particles::createParticlesAlignedWithGlobalCartesianMesh().
Definition at line 85 of file ScalarOperations.cpp.
int tarch::la::round | ( | float | value | ) |
Definition at line 89 of file ScalarOperations.cpp.
Extract row from matrix.
Referenced by elementMax(), frobeniusNorm(), tarch::la::DynamicMatrix::insertEmptyColumns(), tarch::la::DynamicMatrix::insertEmptyRows(), tarch::la::DynamicMatrix::multiply(), tarch::la::DynamicMatrix::multiplyBySmallMatrix(), tarch::la::DynamicMatrix::operator()(), tarch::la::DynamicMatrix::operator()(), operator*(), tarch::la::DynamicMatrix::operator==(), tarch::la::DynamicMatrix::operator==(), tarch::la::DynamicMatrix::removeColumn(), tarch::la::DynamicMatrix::replicateCols(), tarch::la::DynamicMatrix::scale(), tarch::la::DynamicMatrix::serialise(), tarch::la::DynamicMatrix::serialise(), tarch::la::DynamicMatrix::shiftColumnsRight(), tarch::la::DynamicMatrix::shiftRowsDown(), and tarch::la::DynamicMatrix::toString().
int tarch::la::sign | ( | double | value, |
double | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
Definition at line 76 of file ScalarOperations.cpp.
References greater().
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:
Referenced by tarch::la::tests::VectorTest::testWrappedVector().
void tarch::la::slice | ( | Vector< SizeLhs, Scalar > & | toVector, |
const Vector< SizeRhs, Scalar > & | fromVector, | ||
int | fromIndexInToVector, | ||
int | strideInToVector = 1 ) |
Setter.
Definition at line 20 of file VectorSlice.cpph.
References assertion6, and toString().
|
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.
tolerance | Absolute tolerance when we compare two values. |
Definition at line 63 of file ScalarOperations.h.
Referenced by convert::filter::Intersection::apply(), toolbox::particles::applyPeriodicBoundaryConditions(), toolbox::particles::createParticlesAlignedWithGlobalCartesianMesh(), swift2::kernels::legacy::densityKernelPairEvaluationPredicate(), swift2::kernels::legacy::force_kernel(), swift2::kernels::legacy::forceKernelWithMasking(), exahype2::getMinTimeStampOfNeighboursAhead(), tarch::timing::Measurement::getStandardDeviation(), tarch::timing::Measurement::getValue(), convert::data::PatchData::overlaps(), tarch::plotter::PVDTimeSeriesWriter::parseFile(), tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::PeanoTextPatchFileWriter(), applications::exahype2::swe::TopologyParser::sampleBathymetry(), applications::exahype2::swe::TopologyParser::sampleDisplacement(), peano4::grid::internal::sort(), benchmarks::exahype2::ccz4::CCZ4SBH_FD4::startTimeStep(), tarch::la::tests::ScalarTest::testComparison(), tarch::plotter::griddata::unstructured::vtk::VTKBinaryFileWriter::VTKBinaryFileWriter(), tarch::plotter::griddata::unstructured::vtk::VTKTextFileWriter::VTKTextFileWriter(), and tarch::plotter::griddata::unstructured::vtk::VTUTextFileWriter::VTUTextFileWriter().
bool tarch::la::smallerEquals | ( | double | lhs, |
double | rhs, | ||
double | tolerance = NUMERICAL_ZERO_DIFFERENCE ) |
tolerance | Absolute tolerance when we compare two values. |
Definition at line 52 of file ScalarOperations.cpp.
Referenced by allSmallerEquals(), allSmallerEquals(), toolbox::particles::createEquallySpacedParticles(), exahype2::getInterpolationWeights(), applications::exahype2::euler::sphericalaccretion::MassAccumulator::getMass_linearInterpolation(), toolbox::particles::getParticleReassociationInstructionWithinCellWithIntraCellReassignment(), toolbox::particles::FileReader::getParticlesWithinVoxel(), toolbox::particles::FileReaderHDF5::getParticlesWithinVoxel(), swift2::boundaryconditions::getUpdateDueToFixedBoundaryCondition(), applications::exahype2::euler::sphericalaccretion::initialiseOverdensity_bumpFunction(), toolbox::particles::insertParticleIntoCell(), toolbox::blockstructured::interpolateCellDataAssociatedToVolumesIntoOverlappingCell_linear(), peano4::datamanagement::CellMarker::isContained(), peano4::datamanagement::VertexMarker::isContainedInAdjacentCells(), applications::exahype2::euler::sphericalaccretion::SSInfall::mass_interpolate(), oneSmallerEquals(), peano4::datamanagement::CellMarker::overlaps(), exahype2::fv::internal::projectValueOntoParticle_piecewiseLinear(), tarch::timing::Measurement::setValue(), applications::exahype2::euler::sphericalaccretion::SSInfall::startTimeStep(), tarch::la::tests::ScalarTest::testComparison(), peano4::grid::internal::twoEventsAreAdjacent(), and tarch::logging::Statistics::writeToCSV().
Scalar tarch::la::sum | ( | const Matrix< Rows, Cols, Scalar > & | matrix | ) |
Computes the sum of all entries of the matrix.
Definition at line 101 of file MatrixOperations.cpph.
Referenced by tarch::la::tests::VectorTest::testVectorOperations().
Sums up the component values of the vector.
Definition at line 165 of file VectorOperations.cpph.
std::vector< Scalar > tarch::la::toSTLVector | ( | const Vector< Size, Scalar > & | vector | ) |
Definition at line 5 of file VectorOperations.cpph.
tarch::la::DynamicMatrix tarch::la::transpose | ( | const DynamicMatrix & | matrix | ) |
Definition at line 3 of file DynamicMatrixOperations.cpp.
References tarch::la::DynamicMatrix::cols(), and tarch::la::DynamicMatrix::rows().
Referenced by toolbox::blockstructured::interpolateCellDataAssociatedToVolumesIntoOverlappingCell_secondOrder(), tarch::la::tests::GramSchmidtTest::testModifiedGramSchmidt(), and tarch::la::tests::MatrixTest::testTransposedMatrix().
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.
Definition at line 174 of file VectorOperations.cpph.
Referenced by benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFD4::addDensity(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFV::addDensity(), exahype2::dg::cellIntegral_patchwise_in_situ_GaussLegendre(), exahype2::dg::cellIntegral_patchwise_in_situ_GaussLegendre_functors(), toolbox::finiteelements::getPoissonMatrixWithJumpingCoefficient(), peano4::grid::internal::sort(), peano4::grid::internal::twoEventsAreAdjacent(), mghype::matrixfree::solvers::Solver::updateGlobalResidual(), and mghype::matrixfree::solvers::Solver::updateGlobalSolutionUpdates().
|
constexpr |
|
constexpr |
Definition at line 17 of file Scalar.h.
Referenced by toolbox::particles::dropParticle(), toolbox::particles::getAdjacentCellsOwningParticle(), applications::exahype2::euler::selfgravitation::Poisson::getAdmissibleTimeStepSize(), tarch::timing::GlidingAverageMeasurement::getStandardDeviation(), toolbox::particles::liftParticleAssociatedWithVertex(), swift2::kernels::localParticleCanBeUpdatedInCellKernel(), swift2::kernels::localParticleCanBeUpdatedInCellKernelFromAnyOtherParticle(), swift2::kernels::localParticleCanBeUpdatedInCellKernelFromAnyOtherParticleWithinIterationRange(), swift2::markAllParticlesAsUpdatedWithinCell(), toolbox::particles::relativeSpatialOwnershipTolerance(), exahype2::removeTimeStepAccumulationErrorsFromCell(), toolbox::particles::sieveParticle(), toolbox::particles::tests::MultiscaleTransitionsTest::testLiftDropOfParticleAssociatedWithVertex03(), and toolbox::particles::tests::MultiscaleTransitionsTest::testLiftDropOfParticleAssociatedWithVertex04().
|
constexpr |
Definition at line 12 of file Scalar.h.
Referenced by applications::exahype2::euler::selfgravitation::Poisson::flux(), applications::exahype2::euler::sphericalaccretion::SSInfall::getForceDensityNorm(), applications::exahype2::euler::sphericalaccretion::SSInfall::getInitialMIn(), tests::multigrid::matrixfree::poisson::getPointWiseRhs(), applications::exahype2::euler::sphericalaccretion::initialiseOverdensity_bumpFunction(), applications::exahype2::euler::sphericalaccretion::initialiseOverdensity_Gaussian(), applications::exahype2::euler::sphericalaccretion::initialiseOverdensity_hyperbolicSecant(), applications::exahype2::euler::sphericalaccretion::initialiseOverdensity_topHat(), initInputData(), benchmarks::multigrid::petsc::poisson::DGPoisson::initNode(), applications::exahype2::euler::sphericalaccretion::SSInfall::mass_interpolate(), applications::exahype2::euler::selfgravitation::Poisson::maxEigenvalue(), applications::exahype2::euler::sphericalaccretion::SSInfall::sourceTerm(), applications::exahype2::euler::selfgravitation::Poisson::sourceTerm(), and applications::exahype2::euler::sphericalaccretion::SSInfall::sourceTerm().