Rodin::Math module

Spatial arithmetic, matrix operations, and sparse linear algebra.

SpatialVector<T> and SpatialMatrix<T> support small spatial calculations without heap allocation. Vector<T>, Matrix<T>, and their fixed-size counterparts provide Eigen-compatible algebra; LinearSystem<Operator, Vector> groups system data and constraint elimination. These types support geometric mappings, constitutive calculations, assembly, and linear solves.

Types

SymbolTypeDescription
$ x \in \mathbb{K}^{n},\ n \in \mathbb{N} $ Vector<T>Dynamic dense column vector (Eigen-based)
$ A \in \mathbb{K}^{m \times n},\ m,n \in \mathbb{N} $ Matrix<T>Dynamic dense matrix (Eigen-based)
$ \begin{gathered} A_{\mathrm{CSC}} \in \mathbb{K}^{m \times n} \\ (A_{\mathrm{CSC}})_{r_k,j}=v_k,\ p_j \leq k < p_{j+1} \end{gathered} $ SparseMatrix<T>CSC sparse matrix with values $ v_k $ ;
row indices $ r_k $ ;
column offsets $ p_j $ .
$ x \in \mathbb{K}^{n},\ n \in \mathbb{N},\ n\text{ fixed} $ FixedSizeVector<T, Size>Dense vector with its dimension fixed at compile time
$ A \in \mathbb{K}^{m \times n},\ m,n \in \mathbb{N},\ m,n\text{ fixed} $ FixedSizeMatrix<T, Rows, Cols>Dense matrix with its dimensions fixed at compile time
$ x \in \mathbb{K}^{n},\ n \leq 3 $ SpatialVector<T>Small vector with runtime dimension for physical coordinates
$ A \in \mathbb{K}^{m \times n},\ m,n \leq 3 $ SpatialMatrix<T>Small matrix with runtime dimensions for Jacobians and stress tensors
$ A x = b $ LinearSystem<Operator, Vector>Groups an operator, solution vector, and right-hand side for a linear solve

Here, $ \mathbb{K} $ is either the real field $ \mathbb{R} $ or the complex field $ \mathbb{C} $ .

Constants

SymbolFunctionDescription
$ \pi $ Constants::pi()Ratio of a circle's circumference to its diameter.

Mathematical functions

SymbolFunctionDomainDescription
$ \lvert x \rvert $ abs(x)Scalar or matrixAbsolute value or magnitude
$ e^x $ exp(x)Scalar or matrixExponential function
$ \sqrt{x} $ sqrt(x)Scalar or matrixSquare root
$ x^y $ pow(x, y)Scalar or matrixPower function
$ x^2 $ pow2(x)Scalar or matrixSquare of a value
$ \ln x $ log(x)ScalarNatural logarithm
$ \log_2 x $ log2(x)ScalarBase-2 logarithm
$ \log_{10} x $ log10(x)ScalarBase-10 logarithm
$ \sin x $ sin(x)Scalar or matrixSine
$ \cos x $ cos(x)Scalar or matrixCosine
$ \tan x $ tan(x)Scalar or matrixTangent
$ \arcsin x $ asin(x)Scalar, $ x \in [-1, 1] $ Inverse sine in radians
$ \arccos x $ acos(x)Scalar, $ x \in [-1, 1] $ Inverse cosine in radians
$ \arctan x $ atan(x)ScalarInverse tangent in radians
$ \operatorname{atan2}(y, x) $ atan2(y, x)Two real scalar argumentsTwo-argument inverse tangent in radians
$ \sinh x $ sinh(x)Scalar or matrixHyperbolic sine
$ \cosh x $ cosh(x)Scalar or matrixHyperbolic cosine
$ \tanh x $ tanh(x)Scalar or matrixHyperbolic tangent
$ \min(a, b) $ min(a, b)Comparable valuesSmaller of two values
$ \max(a, b) $ max(a, b)Comparable valuesLarger of two values
$ \operatorname{clamp}(x, lo, hi) $ clamp(x, lo, hi)Comparable valuesRestricts a value to the given bounds

Unit types

SymbolTypeDescription
$ \theta\,\mathrm{rad} $ RadRadian wrapper with explicit conversion to Real
$ \theta^{\circ} $ DegDegree wrapper with conversion to Rad

Runge–Kutta schemes

SymbolMethodOrderDescription
$ q_{n+1}=q_n+\Delta t\,k_2 $ RungeKutta::RK22Midpoint method
$ q_{n+1}=q_n+\frac{\Delta t}{6}(k_1+2k_2+2k_3+k_4) $ RungeKutta::RK44Classical Runge-Kutta method

Root finding

SymbolMethodDescription
$ x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)} $ RootFinding::NewtonRaphson<Scalar>Finds scalar roots with a safeguarded Newton iteration, interval bracketing, and bisection fallback

Linear algebra utilities

OperationFunctionDescription
$ a \cdot b $ dot(a, b)Inner product; conjugates the right operand for complex values
$ a \times b $ a.cross(b)Three-dimensional cross product
$ a + b $ sum(a, b)Adds two values
$ a - b $ minus(a, b)Subtracts two values; minus(a) negates one value
$ a b $ mult(a, b)Multiplies two values
$ a / b $ division(a, b)Divides one value by another
$ \overline{a} $ conj(a)Computes the complex conjugate
$ \mathrm{NaN} $ nan<T>()Returns a quiet NaN sentinel of type T

Usage

Include <Rodin/Math.h> and <utility> for these examples. The names below assume using namespace Rodin; and using namespace Rodin::Math;.

Spatial arithmetic

Small spatial vectors support scalar products, cross products, and norms.

SpatialVector<Real> a{1, 2, 3};
SpatialVector<Real> b{4, 5, 6};
const Real product = dot(a, b);       // 32
const auto normal = a.cross(b);      // {-3, 6, -3}
const Real length = a.norm();        // sqrt(14)

Dense and fixed-size algebra

Dynamic and fixed-size types support Eigen-compatible initialization and expressions. Store an expression in a concrete type to retain its result.

Matrix<Real> A(2, 2);
A << 2, -1,
    -1,  2;
Vector<Real> x(2);
x << 1, 2;
Vector<Real> y = A * x;              // {0, 3}

FixedSizeMatrix<Real, 2, 2> fixedA = A;
FixedSizeVector<Real, 2> fixedX = x;
FixedSizeVector<Real, 2> fixedY = fixedA * fixedX;

Sparse matrices

Insert entries and compress the matrix before using its CSC storage.

SparseMatrix<Real> A(3, 3);
A.insert(0, 0) = 2;
A.insert(1, 1) = 3;
A.insert(2, 2) = 4;
A.makeCompressed();

Vector<Real> x = Vector<Real>::Ones(3);
Vector<Real> y = A * x;              // {2, 3, 4}

Complex scalar products

The scalar product conjugates its right-hand operand.

\[ a\cdot b=\sum_i a_i\overline{b_i}. \]
SpatialVector<Complex> a{Complex(1, 1), Complex(2, 0)};
SpatialVector<Complex> b{Complex(0, 1), Complex(3, 0)};
const Complex product = dot(a, b);   // 7 - i

Angles and constants

Convert degrees to radians explicitly; mathematical functions accept the underlying scalar value.

const Rad angle = Deg(180).toRad();
const Real radians = Real(angle);    // pi
const Real halfTurn = Constants::pi();
const Real sine = sin(radians);      // approximately zero

Time integration

Advance $ \dot{q}=-q $ by one time step with the classical fourth-order Runge-Kutta method. Supply the current state separately from the output.

const Real current = 1;
Real next = 0;
RungeKutta::RK4 integrator;
integrator.step(next, 0.1, current, [](Real q) { return -q; });
// next approximates exp(-0.1).

Scalar root finding

Find $ \sqrt{2} $ by solving $ f(x)=x^2-2=0 $ in a bracket. The callable returns the function value and derivative; the result is an Optional containing the root when the iteration succeeds.

RootFinding::NewtonRaphson<Real> solver;
const auto root = solver.solve(
  [](Real x) { return std::make_pair(x * x - 2, 2 * x); },
  1.5, 1.0, 2.0);

Classes

class Deg
Represents an angle in degrees.
template<class Operator, class Vector>
class LinearSystem
Represents a linear system of equations.
See specializations
SpecializationDescription
Math::SparseMatrix<MatrixScalar>, Math::Vector<VectorScalar>
Full specialization
template <
  class MatrixScalar,
  class VectorScalar>
class LinearSystem<
  Math::SparseMatrix< MatrixScalar >,
  Math::Vector< VectorScalar >>;
Linear system specialization for sparse matrices.
Math::Matrix<MatrixScalar>, Math::Vector<VectorScalar>
Full specialization
template <
  class MatrixScalar,
  class VectorScalar>
class LinearSystem<
  Math::Matrix< MatrixScalar >,
  Math::Vector< VectorScalar >>;
Linear system specialization for dense matrices.
::Mat, ::Vec
Full specialization
template <>
class LinearSystem<
  ::Mat,
  ::Vec>;
Specialization of LinearSystem for PETSc objects (Mat and Vec).
template<class ScalarType>
class Matrix
Dynamic-size dense matrix.
template<class ScalarType, size_t Rows, size_t Cols>
class FixedSizeMatrix
Compile-time fixed-size dense matrix.
template<class ScalarType>
class Vector
Dynamic-size dense vector.
template<class ScalarType, size_t Size>
class FixedSizeVector
Compile-time fixed-size dense vector.
template<class ScalarType>
class SpatialVector
Spatial vector with bounded maximum size.
template<class ScalarType>
class SpatialMatrix
Spatial matrix with bounded maximum dimensions.
template<class ScalarType, size_t Rank>
class SpatialTensor
A rank-R spatial tensor with stack storage and runtime extents.
template<class Matrix, class Vector, class Derived>
class LinearSystemBase
Base class for linear systems of the form $ Ax = b $ .
class Rad
Represents an angle in radians.
template<class Derived, class T>
class Unit
Base class for units using CRTP.

Typedefs

using RealMatrix = Matrix<Real>
Real-valued dense matrix.
using ComplexMatrix = Matrix<Complex>
Complex-valued dense matrix.
using SparseIndex = std::int32_t
Signed 32-bit index type used by sparse matrix storage.
template<class ScalarType>
using SparseTriplet = Eigen::Triplet<ScalarType, SparseIndex>
Sparse matrix entry used during assembly.
template<class ScalarType>
using SparseMatrix = Eigen::SparseMatrix<ScalarType, Eigen::ColMajor, SparseIndex>
Sparse matrix type.
using SpatialPoint = SpatialVector<Real>
Real-valued spatial vector for point coordinates.
using ComplexVector = Vector<Complex>
Dynamic-size complex-valued vector.
template<class ScalarType>
using Vector2 = FixedSizeVector<ScalarType, 2>
2D fixed-size vector.
template<class ScalarType>
using Vector3 = FixedSizeVector<ScalarType, 3>
3D fixed-size vector.
template<class ScalarType>
using Vector4 = FixedSizeVector<ScalarType, 4>
4D fixed-size vector.
template<class ScalarType>
using Vector8 = FixedSizeVector<ScalarType, 8>
8D fixed-size vector.
template<class ScalarType>
using Vector16 = FixedSizeVector<ScalarType, 16>
16D fixed-size vector.
template<class ScalarType>
using Vector32 = FixedSizeVector<ScalarType, 32>
32D fixed-size vector.
template<class ScalarType>
using Vector64 = FixedSizeVector<ScalarType, 64>
64D fixed-size vector.
template<class ScalarType>
using Vector128 = FixedSizeVector<ScalarType, 128>
128D fixed-size vector.

Functions

template<class T>
auto abs(const T& x) -> auto constexpr
Computes the absolute value of a value.
template<class Scalar>
auto abs(const Scalar& x) -> Eigen::NumTraits<Scalar>::Real
Computes the real magnitude of a complex scalar.
template<class T>
auto exp(const T& x) -> auto constexpr
Computes the exponential function.
template<class Scalar>
auto conj(const Scalar& x) -> Scalar constexpr
Computes the complex conjugate of a complex number.
template<class T>
auto conj(const Eigen::MatrixBase<T>& x) -> auto constexpr
Computes the conjugate of an Eigen matrix.
template<class Scalar>
auto conj(const Scalar& x) -> Scalar constexpr
Identity conjugate for real numbers.
template<class Scalar>
auto conj(const SpatialVector<Scalar>& value) -> auto
Conjugates each active component of a spatial vector.
template<class Scalar>
auto conj(const SpatialMatrix<Scalar>& value) -> auto
Conjugates each active entry of a spatial matrix.
template<class Base>
auto pow2(const Base& base) -> auto constexpr
Computes the square of a value.
template<size_t N, class Base>
auto pow(const Base& x) -> Base constexpr
Computes the compile-time integer power.
template<class Base, size_t N>
auto pow(const Base& x, std::integral_constant<size_t, N> orderTag) -> Base constexpr
Computes the compile-time integer power via integral_constant.
template<class Base, class Exponent>
auto pow(const Base& base, const Exponent& exponent) -> auto constexpr
Computes a power with arbitrary exponent.
template<class T>
auto sqrt(const T& x) -> auto constexpr
Computes the square root of a value.
template<class T>
auto isNaN(const T& x) -> Boolean constexpr
Determines if a floating point number is not-a-number (NaN).
auto isNaN(const Complex& x) -> Boolean constexpr
Determines if a complex number is not-a-number (NaN).
template<class T>
auto isInf(const T& x) -> Boolean constexpr
Determines if a floating point number is infinite.
template<class T>
auto cos(const T& x) -> auto constexpr
Computes the cosine function.
template<class T>
auto cosh(const T& x) -> auto constexpr
Computes the hyperbolic cosine function.
template<class T>
auto sin(const T& x) -> auto constexpr
Computes the sine function.
template<class T>
auto sinh(const T& x) -> auto constexpr
Computes the hyperbolic sine function.
template<class T>
auto tan(const T& x) -> auto constexpr
Computes the tangent function.
template<typename T>
auto sgn(const T& x) -> T constexpr
Computes the sign (signum) function.
template<class T>
auto binom(const T& n, const T& k) -> T constexpr
Computes the binomial coefficient.
template<class T>
auto factorial(const T& n) -> T constexpr
Computes the factorial function.
template<class T>
auto permutation(const T& n, const T& k) -> T constexpr
Computes the permutation function.
template<class T>
auto nan() -> auto constexpr
Returns a quiet NaN (not-a-number) value.
template<class LHS, class RHS>
auto sum(const LHS& lhs, const RHS& rhs) -> auto constexpr
Computes the sum of two values.
template<class Operand>
auto minus(const Operand& op) -> auto constexpr
Computes the unary minus (negation).
template<class LHS, class RHS>
auto minus(const LHS& lhs, const RHS& rhs) -> auto constexpr
Computes the difference of two values.
template<class LHS, class RHS>
auto mult(const LHS& lhs, const RHS& rhs) -> auto constexpr
Computes the product of two values.
template<class LHS, class RHS>
auto division(const LHS& lhs, const RHS& rhs) -> auto constexpr
Computes the division of two values.
template<class Left, class Right>
auto dot(const Left& lhs, const Right& rhs) -> auto constexpr
Multiplies two real scalars.
dot
Multiplies complex scalars, conjugating the right operand.
See declaration
template<class Left, class Right>
auto dot(const std::complex<Left>& lhs, const std::complex<Right>& rhs) -> auto constexpr
template<class Left, class Right>
auto dot(const Left& lhs, const std::complex<Right>& rhs) -> auto constexpr
Multiplies real and complex scalars, conjugating the right operand.
template<class Left, class Right>
auto dot(const std::complex<Left>& lhs, const Right& rhs) -> auto constexpr
Multiplies complex and real scalars.
dot
Computes the dot product of two Eigen vectors/matrices.
See declaration
template<class LHSDerived, class RHSDerived>
auto dot(const Eigen::MatrixBase<LHSDerived>& lhs, const Eigen::MatrixBase<RHSDerived>& rhs) -> auto constexpr
dot
Computes the dot product of two SpatialVector objects.
See declaration
template<class LHSScalar, class RHSScalar>
auto dot(const SpatialVector<LHSScalar>& lhs, const SpatialVector<RHSScalar>& rhs) -> auto constexpr
dot
Computes the dot product of two SpatialMatrix objects.
See declaration
template<class LHSScalar, class RHSScalar>
auto dot(const SpatialMatrix<LHSScalar>& lhs, const SpatialMatrix<RHSScalar>& rhs) -> auto constexpr
dot
Computes the dot product of an Eigen vector and a SpatialVector.
See declaration
template<class LHSDerived, class RHSScalar>
auto dot(const Eigen::MatrixBase<LHSDerived>& lhs, const Math::SpatialVector<RHSScalar>& rhs) -> auto constexpr
dot
Computes the dot product of a SpatialVector and an Eigen vector.
See declaration
template<class LHSScalar, class RHSDerived>
auto dot(const Math::SpatialVector<LHSScalar>& lhs, const Eigen::MatrixBase<RHSDerived>& rhs) -> auto constexpr
dot
Computes the dot product of an Eigen matrix and a SpatialMatrix.
See declaration
template<class LHSDerived, class RHSScalar>
auto dot(const Eigen::MatrixBase<LHSDerived>& lhs, const Math::SpatialMatrix<RHSScalar>& rhs) -> auto constexpr
dot
Computes the dot product of a SpatialMatrix and an Eigen matrix.
See declaration
template<class LHSScalar, class RHSDerived>
auto dot(const Math::SpatialMatrix<LHSScalar>& lhs, const Eigen::MatrixBase<RHSDerived>& rhs) -> auto constexpr
template<class T>
auto log(const T& x) -> auto constexpr
Computes the natural logarithm.
template<class T>
auto log2(const T& x) -> auto constexpr
Computes the base-2 logarithm.
template<class T>
auto log10(const T& x) -> auto constexpr
Computes the base-10 logarithm.
template<class T>
auto acos(const T& x) -> auto constexpr
Computes the arc cosine (inverse cosine).
template<class T>
auto asin(const T& x) -> auto constexpr
Computes the arc sine (inverse sine).
template<class T>
auto atan(const T& x) -> auto constexpr
Computes the arc tangent (inverse tangent).
template<class T>
auto atan2(const T& y, const T& x) -> auto constexpr
Computes the two-argument arc tangent.
template<class T>
auto tanh(const T& x) -> auto constexpr
Computes the hyperbolic tangent function.
template<class T>
auto min(const T& a, const T& b) -> auto constexpr
Returns the minimum of two values.
template<class T>
auto max(const T& a, const T& b) -> auto constexpr
Returns the maximum of two values.
template<class T>
auto clamp(const T& x, const T& lo, const T& hi) -> auto constexpr
Clamps a value to the range $ [\text{lo}, \text{hi}] $ .
dot
Frobenius contraction of spatial tensors, conjugating the RHS.
See declaration
template<class LHSScalar, class RHSScalar, size_t Rank>
auto dot(const SpatialTensor<LHSScalar, Rank>& lhs, const SpatialTensor<RHSScalar, Rank>& rhs) -> auto
template<class Scalar, size_t Rank>
auto conj(const SpatialTensor<Scalar, Rank>& value) -> auto
Entrywise tensor conjugation.
template<std::size_t I, class Matrix, class Vector>
auto get(LinearSystem<Matrix, Vector>& ls) -> decltype(auto)
Accesses element I of ls for structured binding. (0 = operator $ A $ , 1 = solution $ x $ , 2 = right-hand side $ b $ ).
template<std::size_t I, class Matrix, class Vector>
auto get(const LinearSystem<Matrix, Vector>& ls) -> decltype(auto)
Structured-binding accessor (const overload); see get(LinearSystem&).
template<std::size_t I, class Matrix, class Vector>
auto get(LinearSystem<Matrix, Vector>&& ls) -> decltype(auto)
Structured-binding accessor (rvalue overload); moves out element I.
template<std::size_t I, class Matrix, class Vector>
auto get(const LinearSystem<Matrix, Vector>&& ls) -> decltype(auto)
Structured-binding accessor (const rvalue overload); see get(LinearSystem&&).
axpy
Performs the AXPY operation on sparse matrices.
See declaration
template<class AScalarType, class YScalarType, class XScalarType>
void axpy(SparseMatrix<YScalarType>& y, AScalarType alpha, const SparseMatrix<XScalarType>& x)
operator*
Scalar-times-matrix product with real/complex promotion. Arithmetic coefficients are converted to Real for a complex matrix, preserving real-times-complex arithmetic rather than complexifying them.
See declaration
template<class LHSScalar, class RHSScalar>
auto operator*(const LHSScalar& value, const SpatialMatrix<RHSScalar>& A) -> auto noexcept
operator*
Matrix-times-vector product, returned as a single-column matrix.
See declaration
template<class LHSScalar, class RHSScalar>
auto operator*(const SpatialMatrix<LHSScalar>& A, const Math::Vector<RHSScalar>& s) -> SpatialMatrix<typename FormLanguage::Mult<LHSScalar, RHSScalar>::Type> noexcept
operator*
Matrix-times-scalar product with real/complex promotion.
See declaration
template<class LHSScalar, class RHSScalar>
auto operator*(const SpatialMatrix<LHSScalar>& A, const RHSScalar& value) -> auto noexcept
operator*
Matrix-matrix product with real/complex promotion.
See declaration
template<class LHSScalar, class RHSScalar>
auto operator*(const SpatialMatrix<LHSScalar>& A, const SpatialMatrix<RHSScalar>& B) -> SpatialMatrix<typename FormLanguage::Mult<LHSScalar, RHSScalar>::Type> noexcept
operator+
Computes the element-wise sum of two spatial matrices.
See declaration
template<class Scalar>
auto operator+(const SpatialMatrix<Scalar>& A, const SpatialMatrix<Scalar>& B) -> SpatialMatrix<Scalar>
operator-
Computes the element-wise difference of two spatial matrices.
See declaration
template<class Scalar>
auto operator-(const SpatialMatrix<Scalar>& A, const SpatialMatrix<Scalar>& B) -> SpatialMatrix<Scalar>
operator*
Matrix-times-vector product.
See declaration
template<class LHSScalar, class RHSScalar>
auto operator*(const SpatialMatrix<LHSScalar>& A, const SpatialVector<RHSScalar>& x) -> SpatialVector<typename FormLanguage::Mult<LHSScalar, RHSScalar>::Type> noexcept
operator*
Row-vector-times-matrix product, returned as a single-row matrix.
See declaration
template<class Scalar>
auto operator*(const SpatialVector<Scalar>& v, const SpatialMatrix<Scalar>& m) -> SpatialMatrix<Scalar> noexcept
operator*
Product of an Eigen matrix expression and a spatial matrix.
See declaration
template<class EigenDerived, class Scalar>
auto operator*(const Eigen::MatrixBase<EigenDerived>& s, const SpatialMatrix<Scalar>& m) -> auto
operator*
Product of a spatial matrix and an Eigen matrix expression.
See declaration
template<class Scalar, class EigenDerived>
auto operator*(const SpatialMatrix<Scalar>& m, const Eigen::MatrixBase<EigenDerived>& s) -> auto
template<class Scalar>
auto operator*(const SpatialMatrix<Scalar>& m, const Math::Vector<Scalar>& v) -> auto
Matrix-times-(dynamic)-vector product.
operator+
Componentwise sum of a spatial matrix and an Eigen matrix expression.
See declaration
template<class Scalar, class EigenDerived>
auto operator+(const SpatialMatrix<Scalar>& A, const Eigen::MatrixBase<EigenDerived>& B) -> SpatialMatrix<Scalar>
operator+
Componentwise sum of an Eigen matrix expression and a spatial matrix.
See declaration
template<class EigenDerived, class Scalar>
auto operator+(const Eigen::MatrixBase<EigenDerived>& A, const SpatialMatrix<Scalar>& B) -> SpatialMatrix<Scalar>
template<class Scalar>
auto operator<<(std::ostream& os, const SpatialMatrix<Scalar>& m) -> std::ostream&
Streams the matrix's active block to an output stream.
template<class Scalar, class Value>
auto operator/(const SpatialMatrix<Scalar>& matrix, const Value& divisor) -> auto
Divide every active matrix entry by a scalar.
operator*
Scales every active tensor entry with scalar type promotion.
See declaration
template<class Value, class Scalar, size_t Rank>
auto operator*(const Value& factor, const SpatialTensor<Scalar, Rank>& tensor) -> auto
operator+
Componentwise sum of two spatial vectors.
See declaration
template<class Scalar>
auto operator+(const SpatialVector<Scalar>& a, const SpatialVector<Scalar>& b) -> SpatialVector<Scalar> noexcept
operator-
Componentwise difference of two spatial vectors.
See declaration
template<class Scalar>
auto operator-(const SpatialVector<Scalar>& a, const SpatialVector<Scalar>& b) -> SpatialVector<Scalar> noexcept
template<class LHS, class Scalar>
auto operator*(const LHS& value, const SpatialVector<Scalar>& v) -> auto noexcept
Scalar-times-vector product with real/complex promotion.
template<class Scalar, class RHS>
auto operator*(const SpatialVector<Scalar>& v, const RHS& value) -> auto
Vector-times-scalar product with real/complex promotion.
operator/
Vector-divided-by-scalar product.
See declaration
template<class Scalar, class RHS>
auto operator/(const SpatialVector<Scalar>& v, const RHS& s) -> SpatialVector<Scalar> noexcept
operator+
Componentwise sum of an Eigen vector expression and a spatial vector.
See declaration
template<class EigenDerived, class Scalar>
auto operator+(const Eigen::MatrixBase<EigenDerived>& a, const SpatialVector<Scalar>& b) -> SpatialVector<Scalar>
operator+
Componentwise sum of a spatial vector and an Eigen vector expression.
See declaration
template<class Scalar, class EigenDerived>
auto operator+(const SpatialVector<Scalar>& a, const Eigen::MatrixBase<EigenDerived>& b) -> SpatialVector<Scalar>
operator-
Componentwise difference of an Eigen vector expression and a spatial vector.
See declaration
template<class EigenDerived, class Scalar>
auto operator-(const Eigen::MatrixBase<EigenDerived>& a, const SpatialVector<Scalar>& b) -> auto
operator-
Componentwise difference of a spatial vector and an Eigen vector expression.
See declaration
template<class Scalar, class EigenDerived>
auto operator-(const SpatialVector<Scalar>& a, const Eigen::MatrixBase<EigenDerived>& b) -> auto
operator*
Row-vector-times-matrix product with an Eigen matrix expression.
See declaration
template<class Scalar, class EigenDerived>
auto operator*(const SpatialVector<Scalar>& v, const Eigen::MatrixBase<EigenDerived>& m) -> auto
operator*
Matrix-times-vector product with an Eigen matrix expression.
See declaration
template<class EigenDerived, class Scalar>
auto operator*(const Eigen::MatrixBase<EigenDerived>& m, const SpatialVector<Scalar>& v) -> auto
operator-
Componentwise difference of a spatial matrix and an Eigen matrix expression.
See declaration
template<class Scalar, class EigenDerived>
auto operator-(const SpatialMatrix<Scalar>& A, const Eigen::MatrixBase<EigenDerived>& B) -> SpatialMatrix<Scalar>
operator-
Componentwise difference of an Eigen matrix expression and a spatial matrix.
See declaration
template<class EigenDerived, class Scalar>
auto operator-(const Eigen::MatrixBase<EigenDerived>& A, const SpatialMatrix<Scalar>& B) -> SpatialMatrix<Scalar>
template<class Scalar>
auto operator<<(std::ostream& os, const SpatialVector<Scalar>& v) -> std::ostream&
Streams the vector's active components to an output stream.

Typedef documentation

using RealMatrix = Matrix<Real>

Defined in Rodin/Math/Matrix.h

Real-valued dense matrix.

Convenience alias for Matrix<Real>.

using ComplexMatrix = Matrix<Complex>

Defined in Rodin/Math/Matrix.h

Complex-valued dense matrix.

Convenience alias for Matrix<Complex>, commonly used in eigenvalue problems, frequency-domain analysis, and other applications requiring complex arithmetic.

using SparseIndex = std::int32_t

Defined in Rodin/Math/SparseMatrix.h

Signed 32-bit index type used by sparse matrix storage.

template<class ScalarType>
using SparseTriplet = Eigen::Triplet<ScalarType, SparseIndex>

Defined in Rodin/Math/SparseMatrix.h

Sparse matrix entry used during assembly.

Template parameters
ScalarType The entry value type.

template<class ScalarType>
using SparseMatrix = Eigen::SparseMatrix<ScalarType, Eigen::ColMajor, SparseIndex>

Defined in Rodin/Math/SparseMatrix.h

Sparse matrix type.

Template parameters
ScalarType The element type (e.g., Real, Complex)

A sparse matrix stores only the non-zero elements, making it memory-efficient for large matrices arising from finite element discretizations where most entries are zero. The matrix uses compressed column storage (CCS) format by default.

Storage Format

Eigen's SparseMatrix uses Compressed Column Storage (CCS), also known as Compressed Sparse Column (CSC) format, which stores:

  • Non-zero values
  • Signed 32-bit row indices for each non-zero value
  • Signed 32-bit column pointers indicating where each column starts

Typical Applications

  • Stiffness matrices: $ K $ in $ Ku = f $
  • Mass matrices: $ M $ in $ M\ddot{u} + Ku = f $
  • Discretized differential operators

using SpatialPoint = SpatialVector<Real>

Defined in Rodin/Math/SpatialVector.h

Real-valued spatial vector for point coordinates.

Convenience alias for SpatialVector<Real>, commonly used to represent points in 2D or 3D space.

using ComplexVector = Vector<Complex>

Defined in Rodin/Math/Vector.h

Dynamic-size complex-valued vector.

Convenience alias for Vector<Complex>.

template<class ScalarType>
using Vector2 = FixedSizeVector<ScalarType, 2>

Defined in Rodin/Math/Vector.h

2D fixed-size vector.

Template parameters
ScalarType The element type

A vector with exactly 2 elements.

template<class ScalarType>
using Vector3 = FixedSizeVector<ScalarType, 3>

Defined in Rodin/Math/Vector.h

3D fixed-size vector.

Template parameters
ScalarType The element type

A vector with exactly 3 elements.

template<class ScalarType>
using Vector4 = FixedSizeVector<ScalarType, 4>

Defined in Rodin/Math/Vector.h

4D fixed-size vector.

Template parameters
ScalarType The element type

A vector with exactly 4 elements.

template<class ScalarType>
using Vector8 = FixedSizeVector<ScalarType, 8>

Defined in Rodin/Math/Vector.h

8D fixed-size vector.

Template parameters
ScalarType The element type

A vector with exactly 8 elements.

template<class ScalarType>
using Vector16 = FixedSizeVector<ScalarType, 16>

Defined in Rodin/Math/Vector.h

16D fixed-size vector.

Template parameters
ScalarType The element type

A vector with exactly 16 elements.

template<class ScalarType>
using Vector32 = FixedSizeVector<ScalarType, 32>

Defined in Rodin/Math/Vector.h

32D fixed-size vector.

Template parameters
ScalarType The element type

A vector with exactly 32 elements.

template<class ScalarType>
using Vector64 = FixedSizeVector<ScalarType, 64>

Defined in Rodin/Math/Vector.h

64D fixed-size vector.

Template parameters
ScalarType The element type

A vector with exactly 64 elements.

template<class ScalarType>
using Vector128 = FixedSizeVector<ScalarType, 128>

Defined in Rodin/Math/Vector.h

128D fixed-size vector.

Template parameters
ScalarType The element type

A vector with exactly 128 elements.

Function documentation

template<class T>
auto abs(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the absolute value of a value.

Template parameters
T Type of value (Real, Complex, etc.)
Parameters
x in Value
Returns Absolute value $ |x| $

Returns $ |x| $ , the absolute value (magnitude) of $ x $ .

template<class Scalar>
Eigen::NumTraits<Scalar>::Real abs(const Scalar& x)

Defined in Rodin/Math/Common.h

Computes the real magnitude of a complex scalar.

Template parameters
Scalar Complex scalar type.
Parameters
x Complex scalar whose magnitude is evaluated.
Returns The nonnegative real magnitude.

For $z=a+ib$ , the magnitude is $|z|=\sqrt{a^2+b^2}$ .

template<class T>
auto exp(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the exponential function.

Template parameters
T Type of value
Parameters
x in Exponent
Returns $ e^x $

Returns $ e^x $ where $ e \approx 2.71828 $ is Euler's number.

template<class Scalar>
Scalar conj(const Scalar& x) constexpr

Defined in Rodin/Math/Common.h

Computes the complex conjugate of a complex number.

Template parameters
Scalar Complex scalar type.
Parameters
x in Complex number
Returns Complex conjugate $ \bar{x} $ , preserving scalar precision.

For $ z = a + bi $ , returns $ \bar{z} = a - bi $ .

template<class T>
auto conj(const Eigen::MatrixBase<T>& x) constexpr

Defined in Rodin/Math/Common.h

Computes the conjugate of an Eigen matrix.

Template parameters
T Eigen matrix type
Parameters
x in Matrix
Returns Conjugate matrix

For matrices with complex entries, returns the element-wise conjugate.

template<class Scalar>
Scalar conj(const Scalar& x) constexpr

Defined in Rodin/Math/Common.h

Identity conjugate for real numbers.

Template parameters
Scalar Arithmetic scalar type.
Parameters
x in Real number
Returns $ x $ , preserving scalar precision.

For real numbers, the conjugate is the number itself.

template<class Scalar>
auto conj(const SpatialVector<Scalar>& value)

Defined in Rodin/Math/Common.h

Conjugates each active component of a spatial vector.

Parameters
value Vector to conjugate.
Returns An owning spatial vector with unchanged dimension.

template<class Scalar>
auto conj(const SpatialMatrix<Scalar>& value)

Defined in Rodin/Math/Common.h

Conjugates each active entry of a spatial matrix.

Parameters
value Matrix to conjugate.
Returns An owning spatial matrix with unchanged dimensions.

template<class Base>
auto pow2(const Base& base) constexpr

Defined in Rodin/Math/Common.h

Computes the square of a value.

Template parameters
Base Type of the value
Parameters
base in Value to square
Returns $ \text{base}^2 $

Returns $ x^2 = x \times x $ efficiently without calling std::pow.

template<size_t N, class Base>
Base pow(const Base& x) constexpr

Defined in Rodin/Math/Common.h

Computes the compile-time integer power.

Template parameters
N Exponent (non-negative integer)
Base Type of the base value
Parameters
x in Base value
Returns $ x^N $

Returns $ x^N $ where $ N $ is known at compile time, using exponentiation by squaring for efficiency.

template<class Base, size_t N>
Base pow(const Base& x, std::integral_constant<size_t, N> orderTag) constexpr

Defined in Rodin/Math/Common.h

Computes the compile-time integer power via integral_constant.

Template parameters
Base Type of the base value
N Exponent
Parameters
x in Base value
orderTag Compile-time order or value-range dimension tag.
Returns $ x^N $

Convenience overload accepting the exponent as a std::integral_constant<size_t, N> parameter.

template<class Base, class Exponent>
auto pow(const Base& base, const Exponent& exponent) constexpr

Defined in Rodin/Math/Common.h

Computes a power with arbitrary exponent.

Template parameters
Base Type of the base
Exponent Type of the exponent
Parameters
base in Base value $ x $
exponent in Exponent value $ y $
Returns $ x^y $

Returns $ x^y $ where $ x $ is the base and $ y $ is the exponent.

template<class T>
auto sqrt(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the square root of a value.

Template parameters
T Type of value
Parameters
x in Value (must be non-negative for real types)
Returns $ \sqrt{x} $

Returns $ \sqrt{x} $ , the principal square root of $ x $ .

template<class T>
Boolean isNaN(const T& x) constexpr

Defined in Rodin/Math/Common.h

Determines if a floating point number is not-a-number (NaN).

Template parameters
T Type of value
Parameters
x in Value to check
Returns True if $ x $ is NaN, false otherwise

Checks if $ x $ is NaN (not a number), which typically results from undefined operations like $ 0/0 $ or $ \sqrt{-1} $ for reals.

Boolean isNaN(const Complex& x) constexpr

Defined in Rodin/Math/Common.h

Determines if a complex number is not-a-number (NaN).

Parameters
x in Complex number to check
Returns True if real or imaginary part is NaN, false otherwise

Returns true if either the real or imaginary part is NaN.

template<class T>
Boolean isInf(const T& x) constexpr

Defined in Rodin/Math/Common.h

Determines if a floating point number is infinite.

Template parameters
T Type of value
Parameters
x in Value to check
Returns True if $ x $ is $ +\infty $ or $ -\infty $ , false otherwise

Checks if $ x = \pm\infty $ , which can result from overflow or operations like $ 1/0 $ .

template<class T>
auto cos(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the cosine function.

Template parameters
T Type of value
Parameters
x in Angle in radians
Returns $ \cos(x) $

Returns $ \cos(x) $ where $ x $ is in radians.

template<class T>
auto cosh(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the hyperbolic cosine function.

Template parameters
T Type of value
Parameters
x in Value
Returns $ \cosh(x) $

Returns $ \cosh(x) = \frac{e^x + e^{-x}}{2} $ .

template<class T>
auto sin(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the sine function.

Template parameters
T Type of value
Parameters
x in Angle in radians
Returns $ \sin(x) $

Returns $ \sin(x) $ where $ x $ is in radians.

template<class T>
auto sinh(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the hyperbolic sine function.

Template parameters
T Type of value
Parameters
x in Value
Returns $ \sinh(x) $

Returns $ \sinh(x) = \frac{e^x - e^{-x}}{2} $ .

template<class T>
auto tan(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the tangent function.

Template parameters
T Type of value
Parameters
x in Angle in radians
Returns $ \tan(x) $

Returns $ \tan(x) = \frac{\sin(x)}{\cos(x)} $ where $ x $ is in radians.

template<typename T>
T sgn(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the sign (signum) function.

Template parameters
T Type of value
Parameters
x in Value
Returns The sign of $ x $ , represented by -1, 0 or +1.

Returns the following value.

\[ \text{sgn}(x) = \begin{cases} -1 & \text{if } x < 0 \\ 0 & \text{if } x = 0 \\ +1 & \text{if } x > 0 \end{cases} \]

template<class T>
T binom(const T& n, const T& k) constexpr

Defined in Rodin/Math/Common.h

Computes the binomial coefficient.

Template parameters
T Type of value (typically Integer)
Parameters
n in Total number of items
k in Number of items to choose
Returns $ \binom{n}{k} $

Returns $ \binom{n}{k} = \frac{n!}{k!(n-k)!} $ , the number of ways to choose $ k $ items from $ n $ items without regard to order.

template<class T>
T factorial(const T& n) constexpr

Defined in Rodin/Math/Common.h

Computes the factorial function.

Template parameters
T Type of value (typically Integer)
Parameters
n in Non-negative integer
Returns $ n! $

Returns $ n! = 1 \times 2 \times 3 \times \cdots \times n $ .

template<class T>
T permutation(const T& n, const T& k) constexpr

Defined in Rodin/Math/Common.h

Computes the permutation function.

Template parameters
T Type of value (typically Integer)
Parameters
n in Total number of items
k in Number of items to arrange
Returns $ P(n, k) $

Returns $ P(n, k) = \frac{n!}{(n-k)!} $ , the number of ways to arrange $ k $ items from $ n $ items where order matters.

template<class T>
auto nan() constexpr

Defined in Rodin/Math/Common.h

Returns a quiet NaN (not-a-number) value.

Template parameters
T Type of value (must be a floating point type)
Returns Quiet NaN value of type T

Returns a NaN value of the specified type, useful for indicating undefined or invalid results.

template<class LHS, class RHS>
auto sum(const LHS& lhs, const RHS& rhs) constexpr

Defined in Rodin/Math/Common.h

Computes the sum of two values.

Template parameters
LHS Type of left-hand side
RHS Type of right-hand side
Parameters
lhs in Left-hand side operand
rhs in Right-hand side operand
Returns $ \text{lhs} + \text{rhs} $

Returns $ \text{lhs} + \text{rhs} $ . This function is used internally for type deduction in the form language.

template<class Operand>
auto minus(const Operand& op) constexpr

Defined in Rodin/Math/Common.h

Computes the unary minus (negation).

Template parameters
Operand Type of operand
Parameters
op in Operand to negate
Returns $ -\text{op} $

Returns $ -\text{op} $ . This function is used internally for type deduction in the form language.

template<class LHS, class RHS>
auto minus(const LHS& lhs, const RHS& rhs) constexpr

Defined in Rodin/Math/Common.h

Computes the difference of two values.

Template parameters
LHS Type of left-hand side
RHS Type of right-hand side
Parameters
lhs in Left-hand side operand
rhs in Right-hand side operand
Returns $ \text{lhs} - \text{rhs} $

Returns $ \text{lhs} - \text{rhs} $ . This function is used internally for type deduction in the form language.

template<class LHS, class RHS>
auto mult(const LHS& lhs, const RHS& rhs) constexpr

Defined in Rodin/Math/Common.h

Computes the product of two values.

Template parameters
LHS Type of left-hand side
RHS Type of right-hand side
Parameters
lhs in Left-hand side operand
rhs in Right-hand side operand
Returns $ \text{lhs} \times \text{rhs} $

Returns $ \text{lhs} \times \text{rhs} $ . This function is used internally for type deduction in the form language.

template<class LHS, class RHS>
auto division(const LHS& lhs, const RHS& rhs) constexpr

Defined in Rodin/Math/Common.h

Computes the division of two values.

Template parameters
LHS Type of left-hand side
RHS Type of right-hand side
Parameters
lhs in Left-hand side operand (numerator)
rhs in Right-hand side operand (denominator)
Returns $ \text{lhs} / \text{rhs} $

Returns $ \text{lhs} / \text{rhs} $ . This function is used internally for type deduction in the form language.

template<class Left, class Right>
auto dot(const Left& lhs, const Right& rhs) constexpr

Defined in Rodin/Math/Common.h

Multiplies two real scalars.

Template parameters
Left Left arithmetic type.
Right Right arithmetic type.
Parameters
lhs Left operand.
rhs Right operand.
Returns Ordinary arithmetic product.

template<class Left, class Right>
auto dot(const std::complex<Left>& lhs, const std::complex<Right>& rhs) constexpr

Defined in Rodin/Math/Common.h

Multiplies complex scalars, conjugating the right operand.

Template parameters
Left Left floating-point component type.
Right Right floating-point component type.
Parameters
lhs Left operand.
rhs Right operand.
Returns $u\overline{v}$ at their common scalar precision.

template<class Left, class Right>
auto dot(const Left& lhs, const std::complex<Right>& rhs) constexpr

Defined in Rodin/Math/Common.h

Multiplies real and complex scalars, conjugating the right operand.

Template parameters
Left Left arithmetic type.
Right Right floating-point component type.
Parameters
lhs Left operand.
rhs Right operand.
Returns $u\overline{v}$ at their common scalar precision.

template<class Left, class Right>
auto dot(const std::complex<Left>& lhs, const Right& rhs) constexpr

Defined in Rodin/Math/Common.h

Multiplies complex and real scalars.

Template parameters
Left Left floating-point component type.
Right Right arithmetic type.
Parameters
lhs Left operand.
rhs Right operand.
Returns $u\overline{v}=uv$ at their common scalar precision.

template<class LHSDerived, class RHSDerived>
auto dot(const Eigen::MatrixBase<LHSDerived>& lhs, const Eigen::MatrixBase<RHSDerived>& rhs) constexpr

Defined in Rodin/Math/Common.h

Computes the dot product of two Eigen vectors/matrices.

Template parameters
LHSDerived Eigen type of left-hand side
RHSDerived Eigen type of right-hand side
Parameters
lhs in Left-hand side vector/matrix
rhs in Right-hand side vector/matrix
Returns Dot product (scalar)

For vectors $ \mathbf{u} $ and $ \mathbf{v} $ , computes

\[ \mathbf{u} \cdot \mathbf{v} = \sum_i u_i \overline{v_i} \]

where $ \overline{v_i} $ is the complex conjugate (identity for real values).

template<class LHSScalar, class RHSScalar>
auto dot(const SpatialVector<LHSScalar>& lhs, const SpatialVector<RHSScalar>& rhs) constexpr

Defined in Rodin/Math/Common.h

Computes the dot product of two SpatialVector objects.

Template parameters
LHSScalar Scalar type of left-hand side
RHSScalar Scalar type of right-hand side
Parameters
lhs in Left-hand side SpatialVector
rhs in Right-hand side SpatialVector
Returns Dot product (scalar)

For logical dimension $d\le3$ , computes $\sum_{i=0}^{d-1}u_i\overline{v_i}$ . Real operands use scalar contractions; complex operands retain fixed-extent reductions with right conjugation. Mixed scalar products retain their dynamic reduction. Fused arithmetic and reduction order may differ within floating-point rounding. Inactive storage is never read; the empty product is zero.

template<class LHSScalar, class RHSScalar>
auto dot(const SpatialMatrix<LHSScalar>& lhs, const SpatialMatrix<RHSScalar>& rhs) constexpr

Defined in Rodin/Math/Common.h

Computes the dot product of two SpatialMatrix objects.

Template parameters
LHSScalar Scalar type of left-hand side
RHSScalar Scalar type of right-hand side
Parameters
lhs in Left-hand side SpatialMatrix
rhs in Right-hand side SpatialMatrix
Returns Dot product (scalar)

Computes $\sum_{i,j} A_{ij}\overline{B_{ij}}$ over active entries. Real matrices retain dimension-specific kernels in one shape dispatch, shared with the member dot operation. Full-size storage uses Eigen's fixed reduction directly; smaller shapes use explicit active entries. Empty shapes return zero without reading inactive storage.

template<class LHSDerived, class RHSScalar>
auto dot(const Eigen::MatrixBase<LHSDerived>& lhs, const Math::SpatialVector<RHSScalar>& rhs) constexpr

Defined in Rodin/Math/Common.h

Computes the dot product of an Eigen vector and a SpatialVector.

Template parameters
LHSDerived Eigen type of left-hand side
RHSScalar Scalar type of SpatialVector
Parameters
lhs in Left-hand side Eigen vector
rhs in Right-hand side SpatialVector
Returns Dot product (scalar)

template<class LHSScalar, class RHSDerived>
auto dot(const Math::SpatialVector<LHSScalar>& lhs, const Eigen::MatrixBase<RHSDerived>& rhs) constexpr

Defined in Rodin/Math/Common.h

Computes the dot product of a SpatialVector and an Eigen vector.

Template parameters
LHSScalar Scalar type of SpatialVector
RHSDerived Eigen type of right-hand side
Parameters
lhs in Left-hand side SpatialVector
rhs in Right-hand side Eigen vector
Returns Dot product (scalar)

template<class LHSDerived, class RHSScalar>
auto dot(const Eigen::MatrixBase<LHSDerived>& lhs, const Math::SpatialMatrix<RHSScalar>& rhs) constexpr

Defined in Rodin/Math/Common.h

Computes the dot product of an Eigen matrix and a SpatialMatrix.

Template parameters
LHSDerived Eigen type of left-hand side
RHSScalar Scalar type of SpatialMatrix
Parameters
lhs in Left-hand side Eigen matrix
rhs in Right-hand side SpatialMatrix
Returns Dot product (scalar)

template<class LHSScalar, class RHSDerived>
auto dot(const Math::SpatialMatrix<LHSScalar>& lhs, const Eigen::MatrixBase<RHSDerived>& rhs) constexpr

Defined in Rodin/Math/Common.h

Computes the dot product of a SpatialMatrix and an Eigen matrix.

Template parameters
LHSScalar Scalar type of SpatialMatrix
RHSDerived Eigen type of right-hand side
Parameters
lhs in Left-hand side SpatialMatrix
rhs in Right-hand side Eigen matrix
Returns Dot product (scalar)

template<class T>
auto log(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the natural logarithm.

Template parameters
T Type of value
Parameters
x in Value (must be positive for real types)
Returns $ \ln(x) $

Returns $ \ln(x) $ , the natural (base- $ e $ ) logarithm of $ x $ .

template<class T>
auto log2(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the base-2 logarithm.

Template parameters
T Type of value
Parameters
x in Value (must be positive for real types)
Returns $ \log_2(x) $

Returns $ \log_2(x) $ .

template<class T>
auto log10(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the base-10 logarithm.

Template parameters
T Type of value
Parameters
x in Value (must be positive for real types)
Returns $ \log_{10}(x) $

Returns $ \log_{10}(x) $ .

template<class T>
auto acos(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the arc cosine (inverse cosine).

Template parameters
T Type of value
Parameters
x in Value in $ [-1, 1] $
Returns $ \arccos(x) $ in radians

Returns $ \arccos(x) $ in radians, in the range $ [0, \pi] $ .

template<class T>
auto asin(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the arc sine (inverse sine).

Template parameters
T Type of value
Parameters
x in Value in $ [-1, 1] $
Returns $ \arcsin(x) $ in radians

Returns $ \arcsin(x) $ in radians, in the range $ [-\pi/2, \pi/2] $ .

template<class T>
auto atan(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the arc tangent (inverse tangent).

Template parameters
T Type of value
Parameters
x in Value
Returns $ \arctan(x) $ in radians

Returns $ \arctan(x) $ in radians, in the range $ (-\pi/2, \pi/2) $ .

template<class T>
auto atan2(const T& y, const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the two-argument arc tangent.

Template parameters
T Type of value
Parameters
y in The y-coordinate
x in The x-coordinate
Returns $ \text{atan2}(y, x) $ in radians

Returns $ \text{atan2}(y, x) $ in radians, in the range $ (-\pi, \pi] $ . This is the angle of the vector $ (x, y) $ from the positive $ x $ -axis.

template<class T>
auto tanh(const T& x) constexpr

Defined in Rodin/Math/Common.h

Computes the hyperbolic tangent function.

Template parameters
T Type of value
Parameters
x in Value
Returns $ \tanh(x) $

Returns $ \tanh(x) = \frac{\sinh(x)}{\cosh(x)} $ .

template<class T>
auto min(const T& a, const T& b) constexpr

Defined in Rodin/Math/Common.h

Returns the minimum of two values.

Template parameters
T Type of value
Parameters
a in First value
b in Second value
Returns The smaller of $ a $ and $ b $

template<class T>
auto max(const T& a, const T& b) constexpr

Defined in Rodin/Math/Common.h

Returns the maximum of two values.

Template parameters
T Type of value
Parameters
a in First value
b in Second value
Returns The larger of $ a $ and $ b $

template<class T>
auto clamp(const T& x, const T& lo, const T& hi) constexpr

Defined in Rodin/Math/Common.h

Clamps a value to the range $ [\text{lo}, \text{hi}] $ .

Template parameters
T Type of value
Parameters
x in Value to clamp
lo in Lower bound
hi in Upper bound
Returns Clamped value in $ [\text{lo}, \text{hi}] $

If $ x < \text{lo} $ , returns $ \text{lo} $ . If $ x > \text{hi} $ , returns $ \text{hi} $ . Otherwise returns $ x $ .

template<class LHSScalar, class RHSScalar, size_t Rank>
auto dot(const SpatialTensor<LHSScalar, Rank>& lhs, const SpatialTensor<RHSScalar, Rank>& rhs)

Defined in Rodin/Math/Common.h

Frobenius contraction of spatial tensors, conjugating the RHS.

Parameters
lhs Left operand.
rhs Right operand.
Returns Scalar Frobenius contraction of the operands.

template<class Scalar, size_t Rank>
auto conj(const SpatialTensor<Scalar, Rank>& value)

Defined in Rodin/Math/Common.h

Entrywise tensor conjugation.

Parameters
value Value to store or assign.
Returns Entrywise conjugate of the tensor.

template<std::size_t I, class Matrix, class Vector>
decltype(auto) get(LinearSystem<Matrix, Vector>& ls)

Defined in Rodin/Math/LinearSystem.h

Accesses element I of ls for structured binding. (0 = operator $ A $ , 1 = solution $ x $ , 2 = right-hand side $ b $ ).

Parameters
ls Linear system to solve.
Returns The .

template<std::size_t I, class Matrix, class Vector>
decltype(auto) get(const LinearSystem<Matrix, Vector>& ls)

Defined in Rodin/Math/LinearSystem.h

Structured-binding accessor (const overload); see get(LinearSystem&).

Parameters
ls Linear system to solve.
Returns The .

template<std::size_t I, class Matrix, class Vector>
decltype(auto) get(LinearSystem<Matrix, Vector>&& ls)

Defined in Rodin/Math/LinearSystem.h

Structured-binding accessor (rvalue overload); moves out element I.

Parameters
ls Linear system to solve.
Returns The .

template<std::size_t I, class Matrix, class Vector>
decltype(auto) get(const LinearSystem<Matrix, Vector>&& ls)

Defined in Rodin/Math/LinearSystem.h

Structured-binding accessor (const rvalue overload); see get(LinearSystem&&).

Parameters
ls Linear system to solve.
Returns The .

template<class AScalarType, class YScalarType, class XScalarType>
void axpy(SparseMatrix<YScalarType>& y, AScalarType alpha, const SparseMatrix<XScalarType>& x)

Defined in Rodin/Math/SparseMatrix.h

Performs the AXPY operation on sparse matrices.

Template parameters
AScalarType Scalar type for alpha
YScalarType Scalar type for matrix y
XScalarType Scalar type for matrix x
Parameters
y in/out Matrix to be updated (accumulated result)
alpha in Scalar multiplier for x
x in Matrix to be scaled and added to y

Computes $ y \leftarrow y + \alpha x $ where $ y $ and $ x $ are sparse matrices and $ \alpha $ is a scalar.

This is the sparse matrix version of the Level 1 BLAS AXPY operation.

template<class LHSScalar, class RHSScalar>
auto operator*(const LHSScalar& value, const SpatialMatrix<RHSScalar>& A) noexcept

Defined in Rodin/Math/SpatialMatrix.h

Scalar-times-matrix product with real/complex promotion. Arithmetic coefficients are converted to Real for a complex matrix, preserving real-times-complex arithmetic rather than complexifying them.

Parameters
value Value to store or assign.
A System matrix.
Returns Product of the operands.

template<class LHSScalar, class RHSScalar>
SpatialMatrix<typename FormLanguage::Mult<LHSScalar, RHSScalar>::Type> operator*(const SpatialMatrix<LHSScalar>& A, const Math::Vector<RHSScalar>& s) noexcept

Defined in Rodin/Math/SpatialMatrix.h

Matrix-times-vector product, returned as a single-column matrix.

Parameters
A System matrix.
s Scalar factor.
Returns Product of the operands.

template<class LHSScalar, class RHSScalar>
auto operator*(const SpatialMatrix<LHSScalar>& A, const RHSScalar& value) noexcept

Defined in Rodin/Math/SpatialMatrix.h

Matrix-times-scalar product with real/complex promotion.

Parameters
A System matrix.
value Value to store or assign.
Returns Product of the operands.

template<class LHSScalar, class RHSScalar>
SpatialMatrix<typename FormLanguage::Mult<LHSScalar, RHSScalar>::Type> operator*(const SpatialMatrix<LHSScalar>& A, const SpatialMatrix<RHSScalar>& B) noexcept

Defined in Rodin/Math/SpatialMatrix.h

Matrix-matrix product with real/complex promotion.

Parameters
A System matrix.
B Second matrix operand.
Returns Product of the operands.

template<class Scalar>
SpatialMatrix<Scalar> operator+(const SpatialMatrix<Scalar>& A, const SpatialMatrix<Scalar>& B)

Defined in Rodin/Math/SpatialMatrix.h

Computes the element-wise sum of two spatial matrices.

Template parameters
Scalar Element type
Parameters
A in Left-hand side matrix
B in Right-hand side matrix
Returns $ A + B $

template<class Scalar>
SpatialMatrix<Scalar> operator-(const SpatialMatrix<Scalar>& A, const SpatialMatrix<Scalar>& B)

Defined in Rodin/Math/SpatialMatrix.h

Computes the element-wise difference of two spatial matrices.

Template parameters
Scalar Element type
Parameters
A in Left-hand side matrix
B in Right-hand side matrix
Returns $ A - B $

template<class LHSScalar, class RHSScalar>
SpatialVector<typename FormLanguage::Mult<LHSScalar, RHSScalar>::Type> operator*(const SpatialMatrix<LHSScalar>& A, const SpatialVector<RHSScalar>& x) noexcept

Defined in Rodin/Math/SpatialMatrix.h

Matrix-times-vector product.

Template parameters
LHSScalar Matrix entry field.
RHSScalar Vector entry field.
Parameters
A Matrix with $r$ rows and $c$ columns.
x Vector operand.
Returns Product of the operands.

The logical result has $r$ components and evaluates $y_i=\sum_{j=0}^{c-1}A_{ij}x_j$ . Its constructor initializes the complete fixed-capacity storage once. Empty contractions and inactive components therefore remain zero without a second active-entry clear.

template<class Scalar>
SpatialMatrix<Scalar> operator*(const SpatialVector<Scalar>& v, const SpatialMatrix<Scalar>& m) noexcept

Defined in Rodin/Math/SpatialMatrix.h

Row-vector-times-matrix product, returned as a single-row matrix.

Parameters
v Vector operand.
m Matrix operand.
Returns Product of the operands.

template<class EigenDerived, class Scalar>
auto operator*(const Eigen::MatrixBase<EigenDerived>& s, const SpatialMatrix<Scalar>& m)

Defined in Rodin/Math/SpatialMatrix.h

Product of an Eigen matrix expression and a spatial matrix.

Parameters
s Scalar factor.
m Matrix operand.
Returns Product of the operands.

template<class Scalar, class EigenDerived>
auto operator*(const SpatialMatrix<Scalar>& m, const Eigen::MatrixBase<EigenDerived>& s)

Defined in Rodin/Math/SpatialMatrix.h

Product of a spatial matrix and an Eigen matrix expression.

Parameters
m Matrix operand.
s Scalar factor.
Returns Product of the operands.

template<class Scalar>
auto operator*(const SpatialMatrix<Scalar>& m, const Math::Vector<Scalar>& v)

Defined in Rodin/Math/SpatialMatrix.h

Matrix-times-(dynamic)-vector product.

Parameters
m Matrix operand.
v Vector operand.
Returns Product of the operands.

template<class Scalar, class EigenDerived>
SpatialMatrix<Scalar> operator+(const SpatialMatrix<Scalar>& A, const Eigen::MatrixBase<EigenDerived>& B)

Defined in Rodin/Math/SpatialMatrix.h

Componentwise sum of a spatial matrix and an Eigen matrix expression.

Parameters
A System matrix.
B Second matrix operand.
Returns Sum of the operands.

template<class EigenDerived, class Scalar>
SpatialMatrix<Scalar> operator+(const Eigen::MatrixBase<EigenDerived>& A, const SpatialMatrix<Scalar>& B)

Defined in Rodin/Math/SpatialMatrix.h

Componentwise sum of an Eigen matrix expression and a spatial matrix.

Parameters
A System matrix.
B Second matrix operand.
Returns Sum of the operands.

template<class Scalar>
std::ostream& operator<<(std::ostream& os, const SpatialMatrix<Scalar>& m)

Defined in Rodin/Math/SpatialMatrix.h

Streams the matrix's active block to an output stream.

Parameters
os Output stream.
m Matrix operand.
Returns Output stream after writing the object.

template<class Scalar, class Value>
auto operator/(const SpatialMatrix<Scalar>& matrix, const Value& divisor)

Defined in Rodin/Math/SpatialMatrix.h

Divide every active matrix entry by a scalar.

Parameters
matrix Matrix operand.
divisor Scalar divisor.
Returns Quotient of the operands.

template<class Value, class Scalar, size_t Rank>
auto operator*(const Value& factor, const SpatialTensor<Scalar, Rank>& tensor)

Defined in Rodin/Math/SpatialTensor.h

Scales every active tensor entry with scalar type promotion.

Parameters
factor Scalar multiplier.
tensor Tensor operand.
Returns Product of the operands.

template<class Scalar>
SpatialVector<Scalar> operator+(const SpatialVector<Scalar>& a, const SpatialVector<Scalar>& b) noexcept

Defined in Rodin/Math/SpatialVector.h

Componentwise sum of two spatial vectors.

Parameters
a Left operand.
b Right operand.
Returns Sum of the operands.

template<class Scalar>
SpatialVector<Scalar> operator-(const SpatialVector<Scalar>& a, const SpatialVector<Scalar>& b) noexcept

Defined in Rodin/Math/SpatialVector.h

Componentwise difference of two spatial vectors.

Parameters
a Left operand.
b Right operand.
Returns Difference of the operands, or the negated operand for the unary overload.

template<class LHS, class Scalar>
auto operator*(const LHS& value, const SpatialVector<Scalar>& v) noexcept

Defined in Rodin/Math/SpatialVector.h

Scalar-times-vector product with real/complex promotion.

Parameters
value Value to store or assign.
v Vector operand.
Returns Product of the operands.

template<class Scalar, class RHS>
auto operator*(const SpatialVector<Scalar>& v, const RHS& value)

Defined in Rodin/Math/SpatialVector.h

Vector-times-scalar product with real/complex promotion.

Parameters
v Vector operand.
value Value to store or assign.
Returns Product of the operands.

template<class Scalar, class RHS>
SpatialVector<Scalar> operator/(const SpatialVector<Scalar>& v, const RHS& s) noexcept

Defined in Rodin/Math/SpatialVector.h

Vector-divided-by-scalar product.

Parameters
v Vector operand.
s Scalar factor.
Returns Quotient of the operands.

template<class EigenDerived, class Scalar>
SpatialVector<Scalar> operator+(const Eigen::MatrixBase<EigenDerived>& a, const SpatialVector<Scalar>& b)

Defined in Rodin/Math/SpatialVector.h

Componentwise sum of an Eigen vector expression and a spatial vector.

Parameters
a Left operand.
b Right operand.
Returns Sum of the operands.

template<class Scalar, class EigenDerived>
SpatialVector<Scalar> operator+(const SpatialVector<Scalar>& a, const Eigen::MatrixBase<EigenDerived>& b)

Defined in Rodin/Math/SpatialVector.h

Componentwise sum of a spatial vector and an Eigen vector expression.

Parameters
a Left operand.
b Right operand.
Returns Sum of the operands.

template<class EigenDerived, class Scalar>
auto operator-(const Eigen::MatrixBase<EigenDerived>& a, const SpatialVector<Scalar>& b)

Defined in Rodin/Math/SpatialVector.h

Componentwise difference of an Eigen vector expression and a spatial vector.

Parameters
a Left operand.
b Right operand.
Returns Difference of the operands, or the negated operand for the unary overload.

template<class Scalar, class EigenDerived>
auto operator-(const SpatialVector<Scalar>& a, const Eigen::MatrixBase<EigenDerived>& b)

Defined in Rodin/Math/SpatialVector.h

Componentwise difference of a spatial vector and an Eigen vector expression.

Parameters
a Left operand.
b Right operand.
Returns Difference of the operands, or the negated operand for the unary overload.

template<class Scalar, class EigenDerived>
auto operator*(const SpatialVector<Scalar>& v, const Eigen::MatrixBase<EigenDerived>& m)

Defined in Rodin/Math/SpatialVector.h

Row-vector-times-matrix product with an Eigen matrix expression.

Parameters
v Vector operand.
m Matrix operand.
Returns Product of the operands.

template<class EigenDerived, class Scalar>
auto operator*(const Eigen::MatrixBase<EigenDerived>& m, const SpatialVector<Scalar>& v)

Defined in Rodin/Math/SpatialVector.h

Matrix-times-vector product with an Eigen matrix expression.

Parameters
m Matrix operand.
v Vector operand.
Returns Product of the operands.

template<class Scalar, class EigenDerived>
SpatialMatrix<Scalar> operator-(const SpatialMatrix<Scalar>& A, const Eigen::MatrixBase<EigenDerived>& B)

Defined in Rodin/Math/SpatialVector.h

Componentwise difference of a spatial matrix and an Eigen matrix expression.

Parameters
A System matrix.
B Second matrix operand.
Returns Difference of the operands, or the negated operand for the unary overload.

template<class EigenDerived, class Scalar>
SpatialMatrix<Scalar> operator-(const Eigen::MatrixBase<EigenDerived>& A, const SpatialMatrix<Scalar>& B)

Defined in Rodin/Math/SpatialVector.h

Componentwise difference of an Eigen matrix expression and a spatial matrix.

Parameters
A System matrix.
B Second matrix operand.
Returns Difference of the operands, or the negated operand for the unary overload.

template<class Scalar>
std::ostream& operator<<(std::ostream& os, const SpatialVector<Scalar>& v)

Defined in Rodin/Math/SpatialVector.h

Streams the vector's active components to an output stream.

Parameters
os Output stream.
v Vector operand.
Returns Output stream after writing the object.