qualpal 3.3.0
Loading...
Searching...
No Matches
qualpal::FixedMatrix< T, rows, cols > Class Template Reference

Fixed-size matrix class with compile-time dimensions. More...

#include <matrix.h>

Public Member Functions

constexpr FixedMatrix ()
 Default constructor - elements are zero-initialized.
 
constexpr FixedMatrix (std::initializer_list< std::initializer_list< T > > list)
 Construct from nested initializer list.
 
constexpr FixedMatrix< T, cols, rows > t () const
 Create transpose of this matrix.
 
constexpr T & operator() (std::size_t row, std::size_t col)
 Access matrix element (mutable).
 
constexpr const T & operator() (std::size_t row, std::size_t col) const
 Access matrix element (const).
 
constexpr FixedMatrix< T, rows, cols > operator* (const T &scalar) const
 Scalar multiplication.
 
constexpr std::array< T, rows > operator* (const std::array< T, cols > &vec) const
 Matrix-vector multiplication.
 
template<std::size_t other_cols>
constexpr FixedMatrix< T, rows, other_cols > operator* (const FixedMatrix< T, cols, other_cols > &other) const
 Matrix-matrix multiplication (FixedMatrix * FixedMatrix).
 
constexpr Matrix< T > operator* (const Matrix< T > &other) const
 Matrix-matrix multiplication (FixedMatrix * dynamic Matrix)
 
constexpr FixedMatrix< T, rows, cols > operator+ (const FixedMatrix< T, rows, cols > &other) const
 Matrix addition.
 
constexpr FixedMatrix< T, rows, cols > operator- (const FixedMatrix< T, rows, cols > &other) const
 Matrix subtraction.
 
constexpr void fill (const T &value)
 Fill all elements with specified value.
 
constexpr void zeros ()
 Set all elements to zero.
 

Detailed Description

template<typename T, std::size_t rows, std::size_t cols>
class qualpal::FixedMatrix< T, rows, cols >

Fixed-size matrix class with compile-time dimensions.

Template Parameters
TElement type (typically double or float).
rowsNumber of rows (compile-time constant).
colsNumber of columns (compile-time constant).

Stores elements in row-major order (C-style). Provides constexpr element access, arithmetic, and multiplication.

Example:

FixedMatrix<double, 2, 3> mat = { {1.0, 2.0, 3.0}, {4.0, 5.0, 6.0} };
double v = mat(1, 2); // Access element at row 1, column 2
Fixed-size matrix class with compile-time dimensions.
Definition matrix.h:146
See also
Matrix for dynamic-sized matrices

Definition at line 145 of file matrix.h.

Constructor & Destructor Documentation

◆ FixedMatrix() [1/2]

template<typename T , std::size_t rows, std::size_t cols>
constexpr qualpal::FixedMatrix< T, rows, cols >::FixedMatrix ( )
inlineconstexpr

Default constructor - elements are zero-initialized.

Definition at line 149 of file matrix.h.

◆ FixedMatrix() [2/2]

template<typename T , std::size_t rows, std::size_t cols>
constexpr qualpal::FixedMatrix< T, rows, cols >::FixedMatrix ( std::initializer_list< std::initializer_list< T > >  list)
inlineconstexpr

Construct from nested initializer list.

Parameters
listNested initializer list of matrix elements

Definition at line 158 of file matrix.h.

Member Function Documentation

◆ fill()

template<typename T , std::size_t rows, std::size_t cols>
constexpr void qualpal::FixedMatrix< T, rows, cols >::fill ( const T &  value)
inlineconstexpr

Fill all elements with specified value.

Definition at line 313 of file matrix.h.

◆ operator()() [1/2]

template<typename T , std::size_t rows, std::size_t cols>
constexpr T & qualpal::FixedMatrix< T, rows, cols >::operator() ( std::size_t  row,
std::size_t  col 
)
inlineconstexpr

Access matrix element (mutable).

Parameters
rowRow index (0-based).
colColumn index (0-based).
Returns
Reference to element at (row, col).
Note
Elements are stored in row-major order: data[row * cols + col].
Exceptions
std::out_of_rangeif indices are out of bounds (in debug builds).

Definition at line 193 of file matrix.h.

◆ operator()() [2/2]

template<typename T , std::size_t rows, std::size_t cols>
constexpr const T & qualpal::FixedMatrix< T, rows, cols >::operator() ( std::size_t  row,
std::size_t  col 
) const
inlineconstexpr

Access matrix element (const).

Parameters
rowRow index (0-based).
colColumn index (0-based).
Returns
Const reference to element at (row, col).
Note
Elements are stored in row-major order: data[row * cols + col].
Exceptions
std::out_of_rangeif indices are out of bounds (in debug builds).

Definition at line 206 of file matrix.h.

◆ operator*() [1/4]

template<typename T , std::size_t rows, std::size_t cols>
template<std::size_t other_cols>
constexpr FixedMatrix< T, rows, other_cols > qualpal::FixedMatrix< T, rows, cols >::operator* ( const FixedMatrix< T, cols, other_cols > &  other) const
inlineconstexpr

Matrix-matrix multiplication (FixedMatrix * FixedMatrix).

Template Parameters
other_colsNumber of columns in the other matrix.
Parameters
otherThe matrix to multiply with (must have 'cols' rows).
Returns
Result matrix with dimensions (rows × other_cols).

Definition at line 248 of file matrix.h.

◆ operator*() [2/4]

template<typename T , std::size_t rows, std::size_t cols>
constexpr Matrix< T > qualpal::FixedMatrix< T, rows, cols >::operator* ( const Matrix< T > &  other) const
inlineconstexpr

Matrix-matrix multiplication (FixedMatrix * dynamic Matrix)

Parameters
otherDynamic matrix to multiply with
Returns
Result as dynamic Matrix

Definition at line 268 of file matrix.h.

◆ operator*() [3/4]

template<typename T , std::size_t rows, std::size_t cols>
constexpr std::array< T, rows > qualpal::FixedMatrix< T, rows, cols >::operator* ( const std::array< T, cols > &  vec) const
inlineconstexpr

Matrix-vector multiplication.

Parameters
vecVector to multiply with (must have 'cols' elements)
Returns
Result vector with 'rows' elements

Definition at line 230 of file matrix.h.

◆ operator*() [4/4]

template<typename T , std::size_t rows, std::size_t cols>
constexpr FixedMatrix< T, rows, cols > qualpal::FixedMatrix< T, rows, cols >::operator* ( const T &  scalar) const
inlineconstexpr

Scalar multiplication.

Parameters
scalarValue to multiply all elements by
Returns
New matrix with all elements multiplied by scalar

Definition at line 216 of file matrix.h.

◆ operator+()

template<typename T , std::size_t rows, std::size_t cols>
constexpr FixedMatrix< T, rows, cols > qualpal::FixedMatrix< T, rows, cols >::operator+ ( const FixedMatrix< T, rows, cols > &  other) const
inlineconstexpr

Matrix addition.

Parameters
otherMatrix to add (must have same dimensions)
Returns
New matrix containing element-wise sum

Definition at line 287 of file matrix.h.

◆ operator-()

template<typename T , std::size_t rows, std::size_t cols>
constexpr FixedMatrix< T, rows, cols > qualpal::FixedMatrix< T, rows, cols >::operator- ( const FixedMatrix< T, rows, cols > &  other) const
inlineconstexpr

Matrix subtraction.

Parameters
otherMatrix to subtract (must have same dimensions)
Returns
New matrix containing element-wise difference

Definition at line 302 of file matrix.h.

◆ t()

template<typename T , std::size_t rows, std::size_t cols>
constexpr FixedMatrix< T, cols, rows > qualpal::FixedMatrix< T, rows, cols >::t ( ) const
inlineconstexpr

Create transpose of this matrix.

Returns
New FixedMatrix that is the transpose of this matrix

Definition at line 174 of file matrix.h.

◆ zeros()

template<typename T , std::size_t rows, std::size_t cols>
constexpr void qualpal::FixedMatrix< T, rows, cols >::zeros ( )
inlineconstexpr

Set all elements to zero.

Definition at line 316 of file matrix.h.


The documentation for this class was generated from the following file: