MoReFEM
|
Placeholder namespace description needed for it to appear in Doxygen namespace list. More...
Functions | |
template<class T > | |
constexpr T | UninitializedIndex () noexcept |
When an index is not known at object constructor, better assign a controlled dumb value than not knowing what the compiler decided. | |
template<class T > | |
constexpr T | Square (T value) noexcept |
Computes the square of a value. | |
template<class T > | |
constexpr T | Cube (T value) noexcept |
Computes the cube of a value. | |
template<class T > | |
constexpr T | PowerFour (T value) noexcept |
Computes the 4th power of a value. | |
template<class T > | |
constexpr T | AbsPlus (T value) noexcept |
Returns value if it is positive or 0 otherwise. | |
template<class T > | |
constexpr T | Sign (T value) noexcept |
Returns -1, 0 or 1 depending on the sign of tge value. | |
template<class T > | |
constexpr T | TrueSign (T value) noexcept |
A special version of Sign which considers 0 as positive. | |
template<class T > | |
constexpr T | Heaviside (T value) noexcept |
Heaviside function. | |
template<class T > | |
constexpr std::enable_if_t< std::is_floating_point< T >::value, T > | DefaultEpsilon () noexcept |
Returns a floating-point value that is small enough for most purposes. | |
template<class T > | |
std::enable_if_t< std::is_floating_point< T >::value, bool > | IsZero (T value, T epsilon=DefaultEpsilon< T >()) noexcept |
Check whether a value is close enough to zero to be able to be considered as 0. | |
template<class T > | |
std::enable_if_t< std::is_integral< T >::value, bool > | IsZero (T value) noexcept |
Check whether a value is 0. | |
template<class T > | |
std::enable_if_t< std::is_same< T, LocalMatrix >()||std::is_same< T, LocalVector >(), bool > | IsZero (T value, double epsilon=DefaultEpsilon< double >()) noexcept |
Check whether a LocalVector or a LocalMatrix is filled only by values close enough to zero. | |
bool | IsZero (const LocalVector &vector, double epsilon=DefaultEpsilon< double >()) noexcept |
Check whether a LocalVector is filled with all its values close enough to zero to be able to be considered as 0. | |
bool | IsZero (const LocalMatrix &matrix, double epsilon=DefaultEpsilon< double >()) noexcept |
Check whether a LocalMatrix is filled with all its values close enough to zero to be able to be considered as 0. | |
template<class T > | |
std::enable_if_t< std::is_floating_point< T >::value, bool > | AreEqual (T lhs, T rhs, T epsilon=DefaultEpsilon< T >()) noexcept |
Check whether a value is close enough to another. | |
bool | AreEqual (const LocalVector &lhs, const LocalVector &rhs, double epsilon=DefaultEpsilon< double >()) |
Check whether two LocalVector are filled with all their values close enough to one another. | |
bool | AreEqual (const LocalMatrix &lhs, const LocalMatrix &rhs, double epsilon=DefaultEpsilon< double >()) |
Check whether two LocalMatrix are filled with all their values close enough to one another. | |
template<class T > | |
std::enable_if_t< std::is_same< T, LocalMatrix >()||std::is_same< T, LocalVector >(), bool > | AreEqual (const T &lhs, const T &rhs, double epsilon=DefaultEpsilon< double >()) |
Check whether two LocalVector or LocalMatrix are close enough. | |
template<class T > | |
T | Pow (T base, T exponent, const std::source_location location=std::source_location::current()) |
A wrapper over std::pow which throws whenever an invalid value is computed. | |
Placeholder namespace description needed for it to appear in Doxygen namespace list.
Namespace that enclose numeric utilities (such as IsZero() or AreEqual() used to compared floating-points).
Feel free to replace this text by explanation if namespace name is not self-explaining enough.
|
constexprnoexcept |
When an index is not known at object constructor, better assign a controlled dumb value than not knowing what the compiler decided.
In most cases (typically for instance the initialization of a class attribute) it is a good idea to use it along with decltype:
Doing so makes the code robust to a change of type: if some day index_ becomes a std::size_t rather than an int the default value will keep being the greatest value it can reach.
|
constexprnoexcept |
Computes the square of a value.
T | Type of the value; it is assumed operator* is defined for this type. |
[in] | value | Value upon which the operation is performed. |
|
constexprnoexcept |
Computes the cube of a value.
T | Type of the value; it is assumed operator* is defined for this type. |
[in] | value | Value upon which the operation is performed. |
|
constexprnoexcept |
Computes the 4th power of a value.
T | Type of the value; it is assumed operator* is defined for this type. |
[in] | value | Value upon which the operation is performed. |
|
constexprnoexcept |
Returns value if it is positive or 0 otherwise.
T | Type of the value considered; it must both be initialized with 0 and comes with an operator<. |
[in] | value | Value upon which the operation is performed. |
|
constexprnoexcept |
Returns -1, 0 or 1 depending on the sign of tge value.
[in] | value | Value which sign is evaluated. |
T | Type of the value; 0, 1 and -1 must be convertible to this type and operator< must be defined for it. |
|
constexprnoexcept |
A special version of Sign which considers 0 as positive.
[in] | value | Value which sign is evaluated. |
T | Type of the value; 0, 1 and -1 must be convertible to this type and operator< must be defined for it. |
This is directly lifted from HeartLab code; TrueSign is like the sign except zero is counted as positive.
|
constexprnoexcept |
Heaviside function.
[in] | value | Value which sign is evaluated. |
T | A floating-point type. |
|
constexprnoexcept |
Returns a floating-point value that is small enough for most purposes.
Currently set to 1.e-15 is used here.
T | Type for which the value is required; a double must be convertible into this type. |
|
noexcept |
Check whether a value is close enough to zero to be able to be considered as 0.
T | Floating point type considered (float, double or long double). |
[in] | value | Value that is tested. |
[in] | epsilon | Epsilon used for the comparison. A default value is provided; but the parameter is there if you want to play with it. |
|
noexcept |
Check whether a value is 0.
T | Integral type considered |
[in] | value | Value that is tested. |
For an integral type such a function is trivial but it might be useful from a metaprogramming standpoint.
|
noexcept |
Check whether a LocalVector or a LocalMatrix is filled only by values close enough to zero.
There are in fact dedicated functions to handle the separate cases of Localvector and LocalMatrix, but we wanted to enable the users to make a call such as:
that might be useful in metaprogramming context. Of course current function just calls directly under the hood the other one.
[in] | value | Vector or matrix that is tested. |
[in] | epsilon | Epsilon used for the comparison. A default value is provided; but the parameter is there if you want to play with it. |
|
noexcept |
Check whether a LocalVector is filled with all its values close enough to zero to be able to be considered as 0.
[in] | vector | Vector that is tested. |
[in] | epsilon | Epsilon used for the comparison. A default value is provided; but the parameter is there if you want to play with it. |
|
noexcept |
Check whether a LocalMatrix is filled with all its values close enough to zero to be able to be considered as 0.
[in] | matrix | Matrix that is tested. |
[in] | epsilon | Epsilon used for the comparison. A default value is provided; but the parameter is there if you want to play with it. |
|
noexcept |
Check whether a value is close enough to another.
T | Floating point type considered (float, double or long double). |
[in] | lhs | Lhs value. |
[in] | rhs | Rhs value. |
[in] | epsilon | Epsilon used for the comparison. A default value is provided; but the parameter is there if you want to play with it. |
bool MoReFEM::NumericNS::AreEqual | ( | const LocalVector & | lhs, |
const LocalVector & | rhs, | ||
double | epsilon = DefaultEpsilon< double >() ) |
Check whether two LocalVector are filled with all their values close enough to one another.
If the vectors aren't the same size, an exception is thrown.
[in] | lhs | First vector to be tested. |
[in] | rhs | Second vector to be tested. |
[in] | epsilon | Epsilon used for the comparison. A default value is provided; but the parameter is there if you want to play with it. |
bool MoReFEM::NumericNS::AreEqual | ( | const LocalMatrix & | lhs, |
const LocalMatrix & | rhs, | ||
double | epsilon = DefaultEpsilon< double >() ) |
Check whether two LocalMatrix are filled with all their values close enough to one another.
If the matrices aren't the same dimension, an exception is thrown.
[in] | lhs | First matrix to be tested. |
[in] | rhs | Second matrix to be tested. |
[in] | epsilon | Epsilon used for the comparison. A default value is provided; but the parameter is there if you want to play with it. |
std::enable_if_t< std::is_same< T, LocalMatrix >()||std::is_same< T, LocalVector >(), bool > MoReFEM::NumericNS::AreEqual | ( | const T & | lhs, |
const T & | rhs, | ||
double | epsilon = DefaultEpsilon< double >() ) |
Check whether two LocalVector or LocalMatrix are close enough.
[in] | lhs | First linear algebra to be tested. |
[in] | rhs | Second linear algebra to be tested. Must be the same shape as the first one (or an exception is thrown). |
[in] | epsilon | Epsilon used for the comparison (absolute tolerance). A default value is provided; but the parameter is there if you want to play with it. |
There are in fact dedicated functions to handle the separate cases of LocalVector and LocalMatrix, but we wanted to enable the users to make a call such as:
that might be useful in metaprogramming context. Of course current function just calls directly under the hood the other one.
T MoReFEM::NumericNS::Pow | ( | T | base, |
T | exponent, | ||
const std::source_location | location = std::source_location::current() ) |
A wrapper over std::pow
which throws whenever an invalid value is computed.
std::pow
handles its errors by:
nan
T | Any floating-point type (less powerful than std::pow on this regard but at the moment no need to consider other types). |
[in] | base | Base value |
[in] | exponent | Exponent |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
nan
: if the computation is invalid an exception should be thrown.