![]() |
0.3.0
|
Simple Math functions. More...
Go to the source code of this file.
Classes | |
struct | NAV::math::LerpSearchResult |
Lerp Search Result. More... | |
Functions | |
auto | NAV::math::bilinearInterpolation (const auto &tx, const auto &ty, const auto &c00, const auto &c10, const auto &c01, const auto &c11) |
Bilinear interpolation. | |
double | NAV::math::calcEllipticalIntegral (double phi, double m) |
Calculates the incomplete elliptical integral of the second kind. | |
template<std::floating_point T> | |
T | NAV::math::csc (const T &x) |
Calculates the cosecant of a value (csc(x) = sec(pi/2 - x) = 1 / sin(x)) | |
template<typename Derived> | |
Derived::PlainObject | NAV::math::expm (const Eigen::MatrixBase< Derived > &X, size_t order) |
Calculates the state transition matrix 𝚽 limited to specified order in 𝐅𝜏ₛ | |
uint64_t | NAV::math::factorial (uint64_t n) |
Calculates the factorial of an unsigned integer. | |
template<std::integral Out, size_t Bits, std::integral In> | |
constexpr Out | NAV::math::interpretAs (In in) |
Interprets the input integer with certain amount of Bits as Output type. Takes care of sign extension. | |
template<typename Derived> | |
Derived::PlainObject | NAV::math::inverseSqrt (const Eigen::MatrixBase< Derived > &matrix) |
Returns the inverse square root of a matrix. | |
template<typename Derived> | |
Derived::PlainObject | NAV::math::lerp (const Eigen::MatrixBase< Derived > &a, const Eigen::MatrixBase< Derived > &b, auto t) |
Linear interpolation between vectors. | |
LerpSearchResult | NAV::math::lerpSearch (const auto &data, const auto &value) |
Searches the value in the data container. | |
template<typename Derived> | |
std::optional< std::pair< Eigen::Matrix< typename Derived::Scalar, Derived::RowsAtCompileTime, Derived::ColsAtCompileTime >, Eigen::Vector< typename Derived::Scalar, Derived::RowsAtCompileTime > > > | NAV::math::LtDLdecomp_choleskyFact (const Eigen::MatrixBase< Derived > &Q) |
Find (L^T D L)-decomposition of Q-matrix via a backward Cholesky factorization in a bordering method formulation. | |
template<typename Derived> | |
std::optional< std::pair< Eigen::Matrix< typename Derived::Scalar, Derived::RowsAtCompileTime, Derived::ColsAtCompileTime >, Eigen::Vector< typename Derived::Scalar, Derived::RowsAtCompileTime > > > | NAV::math::LtDLdecomp_outerProduct (const Eigen::MatrixBase< Derived > &Qmatrix) |
Find (L^T D L)-decomposition of Q-matrix via outer product method. | |
double | NAV::math::normalCDF (double value) |
Calculates the cumulative distribution function (CDF) of the standard normal distribution. | |
template<std::floating_point T> | |
constexpr T | NAV::math::round (const T &value, size_t digits) |
Round the number to the specified amount of digits. | |
template<std::floating_point T> | |
constexpr T | NAV::math::roundSignificantDigits (T value, size_t digits) |
Round the number to the specified amount of significant digits. | |
template<std::floating_point T> | |
T | NAV::math::sec (const T &x) |
Calculates the secant of a value (sec(x) = csc(pi/2 - x) = 1 / cos(x)) | |
template<typename T> | |
int | NAV::math::sgn (const T &val) |
Returns the sign of the given value. | |
template<typename T> | |
T | NAV::math::sign (const T &x, const T &y) |
Change the sign of x according to the value of y. | |
template<typename Derived> | |
Eigen::Matrix< typename Derived::Scalar, 3, 3 > | NAV::math::skewSymmetricMatrix (const Eigen::MatrixBase< Derived > &a) |
Calculates the skew symmetric matrix of the given vector. This is needed to perform the cross product with a scalar product operation. | |
template<typename Derived> | |
Eigen::Matrix< typename Derived::Scalar, 3, 3 > | NAV::math::skewSymmetricMatrixSquared (const Eigen::MatrixBase< Derived > &a) |
Calculates the square of a skew symmetric matrix of the given vector. | |
template<typename DerivedA, typename DerivedQ> | |
DerivedA::Scalar | NAV::math::squaredNormVectorMatrix (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedQ > &Q) |
Calculates the squared norm of the vector and matrix. | |
Simple Math functions.
auto NAV::math::bilinearInterpolation | ( | const auto & | tx, |
const auto & | ty, | ||
const auto & | c00, | ||
const auto & | c10, | ||
const auto & | c01, | ||
const auto & | c11 ) |
Bilinear interpolation.
[in] | tx | Distance in x component to interpolate [0, 1] |
[in] | ty | Distance in y component to interpolate [0, 1] |
[in] | c00 | Value for tx = ty = 0 |
[in] | c10 | Value for tx = 1 and ty = 0 |
[in] | c01 | Value for tx = 0 and ty = 1 |
[in] | c11 | Value for tx = ty = 1 |
c01 ---— c11
c00 ---— c10
double NAV::math::calcEllipticalIntegral | ( | double | phi, |
double | m ) |
Calculates the incomplete elliptical integral of the second kind.
[in] | phi | Interval bound the integration uses from 0 to phi |
[in] | m | Function parameter that is integrated 1-m*sin(t)^2 |
Derived::PlainObject NAV::math::expm | ( | const Eigen::MatrixBase< Derived > & | X, |
size_t | order ) |
Calculates the state transition matrix 𝚽 limited to specified order in 𝐅𝜏ₛ
[in] | X | Matrix |
[in] | order | The order of the Taylor polynom to calculate |
uint64_t NAV::math::factorial | ( | uint64_t | n | ) |
Calculates the factorial of an unsigned integer.
[in] | n | Unsigned integer |
|
constexpr |
Interprets the input integer with certain amount of Bits as Output type. Takes care of sign extension.
Out | Output type |
Bits | Size of the input data |
In | Input data type (needs to be bigger than the amount of Bits) |
[in] | in | Number as two's complement, with the sign bit (+ or -) occupying the MSB |
|
nodiscard |
Returns the inverse square root of a matrix.
matrix | Matrix to use |
Derived::PlainObject NAV::math::lerp | ( | const Eigen::MatrixBase< Derived > & | a, |
const Eigen::MatrixBase< Derived > & | b, | ||
auto | t ) |
Linear interpolation between vectors.
a | Left value |
b | Right value |
t | Multiplier. [0, 1] for interpolation |
LerpSearchResult NAV::math::lerpSearch | ( | const auto & | data, |
const auto & | value ) |
Searches the value in the data container.
[in] | data | Data container |
[in] | value | Value to search |
std::optional< std::pair< Eigen::Matrix< typename Derived::Scalar, Derived::RowsAtCompileTime, Derived::ColsAtCompileTime >, Eigen::Vector< typename Derived::Scalar, Derived::RowsAtCompileTime > > > NAV::math::LtDLdecomp_choleskyFact | ( | const Eigen::MatrixBase< Derived > & | Q | ) |
Find (L^T D L)-decomposition of Q-matrix via a backward Cholesky factorization in a bordering method formulation.
[in] | Q | Symmetric positive definite matrix to be factored |
std::optional< std::pair< Eigen::Matrix< typename Derived::Scalar, Derived::RowsAtCompileTime, Derived::ColsAtCompileTime >, Eigen::Vector< typename Derived::Scalar, Derived::RowsAtCompileTime > > > NAV::math::LtDLdecomp_outerProduct | ( | const Eigen::MatrixBase< Derived > & | Qmatrix | ) |
Find (L^T D L)-decomposition of Q-matrix via outer product method.
[in] | Qmatrix | Symmetric positive definite matrix to be factored |
double NAV::math::normalCDF | ( | double | value | ) |
|
constexpr |
Round the number to the specified amount of digits.
[in] | value | Value to round |
[in] | digits | Amount of digits |
|
constexpr |
Round the number to the specified amount of significant digits.
[in] | value | Value to round |
[in] | digits | Amount of digits |
int NAV::math::sgn | ( | const T & | val | ) |
Returns the sign of the given value.
[in] | val | Value to get the sign from |
T NAV::math::sign | ( | const T & | x, |
const T & | y ) |
Change the sign of x according to the value of y.
[in] | x | input value |
[in] | y | input value |
Eigen::Matrix< typename Derived::Scalar, 3, 3 > NAV::math::skewSymmetricMatrix | ( | const Eigen::MatrixBase< Derived > & | a | ) |
Calculates the skew symmetric matrix of the given vector. This is needed to perform the cross product with a scalar product operation.
Derived | Derived Eigen Type |
[in] | a | The vector |
Eigen::Matrix< typename Derived::Scalar, 3, 3 > NAV::math::skewSymmetricMatrixSquared | ( | const Eigen::MatrixBase< Derived > & | a | ) |
Calculates the square of a skew symmetric matrix of the given vector.
Derived | Derived Eigen Type |
[in] | a | The vector |
DerivedA::Scalar NAV::math::squaredNormVectorMatrix | ( | const Eigen::MatrixBase< DerivedA > & | a, |
const Eigen::MatrixBase< DerivedQ > & | Q ) |