Matrix
Dynamic-size dense matrix.
Defined in Rodin/Math/Matrix.h
template < class ScalarType> class Matrix;
| Template parameters | |
|---|---|
| ScalarType | The element type (e.g., Real, Complex) |
Dynamic-size dense matrix type.
A dense matrix with both dimensions determined at runtime. The matrix is stored in column-major order (Fortran style) and supports standard linear algebra operations without additional storage. Dot products conjugate the right operand.
Public types
Constructors, destructors, conversion operators
- Matrix()
- Constructs a matrix with Eigen's default initialization.
- Matrix(const Matrix& other) defaulted
- Copies the matrix and its owned coefficients.
- Matrix(Matrix&& other) defaulted noexcept
- Moves the matrix and its owned coefficients.
-
template<class T>Matrix(const T& value) explicit
- Constructs a matrix from dimensions, coefficients or an Eigen object.
-
template<class T0, class T1>Matrix(const T0& first, const T1& second)
- Constructs a matrix from dimensions or two vector coefficients.
-
template<class Derived>Matrix(const Eigen::DenseBase<Derived>& other)
- Copies the coefficients of an Eigen dense expression.
-
template<class Derived>Matrix(const Eigen::EigenBase<Derived>& other)
- Evaluates an Eigen operator, such as a permutation or solve.
-
template<class Derived>Matrix(const Eigen::ReturnByValue<Derived>& other)
- Evaluates an Eigen return-by-value operation.
- Matrix(const std::initializer_list<std::initializer_list<Scalar>>& rows) explicit
- Constructs a matrix from coefficients grouped by row.
- Matrix(Eigen::Matrix<ScalarType, Eigen::Dynamic, Eigen::Dynamic>&& other) noexcept
- Takes ownership of a native Eigen matrix without reallocating.
Public functions
- auto operator=(Eigen::Matrix<ScalarType, Eigen::Dynamic, Eigen::Dynamic>&& other) -> Matrix& noexcept
- Exchanges owned storage with a native Eigen matrix.
- auto operator=(const Matrix& other) -> Matrix&
- Copies the matrix coefficients.
- auto operator=(Matrix&& other) -> Matrix& defaulted noexcept
- Moves the matrix coefficients.
-
template<class Derived>auto operator=(const Eigen::DenseBase<Derived>& other) -> Matrix&
- Assigns a dense expression, resizing when necessary.
-
template<class Derived>auto operator=(const Eigen::EigenBase<Derived>& other) -> Matrix&
- Assigns an Eigen operator, retaining the Rodin matrix return type.
-
template<class Derived>auto operator=(const Eigen::ReturnByValue<Derived>& other) -> Matrix&
- Assigns an Eigen return-by-value operation.
- void conservativeResize(Eigen::Index rows, Eigen::Index cols)
- Resizes while preserving the common top-left block.
- void conservativeResize(Eigen::Index rows, Eigen::NoChange_t unchanged)
- Changes the row count while preserving existing coefficients.
- void conservativeResize(Eigen::NoChange_t unchanged, Eigen::Index cols)
- Changes the column count while preserving existing coefficients.
-
template<class Derived>void conservativeResizeLike(const Eigen::DenseBase<Derived>& other)
- Resizes to an expression, retaining old values and copying new entries.
- auto innerStride() const -> Eigen::Index constexpr noexcept
- Stride between consecutive coefficients in the inner dimension.
- auto outerStride() const -> Eigen::Index constexpr noexcept
- Stride between consecutive columns, or rows for row-major storage.
-
template<class Derived>auto dot(const Eigen::MatrixBase<Derived>& other) const -> auto
- Contracts with the conjugate of the right operand.
Function documentation
Matrix(const Matrix& other) defaulted
Copies the matrix and its owned coefficients.
| Parameters | |
|---|---|
| other | Matrix to copy. |
Matrix(Matrix&& other) defaulted noexcept
Moves the matrix and its owned coefficients.
| Parameters | |
|---|---|
| other | Matrix to move. |
template<class ScalarType>
template<class T>
Matrix(const T& value) explicit
Constructs a matrix from dimensions, coefficients or an Eigen object.
| Template parameters | |
|---|---|
| T | Argument type understood by Eigen's matrix constructor. |
| Parameters | |
| value | Dimension, coefficient, coefficient array or Eigen object. |
template<class ScalarType>
template<class T0, class T1>
Matrix(const T0& first,
const T1& second)
Constructs a matrix from dimensions or two vector coefficients.
| Template parameters | |
|---|---|
| T0 | First argument type. |
| T1 | Second argument type. |
| Parameters | |
| first | Row count or first coefficient of a two-component vector. |
| second | Column count or second coefficient of a two-component vector. |
template<class ScalarType>
template<class Derived>
Matrix(const Eigen::DenseBase<Derived>& other)
Copies the coefficients of an Eigen dense expression.
| Template parameters | |
|---|---|
| Derived | Eigen expression type. |
| Parameters | |
| other | Expression to evaluate. |
template<class ScalarType>
template<class Derived>
Matrix(const Eigen::EigenBase<Derived>& other)
Evaluates an Eigen operator, such as a permutation or solve.
| Template parameters | |
|---|---|
| Derived | Eigen operator type. |
| Parameters | |
| other | Operator to evaluate. |
template<class ScalarType>
template<class Derived>
Matrix(const Eigen::ReturnByValue<Derived>& other)
Evaluates an Eigen return-by-value operation.
| Template parameters | |
|---|---|
| Derived | Eigen operation type. |
| Parameters | |
| other | Operation to evaluate. |
Matrix(Eigen::Matrix<ScalarType, Eigen::Dynamic, Eigen::Dynamic>&& other) noexcept
Takes ownership of a native Eigen matrix without reallocating.
| Parameters | |
|---|---|
| other | Native matrix to move. |
void conservativeResize(Eigen::Index rows, Eigen::Index cols)
Resizes while preserving the common top-left block.
| Parameters | |
|---|---|
| rows | New row count. |
| cols | New column count. |
void conservativeResize(Eigen::Index rows, Eigen::NoChange_t unchanged)
Changes the row count while preserving existing coefficients.
| Parameters | |
|---|---|
| rows | New row count. |
| unchanged | Retains the column count. |
void conservativeResize(Eigen::NoChange_t unchanged, Eigen::Index cols)
Changes the column count while preserving existing coefficients.
| Parameters | |
|---|---|
| unchanged | Retains the row count. |
| cols | New column count. |
template<class ScalarType>
template<class Derived>
void conservativeResizeLike(const Eigen::DenseBase<Derived>& other)
Resizes to an expression, retaining old values and copying new entries.
| Template parameters | |
|---|---|
| Derived | Eigen dense expression type. |
| Parameters | |
| other | Expression supplying the new shape and appended coefficients. |
Eigen::Index innerStride() const constexpr noexcept
Stride between consecutive coefficients in the inner dimension.
| Returns | One, since inner coefficients are contiguous. |
|---|
Eigen::Index outerStride() const constexpr noexcept
Stride between consecutive columns, or rows for row-major storage.
| Returns | The number of coefficients in the inner dimension. |
|---|
template<class ScalarType>
template<class Derived>
auto dot(const Eigen::MatrixBase<Derived>& other) const
Contracts with the conjugate of the right operand.
| Template parameters | |
|---|---|
| Derived | Eigen type of the right operand. |
| Parameters | |
| other | Matrix of the same shape. |
| Returns | The right-conjugating inner product. |
Computes , consistently with dot. Eigen expressions and views retain their Eigen types; use dot to contract those with this convention.