#include <Rodin/Math/SpatialMatrix.h>
template<class ScalarType>
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:
- Metric tensors
- Local coordinate transformations
Public types
Public static variables
- static std::uint8_t MaxSize constexpr
- Maximum storable dimension (RODIN_MAXIMAL_SPACE_DIMENSION, fixed at 3).
Public static functions
- static auto Identity(std::uint8_t rows, std::uint8_t cols) -> SpatialMatrix constexpr
- Returns an identity matrix of the given dimensions.
Constructors, destructors, conversion operators
- SpatialMatrix() constexpr noexcept
- Constructs an empty (0-by-0) spatial matrix.
- SpatialMatrix(std::uint8_t rows, std::uint8_t cols) constexpr
- Constructs a zero-initialized spatial matrix of the given dimensions.
- SpatialMatrix(const SpatialVector<Scalar>& vec) constexpr
- Constructs a single-column matrix from a spatial vector.
- SpatialMatrix(const SpatialMatrix&) defaulted constexpr
- Copy constructor.
- SpatialMatrix(SpatialMatrix&&) defaulted constexpr
- Move constructor.
-
template<class EigenDerived>SpatialMatrix(const Eigen::MatrixBase<EigenDerived>& other) constexpr
- Constructs a spatial matrix from an Eigen matrix expression.
Public functions
- auto operator=(const SpatialMatrix&) -> SpatialMatrix& defaulted constexpr
- Copy assignment operator.
- auto operator=(SpatialMatrix&&) -> SpatialMatrix& defaulted constexpr
- Move assignment operator.
-
template<class EigenDerived>auto operator=(const Eigen::ArrayBase<EigenDerived>& other) -> SpatialMatrix& constexpr
- Assigns from an Eigen array expression, resizing to match.
-
template<class EigenDerived>auto operator=(const Eigen::MatrixBase<EigenDerived>& other) -> SpatialMatrix& constexpr
- Assigns from an Eigen matrix expression, resizing to match.
- auto operator+=(const SpatialMatrix& other) -> SpatialMatrix& constexpr
- Adds another spatial matrix componentwise in place.
- auto rows() const -> std::uint8_t constexpr noexcept
- Returns the number of rows.
- auto cols() const -> std::uint8_t constexpr noexcept
- Returns the number of columns.
- void resize(std::uint8_t r, std::uint8_t c) constexpr
- Sets the logical dimensions (each must not exceed MaxSize).
- auto operator()(std::uint8_t i, std::uint8_t j) -> ScalarType& constexpr
- Returns a reference to entry (i, j).
- auto operator()(std::uint8_t i, std::uint8_t j) const -> const ScalarType& constexpr
- Returns a const reference to entry (i, j).
- void setZero() constexpr noexcept
- Sets all entries to zero.
- void setConstant(const ScalarType& value) constexpr noexcept
- Sets all entries to the given value.
- void setIdentity() constexpr noexcept
- Sets this matrix to the identity.
- auto squaredNorm() const -> ScalarType constexpr noexcept
- Returns the squared Frobenius norm.
- auto norm() const -> ScalarType constexpr noexcept
- Returns the Frobenius norm.
- auto dot(const SpatialMatrix& other) const -> ScalarType constexpr noexcept
- Returns the Frobenius inner product with another spatial matrix.
-
template<class EigenDerived>auto dot(const Eigen::MatrixBase<EigenDerived>& other) const -> ScalarType constexpr noexcept
- Returns the Frobenius inner product with an Eigen matrix expression.
- auto transpose() const -> SpatialMatrix<ScalarType> constexpr noexcept
- Returns the transpose.
- auto conjugate() const -> SpatialMatrix<ScalarType> constexpr noexcept
- Returns the elementwise complex conjugate.
- auto adjoint() const -> SpatialMatrix<ScalarType> constexpr noexcept
- Returns the conjugate transpose (adjoint).
- auto trace() const -> ScalarType constexpr noexcept
- Returns the trace (sum of the diagonal entries; requires a square matrix).
- auto value() const -> ScalarType constexpr noexcept
- Returns the (0, 0) entry (for 1-by-1 matrices used as scalars).
- auto solve(const SpatialVector<ScalarType>& b) const -> SpatialVector<ScalarType> noexcept
- Solves the linear system .
- auto determinant() const -> ScalarType constexpr noexcept
- Returns the determinant (specialized for 1x1, 2x2 and 3x3).
- auto inverse() const -> SpatialMatrix<ScalarType> constexpr noexcept
- Returns the matrix inverse (specialized for 1x1, 2x2 and 3x3).
- auto row(std::uint8_t i) const -> SpatialVector<Scalar> constexpr noexcept
- Extracts the -th row as a SpatialVector.
- auto col(std::uint8_t j) const -> SpatialVector<Scalar> constexpr noexcept
- Extracts the -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 constexpr noexcept
- Returns the componentwise additive inverse of this matrix.
- auto operator*=(const SpatialMatrix& rhs) -> SpatialMatrix& constexpr noexcept
- In-place matrix multiplication.
- auto getData() -> auto& constexpr noexcept
- Returns a reference to the underlying Eigen storage.
- auto getData() const -> const auto& constexpr noexcept
- Returns a const reference to the underlying Eigen storage.
Function documentation
template<class ScalarType>
SpatialVector<ScalarType> Rodin:: Math:: SpatialMatrix<ScalarType>:: solve(const SpatialVector<ScalarType>& b) const noexcept
Solves the linear system .
| Parameters | |
|---|---|
| b in | Right-hand side vector |
| Returns | Solution vector |
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 -th row as a SpatialVector.
| Parameters | |
|---|---|
| i 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 -th column as a SpatialVector.
| Parameters | |
|---|---|
| j 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 |
|---|
For full column rank matrices ( ), computes . For full row rank matrices ( ), computes .
template<class ScalarType>
SpatialMatrix& Rodin:: Math:: SpatialMatrix<ScalarType>:: operator*=(const Scalar& s) constexpr noexcept
Scales all elements by a scalar.
| Parameters | |
|---|---|
| s in | Scalar multiplier |
| Returns | Reference to 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 after multiplication |
Replaces with . Requires cols() == rhs.rows(). Handles self-multiplication safely.