#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& other) defaulted constexpr
- Copy constructor.
- SpatialMatrix(SpatialMatrix&& other) 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& other) -> SpatialMatrix& defaulted constexpr
- Copy assignment operator.
- auto operator=(SpatialMatrix&& other) -> 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 -> Eigen::NumTraits<ScalarType>::
Real constexpr noexcept - Returns the squared Frobenius norm.
-
auto norm() const -> Eigen::NumTraits<ScalarType>::
Real 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>
static SpatialMatrix Rodin:: Math:: SpatialMatrix<ScalarType>:: Identity(std::uint8_t rows,
std::uint8_t cols) constexpr
Returns an identity matrix of the given dimensions.
| Parameters | |
|---|---|
| rows | Number of rows. |
| cols | Number of columns. |
| Returns | An identity matrix of the given dimensions. |
template<class ScalarType>
Rodin:: Math:: SpatialMatrix<ScalarType>:: SpatialMatrix(std::uint8_t rows,
std::uint8_t cols) constexpr
Constructs a zero-initialized spatial matrix of the given dimensions.
| Parameters | |
|---|---|
| rows | Number of rows. |
| cols | Number of columns. |
template<class ScalarType>
Rodin:: Math:: SpatialMatrix<ScalarType>:: SpatialMatrix(const SpatialVector<Scalar>& vec) constexpr
Constructs a single-column matrix from a spatial vector.
| Parameters | |
|---|---|
| vec | Vector used to initialize the matrix. |
template<class ScalarType>
Rodin:: Math:: SpatialMatrix<ScalarType>:: SpatialMatrix(const SpatialMatrix& other) defaulted constexpr
Copy constructor.
| Parameters | |
|---|---|
| other | Object to copy from. |
template<class ScalarType>
Rodin:: Math:: SpatialMatrix<ScalarType>:: SpatialMatrix(SpatialMatrix&& other) defaulted constexpr
Move constructor.
| Parameters | |
|---|---|
| other | Object to move from. |
template<class ScalarType>
template<class EigenDerived>
Rodin:: Math:: SpatialMatrix<ScalarType>:: SpatialMatrix(const Eigen::MatrixBase<EigenDerived>& other) constexpr
Constructs a spatial matrix from an Eigen matrix expression.
| Parameters | |
|---|---|
| other | Object to copy from. |
template<class ScalarType>
SpatialMatrix& Rodin:: Math:: SpatialMatrix<ScalarType>:: operator=(const SpatialMatrix& other) defaulted constexpr
Copy assignment operator.
| Parameters | |
|---|---|
| other | Object to copy from. |
| Returns | Reference to this object after the operation. |
template<class ScalarType>
SpatialMatrix& Rodin:: Math:: SpatialMatrix<ScalarType>:: operator=(SpatialMatrix&& other) defaulted constexpr
Move assignment operator.
| Parameters | |
|---|---|
| other | Object to move from. |
| Returns | Reference to this object after the operation. |
template<class ScalarType>
template<class EigenDerived>
SpatialMatrix& Rodin:: Math:: SpatialMatrix<ScalarType>:: operator=(const Eigen::ArrayBase<EigenDerived>& other) constexpr
Assigns from an Eigen array expression, resizing to match.
| Parameters | |
|---|---|
| other | Object to copy from. |
| Returns | Reference to this object after the operation. |
template<class ScalarType>
template<class EigenDerived>
SpatialMatrix& Rodin:: Math:: SpatialMatrix<ScalarType>:: operator=(const Eigen::MatrixBase<EigenDerived>& other) constexpr
Assigns from an Eigen matrix expression, resizing to match.
| Parameters | |
|---|---|
| other | Object to copy from. |
| Returns | Reference to this object after the operation. |
template<class ScalarType>
SpatialMatrix& Rodin:: Math:: SpatialMatrix<ScalarType>:: operator+=(const SpatialMatrix& other) constexpr
Adds another spatial matrix componentwise in place.
| Parameters | |
|---|---|
| other | Other operand. |
| Returns | Reference to this object after the operation. |
template<class ScalarType>
std::uint8_t Rodin:: Math:: SpatialMatrix<ScalarType>:: rows() const constexpr noexcept
Returns the number of rows.
| Returns | The number of rows. |
|---|
template<class ScalarType>
std::uint8_t Rodin:: Math:: SpatialMatrix<ScalarType>:: cols() const constexpr noexcept
Returns the number of columns.
| Returns | The number of columns. |
|---|
template<class ScalarType>
void Rodin:: Math:: SpatialMatrix<ScalarType>:: resize(std::uint8_t r,
std::uint8_t c) constexpr
Sets the logical dimensions (each must not exceed MaxSize).
| Parameters | |
|---|---|
| r | Number of rows. |
| c | Number of columns. |
template<class ScalarType>
ScalarType& Rodin:: Math:: SpatialMatrix<ScalarType>:: operator()(std::uint8_t i,
std::uint8_t j) constexpr
Returns a reference to entry (i, j).
| Parameters | |
|---|---|
| i | Index of the requested entry. |
| j | Index of the second coordinate. |
| Returns | Reference to the entry at the supplied indices. |
template<class ScalarType>
const ScalarType& Rodin:: Math:: SpatialMatrix<ScalarType>:: operator()(std::uint8_t i,
std::uint8_t j) const constexpr
Returns a const reference to entry (i, j).
| Parameters | |
|---|---|
| i | Index of the requested entry. |
| j | Index of the second coordinate. |
| Returns | Reference to the entry at the supplied indices. |
template<class ScalarType>
void Rodin:: Math:: SpatialMatrix<ScalarType>:: setConstant(const ScalarType& value) constexpr noexcept
Sets all entries to the given value.
| Parameters | |
|---|---|
| value | Value to store or assign. |
template<class ScalarType>
Eigen::NumTraits<ScalarType>:: Real Rodin:: Math:: SpatialMatrix<ScalarType>:: squaredNorm() const constexpr noexcept
Returns the squared Frobenius norm.
| Returns | The squared Frobenius norm. |
|---|
template<class ScalarType>
ScalarType Rodin:: Math:: SpatialMatrix<ScalarType>:: dot(const SpatialMatrix& other) const constexpr noexcept
Returns the Frobenius inner product with another spatial matrix.
| Parameters | |
|---|---|
| other | Other operand. |
| Returns | The Frobenius inner product with another spatial matrix. |
template<class ScalarType>
template<class EigenDerived>
ScalarType Rodin:: Math:: SpatialMatrix<ScalarType>:: dot(const Eigen::MatrixBase<EigenDerived>& other) const constexpr noexcept
Returns the Frobenius inner product with an Eigen matrix expression.
| Parameters | |
|---|---|
| other | Other operand. |
| Returns | The Frobenius inner product with an Eigen matrix expression. |
template<class ScalarType>
SpatialMatrix<ScalarType> Rodin:: Math:: SpatialMatrix<ScalarType>:: transpose() const constexpr noexcept
Returns the transpose.
| Returns | The transpose. |
|---|
template<class ScalarType>
SpatialMatrix<ScalarType> Rodin:: Math:: SpatialMatrix<ScalarType>:: conjugate() const constexpr noexcept
Returns the elementwise complex conjugate.
| Returns | The elementwise complex conjugate. |
|---|
template<class ScalarType>
SpatialMatrix<ScalarType> Rodin:: Math:: SpatialMatrix<ScalarType>:: adjoint() const constexpr noexcept
Returns the conjugate transpose (adjoint).
| Returns | The conjugate transpose (adjoint). |
|---|
template<class ScalarType>
ScalarType Rodin:: Math:: SpatialMatrix<ScalarType>:: trace() const constexpr noexcept
Returns the trace (sum of the diagonal entries; requires a square matrix).
| Returns | The trace (sum of the diagonal entries; requires a square matrix). |
|---|
template<class ScalarType>
ScalarType Rodin:: Math:: SpatialMatrix<ScalarType>:: value() const constexpr noexcept
Returns the (0, 0) entry (for 1-by-1 matrices used as scalars).
| Returns | The (0, 0) entry (for 1-by-1 matrices used as scalars). |
|---|
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>
ScalarType Rodin:: Math:: SpatialMatrix<ScalarType>:: determinant() const constexpr noexcept
Returns the determinant (specialized for 1x1, 2x2 and 3x3).
| Returns | The determinant (specialized for 1x1, 2x2 and 3x3). |
|---|
Small matrices use specialized formulas; larger matrices use a generic fallback.
template<class ScalarType>
SpatialMatrix<ScalarType> Rodin:: Math:: SpatialMatrix<ScalarType>:: inverse() const constexpr noexcept
Returns the matrix inverse (specialized for 1x1, 2x2 and 3x3).
| Returns | The matrix inverse (specialized for 1x1, 2x2 and 3x3). |
|---|
Small matrices use specialized formulas; larger matrices use a generic fallback. The returned matrix has the same runtime dimensions.
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 constexpr noexcept
Returns the componentwise additive inverse of this matrix.
| Returns | Difference of the operands, or the negated operand for the unary overload. |
|---|
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.
template<class ScalarType>
auto& Rodin:: Math:: SpatialMatrix<ScalarType>:: getData() constexpr noexcept
Returns a reference to the underlying Eigen storage.
| Returns | A reference to the underlying Eigen storage. |
|---|
template<class ScalarType>
const auto& Rodin:: Math:: SpatialMatrix<ScalarType>:: getData() const constexpr noexcept
Returns a const reference to the underlying Eigen storage.
| Returns | A const reference to the underlying Eigen storage. |
|---|