Peano 4
Loading...
Searching...
No Matches
tarch::la Namespace Reference

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...
 
struct  Vector
 Simple vector class. More...
 
struct  VectorCompare
 Comparison operator for boolean vectors. More...
 

Functions

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.
 
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)
 Accepts an upper triangular matrix and a rhs.
 
template<typename Scalar >
Matrix< 2, 2, Scalar > invert (const Matrix< 2, 2, Scalar > &R)
 
template<typename Scalar >
Matrix< 3, 3, Scalar > invert (const Matrix< 3, 3, Scalar > &R)
 
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, intequalsReturnIndex (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
 

Detailed Description

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.

Function Documentation

◆ abs() [1/5]

double tarch::la::abs ( const std::complex< double > & value)

Definition at line 9 of file ScalarOperations.cpp.

◆ abs() [2/5]

template<int Size, typename Scalar >
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.

Returns
A copy of the temporary holding the result.

◆ abs() [3/5]

template<int Size>
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

◆ abs() [4/5]

double tarch::la::abs ( double value)

Returns the absolute value of a type by redirecting to std::abs.

Definition at line 13 of file ScalarOperations.cpp.

Referenced by swift2::kernels::legacy::hydro_prepare_force(), norm1(), norm1(), tarch::la::tests::ScalarTest::testAbs(), toolbox::particles::tests::MultiscaleTransitionsTest::testSievePredicate(), and tarch::la::Matrix< Rows, Cols, Scalar >::toPrettyString().

Here is the caller graph for this function:

◆ abs() [5/5]

int tarch::la::abs ( int value)

Returns the absolute value of the given int.

Definition at line 5 of file ScalarOperations.cpp.

◆ allEntriesAreTheSame()

template<int Size, typename Scalar >
bool tarch::la::allEntriesAreTheSame ( const Vector< Size, Scalar > & vector)

Definition at line 24 of file VectorOperations.cpph.

References equals().

Here is the call graph for this function:

◆ allGreater() [1/3]

template<int Size>
bool tarch::la::allGreater ( const Vector< Size, int > & lhs,
const int & cmp )

Definition at line 429 of file VectorScalarOperations.cpph.

◆ allGreater() [2/3]

template<int Size, typename Scalar >
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 tarch::la::tests::VectorTest::testVectorVectorOperations().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ allGreater() [3/3]

template<int Size, typename Scalar >
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.

Parameters
toleranceAbsolute 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().

Here is the call graph for this function:

◆ allGreaterEquals() [1/3]

template<int Size>
bool tarch::la::allGreaterEquals ( const Vector< Size, int > & lhs,
const int & cmp )

Definition at line 450 of file VectorScalarOperations.cpph.

◆ allGreaterEquals() [2/3]

template<int Size, typename Scalar >
bool tarch::la::allGreaterEquals ( const Vector< Size, Scalar > & lhs,
const Scalar & cmp,
const Scalar tolerance = NUMERICAL_ZERO_DIFFERENCE )

◆ allGreaterEquals() [3/3]

template<int Size, typename Scalar >
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().

Here is the call graph for this function:

◆ allSmaller() [1/3]

template<int Size>
bool tarch::la::allSmaller ( const Vector< Size, int > & lhs,
const int & cmp )

Definition at line 471 of file VectorScalarOperations.cpph.

◆ allSmaller() [2/3]

template<int Size, typename Scalar >
bool tarch::la::allSmaller ( const Vector< Size, Scalar > & lhs,
const Scalar & cmp,
const Scalar tolerance = NUMERICAL_ZERO_DIFFERENCE )

◆ allSmaller() [3/3]

template<int Size, typename Scalar >
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.

◆ allSmallerEquals() [1/3]

template<int Size>
bool tarch::la::allSmallerEquals ( const Vector< Size, int > & lhs,
const int & cmp )

Definition at line 492 of file VectorScalarOperations.cpph.

◆ allSmallerEquals() [2/3]

template<int Size, typename Scalar >
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ allSmallerEquals() [3/3]

template<int Size, typename Scalar >
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().

Here is the call graph for this function:

◆ aPowI()

◆ average()

template<int Size, typename Scalar >
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.

◆ backSubstitution()

template<int Rows, typename Scalar >
Vector< Rows, Scalar > tarch::la::backSubstitution ( const Matrix< Rows, Rows, Scalar > & R,
const Vector< Rows, Scalar > & f )

Accepts an upper triangular matrix and a rhs.

It then returns the solution x to

Rx=f

i.e. x=R^{-1}f

◆ col()

◆ contains()

◆ convertAbsoluteIntoRelativeValue()

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.

Definition at line 26 of file Scalar.cpp.

◆ convertScalar()

template<typename NewScalarType , int Size, typename Scalar >
tarch::la::Vector< Size, NewScalarType > tarch::la::convertScalar ( const tarch::la::Vector< Size, Scalar > & vector)

Definition at line 94 of file Vector.cpph.

◆ count()

template<int Size, typename Scalar >
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ countEqualEntries() [1/2]

template<int Size>
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().

Here is the caller graph for this function:

◆ countEqualEntries() [2/2]

template<int Size, typename Scalar >
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.

◆ cross()

template<typename Scalar >
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().

Here is the caller graph for this function:

◆ det() [1/2]

template<typename Scalar >
double tarch::la::det ( const Matrix< 2, 2, Scalar > & R)

Definition at line 80 of file LUDecomposition.cpph.

◆ det() [2/2]

template<typename Scalar >
double tarch::la::det ( const Matrix< 3, 3, Scalar > & R)

Definition at line 133 of file LUDecomposition.cpph.

◆ diag()

template<int Rows, typename Scalar >
Vector< Rows, Scalar > tarch::la::diag ( const Matrix< Rows, Rows, Scalar > & matrix)

Extract diagonal vector from matrix.

◆ dot()

template<int Size, typename Scalar >
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ elementMax()

template<int Rows, int Cols, typename Scalar >
Scalar tarch::la::elementMax ( const Matrix< Rows, Cols, Scalar > & matrix)

Max norm.

Definition at line 29 of file MatrixOperations.cpph.

References col(), matrix, and row().

Here is the call graph for this function:

◆ equals() [1/6]

template<int Rows, int Cols, typename Scalar >
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 65 of file MatrixMatrixOperations.cpph.

References j.

Referenced by examples::exahype2::gprdr::GPRDR::adjustSolution(), examples::exahype2::loh1::LOH1::adjustSolution(), examples::exahype2::loh1::LOH1OnGPU::adjustSolution(), examples::exahype2::mgccz4::FiniteVolumeMGCCZ4::adjustSolution(), examples::exahype2::ccz4::ADERDGCCZ4::adjustSolution(), examples::exahype2::loh1::ADERDGLOH1::adjustSolution(), examples::exahype2::mgccz4::ADERDGMGCCZ4::adjustSolution(), allEntriesAreTheSame(), tarch::plotter::PVDTimeSeriesWriter::appendNewData(), swift2::boundaryconditions::applyFixedBoundaryCondition(), exahype2::fd::applySommerfeldConditions(), toolbox::loadbalancing::AbstractLoadBalancing::areRanksUnemployed(), applications::exahype2::swe::parser::AdjointParser::calculate_inner_product(), applications::exahype2::swe::adjoint::AdjointSolver::compute_net_updates(), Numerics::computeAbsA(), swift2::timestepping::computeAdmissibleTimeStepSizeFromGlobalMeshSizeAndMaximumVelocity(), count(), toolbox::particles::assignmentchecks::internal::Database::createParticleIdentifier(), 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(), ContextCurvilinear< Shortcuts, basisSize >::initUnknownsPatch(), Context< Shortcuts, basisSize >::initUnknownsPointwise(), applications::exahype2::swe::parser::AdjointParser::max_inner_product(), 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::ccz4::CCZ4::refinementCriterion(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFD4::refinementCriterion(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFV::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(), 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().

◆ equals() [2/6]

bool tarch::la::equals ( const std::complex< double > & lhs,
const std::complex< double > & rhs,
double tolerance = NUMERICAL_ZERO_DIFFERENCE )
Parameters
toleranceAbsolute tolerance when we compare two values.

Definition at line 68 of file ScalarOperations.cpp.

◆ equals() [3/6]

template<int Size>
bool tarch::la::equals ( const Vector< Size, int > & lhs,
const int & cmp )

Specialisation for int.

Definition at line 303 of file VectorScalarOperations.cpph.

◆ equals() [4/6]

template<int Size, typename Scalar >
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.

◆ equals() [5/6]

template<int Size, typename Scalar >
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.

Parameters
toleranceAbsolute 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.

◆ equals() [6/6]

bool tarch::la::equals ( double lhs,
double rhs,
double tolerance = NUMERICAL_ZERO_DIFFERENCE )
Parameters
toleranceAbsolute tolerance when we compare two values.

Definition at line 60 of file ScalarOperations.cpp.

◆ equalsReturnIndex() [1/3]

template<int Rows, int Cols, typename Scalar >
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 118 of file MatrixMatrixOperations.cpph.

References j.

Referenced by tarch::la::tests::MatrixTest::testMatrixMatrixOperations(), and tarch::la::tests::VectorTest::testVectorVectorOperations().

Here is the caller graph for this function:

◆ equalsReturnIndex() [2/3]

template<int Size>
int tarch::la::equalsReturnIndex ( const Vector< Size, int > & lhs,
const Vector< Size, int > & rhs )

Definition at line 354 of file VectorVectorOperations.cpph.

◆ equalsReturnIndex() [3/3]

template<int Size, typename Scalar >
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.

◆ expandOrSlice() [1/2]

template<int SizeLhs, typename Scalar >
Vector< SizeLhs, Scalar > tarch::la::expandOrSlice ( const Scalar & scalar)

Delegates to slice().

See also
expandOrSlice()

◆ expandOrSlice() [2/2]

template<int SizeLhs, int SizeRhs, typename Scalar >
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().

◆ firstGreater()

template<int Size, typename Scalar >
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.

Parameters
toleranceAbsolute 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().

Here is the caller graph for this function:

◆ frobeniusNorm()

template<int Rows, int Cols, typename Scalar >
Scalar tarch::la::frobeniusNorm ( const Matrix< Rows, Cols, Scalar > & matrix)

Definition at line 14 of file MatrixOperations.cpph.

References col(), matrix, and row().

Referenced by examples::regulargridupscaling::MyObserver::enterCell().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ greater()

bool tarch::la::greater ( double lhs,
double rhs,
double tolerance = NUMERICAL_ZERO_DIFFERENCE )
Parameters
toleranceAbsolute tolerance when we compare two values.

Definition at line 25 of file ScalarOperations.cpp.

Referenced by applications::exahype2::euler::sphericalaccretion::addGravitationalSource_AlphaCDM(), allGreater(), allGreater(), exahype2::saintvenant::calculateDerivatives(), applications::exahype2::swe::adjoint::AdjointSolver::compute_net_updates(), applications::exahype2::swe::adjoint::DimensionalSplitting::compute_numerical_fluxes(), swift2::kernels::gravity::computeGravitationalForce(), toolbox::particles::createParticlesAlignedWithGlobalCartesianMesh(), swift2::kernels::legacy::density_kernel(), exahype2::discretiseAndTruncateTimeStepSizes(), toolbox::blockstructured::GlobalDatabase::dumpDatabaseSnapshot(), toolbox::particles::TrajectoryDatabase::dumpDatabaseSnapshot(), exahype2::saintvenant::flux(), swift2::kernels::legacy::force_kernel(), swift2::kernels::legacy::forceKernelWithMasking(), exahype2::getMinTimeStampOfNeighboursAhead(), applications::exahype2::swe::adjoint::SWEAdjoint::hump_criterion_square(), applications::exahype2::swe::parser::AdjointParser::interpolate_values(), applications::exahype2::euler::sphericalaccretion::SSInfall::mass_interpolate(), exahype2::saintvenant::maxEigenvalue(), convert::data::PatchData::overlaps(), applications::exahype2::euler::sphericalaccretion::SSInfall::patchCanUseStatelessPDETerms(), applications::exahype2::swe::parser::TopologyParser::sample_bathymetry(), applications::exahype2::swe::parser::AdjointParser::set_start_index(), sign(), peano4::grid::internal::sort(), and tarch::la::tests::ScalarTest::testComparison().

Here is the caller graph for this function:

◆ greaterEquals()

◆ identity()

template<int Rows, typename Scalar >
static Matrix< Rows, Rows, Scalar > tarch::la::identity ( )
static

Returns the identity matrix.

◆ imag()

template<int Size>
Vector< Size, double > tarch::la::imag ( const Vector< Size, std::complex< double > > & vector)

◆ indexMax()

template<int Size, typename Scalar >
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ indexMin()

template<int Size, typename Scalar >
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ innerDot()

template<int Size, typename Scalar >
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*().

Here is the caller graph for this function:

◆ invert() [1/2]

template<typename Scalar >
Matrix< 2, 2, Scalar > tarch::la::invert ( const Matrix< 2, 2, Scalar > & R)

Referenced by tarch::la::tests::LUDecompositionTest::testInversion().

Here is the caller graph for this function:

◆ invert() [2/2]

template<typename Scalar >
Matrix< 3, 3, Scalar > tarch::la::invert ( const Matrix< 3, 3, Scalar > & R)

◆ invertEntries() [1/2]

template<int Rows, int Cols, typename Scalar >
Matrix< Rows, Cols, Scalar > tarch::la::invertEntries ( const Matrix< Rows, Cols, Scalar > & matrix)

◆ invertEntries() [2/2]

template<int Size, typename Scalar >
Vector< Size, Scalar > tarch::la::invertEntries ( const Vector< Size, Scalar > & vector)

◆ isEntryFinite()

template<int Size, typename Scalar >
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().

Here is the caller graph for this function:

◆ isEntryNan()

template<int Size, typename Scalar >
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().

Here is the caller graph for this function:

◆ lu() [1/2]

template<int Rows, typename Scalar >
void tarch::la::lu ( Matrix< Rows, Rows, Scalar > & A)

In-situ LU without pivoting.

See the other lu routine.

Definition at line 60 of file LUDecomposition.cpph.

References j, and k.

◆ lu() [2/2]

template<int Rows, typename Scalar >
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 upper triangular matrix are one.

Definition at line 21 of file LUDecomposition.cpph.

References j, k, and max().

Here is the call graph for this function:

◆ max() [1/3]

template<int Size, typename Scalar >
Vector< Size, Scalar > tarch::la::max ( const Vector< Size, Scalar > & lhs,
const Vector< Size, Scalar > & rhs )

Component-wise max evaluation.

◆ max() [2/3]

template<int Size, typename Scalar >
Scalar tarch::la::max ( const Vector< Size, Scalar > & vector)

Returns the element with maximal value (NOT absolute value).

Definition at line 201 of file VectorOperations.cpph.

◆ max() [3/3]

◆ maxAbs()

template<int Size, typename Scalar >
Scalar tarch::la::maxAbs ( const Vector< Size, Scalar > & vector)

Returns the element with maximal absolute value.

Definition at line 212 of file VectorOperations.cpph.

◆ maxImag()

template<int Size>
double tarch::la::maxImag ( const Vector< Size, std::complex< double > > & vector)

Definition at line 254 of file VectorOperations.cpph.

◆ maxReal()

template<int Size>
double tarch::la::maxReal ( const Vector< Size, std::complex< double > > & vector)

Definition at line 245 of file VectorOperations.cpph.

◆ min() [1/2]

template<int Size, typename Scalar >
Vector< Size, Scalar > tarch::la::min ( const Vector< Size, Scalar > & lhs,
const Vector< Size, Scalar > & rhs )

Component-wise min evaluation.

◆ min() [2/2]

◆ modifiedGramSchmidt()

template<int Rows, int Cols, typename Scalar >
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:

  • The column vectors of A have to be linear independent.
  • If A has n columns and m rows, then:
    • n <= m for A
    • Q has to have same size than A
    • R has to be a n * n matrix

Postconditions:

  • A is changed
  • Q holds an orthonormal basis of range(A) in its column vectors.
  • R is an upper triangular matrix, with all main diagonal element unequal to zero iff A has full rank.

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.

References j, and k.

Referenced by tarch::la::tests::GramSchmidtTest::testModifiedGramSchmidt().

Here is the caller graph for this function:

◆ multiply() [1/2]

template<int Rows, int Cols, typename Scalar >
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.

◆ multiply() [2/2]

template<int Rows, int Cols, int X, typename Scalar >
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().

Here is the caller graph for this function:

◆ multiplyComponents() [1/2]

◆ multiplyComponents() [2/2]

template<int Size, typename Scalar >
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.

◆ norm1() [1/2]

template<int Size, typename Scalar >
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ norm1() [2/2]

template<int Size>
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

Definition at line 82 of file VectorOperations.cpph.

References abs().

Here is the call graph for this function:

◆ norm2() [1/2]

template<int Size, typename Scalar >
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::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::ccz4::CCZ4::refinementCriterion(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFD4::refinementCriterion(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallFV::refinementCriterion(), benchmarks::exahype2::euler::sphericalaccretionupscaling::SelfSimilarInfallDG::refinementCriterion(), applications::exahype2::euler::sphericalaccretion::SSInfall::sourceTerm(), applications::exahype2::acousticwave::sourceTerm(), applications::exahype2::elasticwave::sourceTerm(), and toolbox::particles::potentials::springPotential().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ norm2() [2/2]

template<int Size>
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

Definition at line 115 of file VectorOperations.cpph.

References norm2Squared().

Here is the call graph for this function:

◆ norm2Squared() [1/2]

template<int Size, typename Scalar >
Scalar tarch::la::norm2Squared ( const Vector< Size, Scalar > & vector)

Definition at line 91 of file VectorOperations.cpph.

Referenced by swift2::kernels::adoptInteractionRadiusAndTriggerRerun(), norm2(), and norm2().

Here is the caller graph for this function:

◆ norm2Squared() [2/2]

template<int Size>
double tarch::la::norm2Squared ( const Vector< Size, std::complex< double > > & vector)

Definition at line 105 of file VectorOperations.cpph.

◆ normMax() [1/2]

template<int Size, typename Scalar >
Scalar tarch::la::normMax ( const Vector< Size, Scalar > & vector)

Computes the max-norm of the vector.

Definition at line 120 of file VectorOperations.cpph.

◆ normMax() [2/2]

template<int Size>
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.

◆ oneEquals() [1/2]

template<int Size>
bool tarch::la::oneEquals ( const Vector< Size, int > & lhs,
const int & cmp )

Definition at line 324 of file VectorScalarOperations.cpph.

◆ oneEquals() [2/2]

template<int Size, typename Scalar >
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.

◆ oneGreater() [1/3]

template<int Size>
bool tarch::la::oneGreater ( const Vector< Size, int > & lhs,
const int & cmp )

Definition at line 345 of file VectorScalarOperations.cpph.

◆ oneGreater() [2/3]

template<int Size, typename Scalar >
bool tarch::la::oneGreater ( const Vector< Size, Scalar > & lhs,
const Scalar & cmp,
const Scalar tolerance = NUMERICAL_ZERO_DIFFERENCE )

◆ oneGreater() [3/3]

template<int Size, typename Scalar >
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.

Parameters
toleranceAbsolute 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.

◆ oneGreaterEquals() [1/3]

template<int Size>
bool tarch::la::oneGreaterEquals ( const Vector< Size, int > & lhs,
const int & cmp )

Definition at line 366 of file VectorScalarOperations.cpph.

◆ oneGreaterEquals() [2/3]

template<int Size, typename Scalar >
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().

Here is the caller graph for this function:

◆ oneGreaterEquals() [3/3]

template<int Size, typename Scalar >
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.

◆ oneSmaller() [1/3]

template<int Size>
bool tarch::la::oneSmaller ( const Vector< Size, int > & lhs,
const int & cmp )

Definition at line 387 of file VectorScalarOperations.cpph.

◆ oneSmaller() [2/3]

template<int Size, typename Scalar >
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().

Here is the caller graph for this function:

◆ oneSmaller() [3/3]

template<int Size, typename Scalar >
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.

◆ oneSmallerEquals() [1/3]

template<int Size>
bool tarch::la::oneSmallerEquals ( const Vector< Size, int > & lhs,
const int & cmp )

Definition at line 408 of file VectorScalarOperations.cpph.

◆ oneSmallerEquals() [2/3]

template<int Size, typename Scalar >
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().

Here is the caller graph for this function:

◆ oneSmallerEquals() [3/3]

template<int Size, typename Scalar >
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().

Here is the call graph for this function:

◆ operator!=()

template<int Size, typename Scalar >
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.

◆ operator*() [1/8]

template<int Rows, int Cols>
Matrix< Rows, Cols, std::complex< double > > tarch::la::operator* ( const double & scalar,
const Matrix< Rows, Cols, std::complex< double > > & matrix )

◆ operator*() [2/8]

template<int Rows, int Cols, typename Scalar >
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.

◆ operator*() [3/8]

template<int Rows, int Cols, typename Scalar >
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.

◆ operator*() [4/8]

template<int Rows, int Cols, int X, typename Scalar >
Matrix< Rows, Cols, Scalar > tarch::la::operator* ( const Matrix< Rows, X, Scalar > & lhs,
const Matrix< X, Cols, Scalar > & rhs )

◆ operator*() [5/8]

template<int Rows, int Cols, typename Scalar >
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.

◆ operator*() [6/8]

template<int Size, typename Scalar >
Vector< Size, Scalar > tarch::la::operator* ( const Scalar & scalar,
const Vector< Size, Scalar > & vector )

◆ operator*() [7/8]

template<int Size, typename Scalar >
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().

Here is the call graph for this function:

◆ operator*() [8/8]

template<int Size, typename Scalar >
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.

◆ operator*=() [1/2]

template<int Rows, int Cols, typename Scalar >
Matrix< Rows, Cols, Scalar > & tarch::la::operator*= ( Matrix< Rows, Cols, Scalar > & matrix,
const Scalar & scalar )

◆ operator*=() [2/2]

template<int Size, typename 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.

◆ operator+() [1/4]

template<int Rows, int Cols, typename Scalar >
Matrix< Rows, Cols, Scalar > tarch::la::operator+ ( const Matrix< Rows, Cols, Scalar > & lhs,
const Matrix< Rows, Cols, Scalar > & rhs )

◆ operator+() [2/4]

template<int Size, typename Scalar >
Vector< Size, Scalar > tarch::la::operator+ ( const Scalar & scalar,
const Vector< Size, Scalar > & vector )

◆ operator+() [3/4]

template<int Size, typename Scalar >
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.

◆ operator+() [4/4]

template<int Size, typename Scalar >
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.

◆ operator+=() [1/2]

template<int Size, typename Scalar >
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.

◆ operator+=() [2/2]

template<int Size, typename Scalar >
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.

◆ operator-() [1/3]

template<int Rows, int Cols, typename Scalar >
Matrix< Rows, Cols, Scalar > tarch::la::operator- ( const Matrix< Rows, Cols, Scalar > & lhs,
const Matrix< Rows, Cols, Scalar > & rhs )

◆ operator-() [2/3]

template<int Size, typename Scalar >
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.

◆ operator-() [3/3]

template<int Size, typename Scalar >
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.

◆ operator-=() [1/2]

template<int Size, typename Scalar >
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.

◆ operator-=() [2/2]

template<int Size, typename Scalar >
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.

◆ operator/()

template<int Size, typename Scalar >
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.

◆ operator/=()

template<int Size, typename Scalar >
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.

◆ operator==() [1/2]

template<int Rows, int Cols, typename Scalar >
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 48 of file MatrixMatrixOperations.cpph.

References j.

◆ operator==() [2/2]

template<int Size, typename Scalar >
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.

◆ outerDot()

template<int Size, typename Scalar >
Matrix< Size, Size, Scalar > tarch::la::outerDot ( const Vector< Size, Scalar > & lhs,
const Vector< Size, Scalar > & rhs )

Outer dot product.

◆ pow()

double tarch::la::pow ( double base,
double exponent )

Wrapper around std::pow which is redirected to Intel's implementation on Intel machines.

Definition at line 23 of file Scalar.cpp.

◆ real()

template<int Size>
Vector< Size, double > tarch::la::real ( const Vector< Size, std::complex< double > > & vector)

◆ relativeEps()

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.

Referenced by peano4::grid::internal::twoEventsAreAdjacent().

Here is the caller graph for this function:

◆ relativeEpsNormaledAgainstValueGreaterOne()

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.

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().

Here is the caller graph for this function:

◆ remainder()

template<int Size, typename Scalar >
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().

Here is the caller graph for this function:

◆ round() [1/2]

int tarch::la::round ( double value)

Definition at line 85 of file ScalarOperations.cpp.

◆ round() [2/2]

int tarch::la::round ( float value)

Definition at line 89 of file ScalarOperations.cpp.

◆ row()

◆ sign()

int tarch::la::sign ( double value,
double tolerance = NUMERICAL_ZERO_DIFFERENCE )
Returns
-10, or 1 depending on the sign of value

Definition at line 76 of file ScalarOperations.cpp.

References greater().

Here is the call graph for this function:

◆ slice() [1/2]

template<int SizeLhs, int SizeRhs, typename Scalar >
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:

tarch::la::slice<3>(myVector,0)

Take the elements 2,3,5,6 from a vector:

tarch::la::slice<3>(myVector,2,2)

Referenced by tarch::la::tests::VectorTest::testWrappedVector().

Here is the caller graph for this function:

◆ slice() [2/2]

template<int SizeLhs, int SizeRhs, typename Scalar >
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().

Here is the call graph for this function:

◆ smaller()

static bool tarch::la::smaller ( double lhs,
double rhs,
double tolerance = NUMERICAL_ZERO_DIFFERENCE )
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.

Parameters
toleranceAbsolute tolerance when we compare two values.

Definition at line 62 of file ScalarOperations.h.

Referenced by convert::filter::Intersection::apply(), toolbox::particles::createParticlesAlignedWithGlobalCartesianMesh(), swift2::kernels::legacy::force_kernel(), swift2::kernels::legacy::forceKernelWithMasking(), exahype2::getMinTimeStampOfNeighboursAhead(), tarch::timing::Measurement::getStandardDeviation(), tarch::timing::Measurement::getValue(), applications::exahype2::swe::adjoint::SWEAdjoint::hump_criterion_circle(), applications::exahype2::swe::adjoint::SWEAdjoint::hump_criterion_square(), toolbox::particles::insertParticleIntoCell(), applications::exahype2::swe::parser::AdjointParser::interpolate_values(), applications::exahype2::swe::parser::AdjointParser::max_inner_product(), convert::data::PatchData::overlaps(), tarch::plotter::PVDTimeSeriesWriter::parseFile(), tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::PeanoTextPatchFileWriter(), applications::exahype2::swe::parser::TopologyParser::sample_bathymetry(), 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().

Here is the caller graph for this function:

◆ smallerEquals()

bool tarch::la::smallerEquals ( double lhs,
double rhs,
double tolerance = NUMERICAL_ZERO_DIFFERENCE )
Parameters
toleranceAbsolute tolerance when we compare two values.

Definition at line 52 of file ScalarOperations.cpp.

Referenced by allSmallerEquals(), allSmallerEquals(), toolbox::particles::createEquallySpacedParticles(), swift2::kernels::legacy::density_kernel(), 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(), applications::exahype2::swe::parser::AdjointParser::max_inner_product(), oneSmallerEquals(), peano4::datamanagement::CellMarker::overlaps(), examples::exahype2::loh1::AbstractLOH1OnGPU::refinementCriterion(), applications::exahype2::swe::adjoint::SWEAdjoint::run_simulation(), applications::exahype2::swe::parser::TopologyParser::sample_displacement(), applications::exahype2::swe::parser::AdjointParser::set_start_index(), tarch::timing::Measurement::setValue(), applications::exahype2::euler::sphericalaccretion::SSInfall::startTimeStep(), tarch::la::tests::ScalarTest::testComparison(), peano4::grid::internal::twoEventsAreAdjacent(), and tarch::logging::Statistics::writeToCSV().

Here is the caller graph for this function:

◆ sum() [1/2]

template<int Rows, int Cols, typename Scalar >
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.

References j, and matrix.

Referenced by tarch::la::tests::VectorTest::testVectorOperations().

Here is the caller graph for this function:

◆ sum() [2/2]

template<int Size, typename Scalar >
Scalar tarch::la::sum ( const Vector< Size, Scalar > & vector)

Sums up the component values of the vector.

Definition at line 165 of file VectorOperations.cpph.

◆ toSTLVector()

template<int Size, typename Scalar >
std::vector< Scalar > tarch::la::toSTLVector ( const Vector< Size, Scalar > & vector)

Definition at line 5 of file VectorOperations.cpph.

◆ transpose()

template<int Rows, int Cols, typename Scalar >
Matrix< Cols, Rows, Scalar > tarch::la::transpose ( const Matrix< Rows, Cols, Scalar > & matrix)

◆ volume()

template<int Size, typename Scalar >
Scalar tarch::la::volume ( const Vector< Size, Scalar > & vector)

Variable Documentation

◆ E

constexpr double tarch::la::E = 2.7182818284590452353602874713526624977572
constexpr

Definition at line 13 of file Scalar.h.

◆ NUMERICAL_ZERO_DIFFERENCE

◆ PI