Skip to content

LiteFX::Math::Matrix

An algebraic matrix type.

Synopsis

Declared in <litefx/matrix.hpp>

template<
    typename T,
    unsigned int ROWS,
    unsigned int COLS>
requires (ROWS >= 2 && COLS >= 2) && std::is_standard_layout_v<T> && std::is_trivially_copyable_v<T>
struct Matrix final

Description

Note that matrices in the engine are row-major by convention.

Matrices act as optimized storage containers only. All algebraic operations are not part of the library itself, but rather covered by supported linear algebra libraries.

Type Aliases

NameDescription
generic_mat_type The type of the matrix, but without pre-defined dimensions.
mat_type The type of the matrix itself.
scalar_type The type of the matrix elements.

Member Functions

NameDescription
Matrix [constructor]Constructors
~Matrix [destructor]Destroys the matrix instance.
operator= Assignment operators
at Returns the element at a specified position.
begin Returns an iterator for that addresses the begin of the matrix elements.
cbegin Returns a constant iterator for that addresses the begin of the matrix elements.
cend Returns a constant iterator for that addresses the end of the matrix elements.
column Returns a copy of a column over the matrix.
elements Returns a pointer to the raw data of the matrix.
end Returns an iterator for that addresses the end of the matrix elements.
operator[] Returns an element of the matrix.
row Returns a view over a row of the matrix.
size Returns the number of elements of the matrix.
symmetric Returns whether or not the matrix is symmetric, that is the number of rows and columns are equal.
transpose Returns a copy of the matrix where the elements are transposed.
operator DirectX::XMFLOAT3X3 Converts the matrix into a 3x3 DirectX matrix.
operator DirectX::XMFLOAT3X4 Converts the matrix into a 3x4 DirectX matrix.
operator DirectX::XMFLOAT4X3 Converts the matrix into a 4x3 DirectX matrix.
operator DirectX::XMFLOAT4X4 Converts the matrix into a 4x4 DirectX matrix.
operator DirectX::XMMATRIX Converts the matrix into a DirectX matrix.
operator glm::mat<2, 2, scalar_type> Converts the matrix into a 2x2 glm matrix.
operator glm::mat<2, 3, scalar_type> Converts the matrix into a 3x2 glm matrix.
operator glm::mat<2, 4, scalar_type> Converts the matrix into a 4x2 glm matrix.
operator glm::mat<3, 2, scalar_type> Converts the matrix into a 2x3 glm matrix.
operator glm::mat<3, 3, scalar_type> Converts the matrix into a 3x3 glm matrix.
operator glm::mat<3, 4, scalar_type> Converts the matrix into a 4x3 glm matrix.
operator glm::mat<4, 2, scalar_type> Converts the matrix into a 2x4 glm matrix.
operator glm::mat<4, 3, scalar_type> Converts the matrix into a 3x4 glm matrix.
operator glm::mat<4, 4, scalar_type> Converts the matrix into a 4x4 glm matrix.
operator glm::mat<cols, rows, scalar_type> Converts the matrix into a glm matrix.
operator std::array<T, mat_rows * mat_cols> Converts the matrix to an instance of std::array.
operator std::mdspan<scalar_type const, std::extents<size_t, mat_rows, mat_cols>> Converts the matrix into a multi-dimensional view over the elements.
operator std::mdspan<scalar_type, std::extents<size_t, mat_rows, mat_cols>> Converts the matrix into a multi-dimensional view over the elements.
operator std::span<scalar_type const> Converts the matrix into a linear view over the elements.
operator std::span<scalar_type> Converts the matrix into a linear view over the elements.
operator std::vector<T> Converts the matrix into an instance of type std::vector.

Static Member Functions

NameDescription
identity Returns an identity matrix.

Static Data Members

NameDescription
mat_cols Stores the number of columns of the matrix.
mat_rows Stores the number of rows of the matrix.

Protected Type Aliases

Name
array_type

Protected Data Members

Name
m_elements

Template Parameters

NameDescription
TThe type of the matrix scalar elements. Must be in standard layout (i.e., std::is_standard_layout_v<T> must evaluate to true).
ROWSThe number of rows of the matrix. Must be greater than 1.
COLSThe number of columns of the matrix. Must be greater than 1.