template<class ScalarType>
Rodin::Math::SpatialMatrix class

Spatial matrix with bounded maximum dimensions.

Template parameters
ScalarType The element type

A dynamic-size matrix with maximum dimensions bounded by RODIN_MAXIMAL_SPACE_DIMENSION. Used for geometric transformations, Jacobians, and other spatial operators to optimize memory allocation.

Typical uses:

  • Jacobian matrices: $ J = \frac{\partial \mathbf{f}}{\partial \mathbf{x}} $
  • Metric tensors
  • Local coordinate transformations

Public functions

auto solve(const SpatialVector<ScalarType>& b) const -> SpatialVector<ScalarType> noexcept
Solves the linear system $ Ax = b $ .
auto row(std::uint8_t i) const -> SpatialVector<Scalar> constexpr noexcept
Extracts the $ i $ -th row as a SpatialVector.
auto col(std::uint8_t j) const -> SpatialVector<Scalar> constexpr noexcept
Extracts the $ j $ -th column as a SpatialVector.
auto pseudoInverse() const -> SpatialMatrix constexpr noexcept
Computes the Moore-Penrose pseudo-inverse.
auto operator*=(const Scalar& s) -> SpatialMatrix& constexpr noexcept
Scales all elements by a scalar.
auto operator*=(const SpatialMatrix& rhs) -> SpatialMatrix& constexpr noexcept
In-place matrix multiplication.

Function documentation

template<class ScalarType>
SpatialVector<ScalarType> Rodin::Math::SpatialMatrix<ScalarType>::solve(const SpatialVector<ScalarType>& b) const noexcept

Solves the linear system $ Ax = b $ .

Parameters
in Right-hand side vector
Returns Solution vector $ x = A^{-1} b $

Uses Cramer's rule for small systems (1×1, 2×2, 3×3). The matrix must be square and non-singular.

template<class ScalarType>
SpatialVector<Scalar> Rodin::Math::SpatialMatrix<ScalarType>::row(std::uint8_t i) const constexpr noexcept

Extracts the $ i $ -th row as a SpatialVector.

Parameters
in Row index (0-based)
Returns Row vector of length cols()

template<class ScalarType>
SpatialVector<Scalar> Rodin::Math::SpatialMatrix<ScalarType>::col(std::uint8_t j) const constexpr noexcept

Extracts the $ j $ -th column as a SpatialVector.

Parameters
in Column index (0-based)
Returns Column vector of length rows()

template<class ScalarType>
SpatialMatrix Rodin::Math::SpatialMatrix<ScalarType>::pseudoInverse() const constexpr noexcept

Computes the Moore-Penrose pseudo-inverse.

Returns The pseudo-inverse $ A^+ $

For full column rank matrices ( $ m \geq n $ ), computes $ A^+ = (A^T A)^{-1} A^T $ . For full row rank matrices ( $ m < n $ ), computes $ A^+ = A^T (A A^T)^{-1} $ .

template<class ScalarType>
SpatialMatrix& Rodin::Math::SpatialMatrix<ScalarType>::operator*=(const Scalar& s) constexpr noexcept

Scales all elements by a scalar.

Parameters
in Scalar multiplier
Returns Reference to $ *this $ after scaling

template<class ScalarType>
SpatialMatrix& Rodin::Math::SpatialMatrix<ScalarType>::operator*=(const SpatialMatrix& rhs) constexpr noexcept

In-place matrix multiplication.

Parameters
rhs in Right-hand side matrix
Returns Reference to $ *this $ after multiplication

Replaces $ *this $ with $ (*this) \cdot rhs $ . Requires cols() == rhs.rows(). Handles self-multiplication safely.