Raven Engine v0.1
Loading...
Searching...
No Matches
Crux::Matrix< T, Rows, Cols > Struct Template Reference

Generic fixed-size matrix container. More...

#include <Matrix.h>

Public Member Functions

constexpr Matrix ()=default
 Default constructs a matrix without initializing elements.
constexpr Matrix (T value)
 Constructs a matrix with all elements set to a single value.
constexpr Matrix (std::initializer_list< T > values)
 Constructs a matrix from a flat initializer list.
constexpr T & operator() (size_t row, size_t col)
 < Internal storage for matrix elements.
constexpr const T & operator() (size_t row, size_t col) const
 Element access by (row, column).
constexpr std::array< T, Cols > & operator[] (size_t row)
 Row access operator.
constexpr const std::array< T, Cols > & operator[] (size_t row) const
 Row access operator.

Public Attributes

std::array< std::array< T, Cols >, Rows > Data

Detailed Description

template<typename T, size_t Rows, size_t Cols>
struct Crux::Matrix< T, Rows, Cols >

Generic fixed-size matrix container.

Template Parameters
TNumeric element type.
RowsNumber of rows.
ColsNumber of columns.

Constructor & Destructor Documentation

◆ Matrix() [1/3]

template<typename T, size_t Rows, size_t Cols>
Crux::Matrix< T, Rows, Cols >::Matrix ( )
constexprdefault

Default constructs a matrix without initializing elements.

◆ Matrix() [2/3]

template<typename T, size_t Rows, size_t Cols>
Crux::Matrix< T, Rows, Cols >::Matrix ( T value)
inlineconstexpr

Constructs a matrix with all elements set to a single value.

Parameters
valueValue to assign to every element.

◆ Matrix() [3/3]

template<typename T, size_t Rows, size_t Cols>
Crux::Matrix< T, Rows, Cols >::Matrix ( std::initializer_list< T > values)
inlineconstexpr

Constructs a matrix from a flat initializer list.

Elements are filled row-major. If the list has fewer elements than Rows * Cols, remaining entries are zero-initialized.

Parameters
valuesInitializer list of values.

Member Function Documentation

◆ operator()() [1/2]

template<typename T, size_t Rows, size_t Cols>
T & Crux::Matrix< T, Rows, Cols >::operator() ( size_t row,
size_t col )
inlineconstexpr

< Internal storage for matrix elements.

Element access by (row, column).

Parameters
rowZero-based row index.
colZero-based column index.
Returns
Reference to the element at (row, col).

◆ operator()() [2/2]

template<typename T, size_t Rows, size_t Cols>
const T & Crux::Matrix< T, Rows, Cols >::operator() ( size_t row,
size_t col ) const
inlineconstexpr

Element access by (row, column).

Parameters
rowZero-based row index.
colZero-based column index.
Returns
const Reference to the element at (row, col).

◆ operator[]() [1/2]

template<typename T, size_t Rows, size_t Cols>
std::array< T, Cols > & Crux::Matrix< T, Rows, Cols >::operator[] ( size_t row)
inlineconstexpr

Row access operator.

Allows 2D array-like indexing via matrix[row][col].

Parameters
rowZero-based row index.
Returns
Reference to the row array.

◆ operator[]() [2/2]

template<typename T, size_t Rows, size_t Cols>
const std::array< T, Cols > & Crux::Matrix< T, Rows, Cols >::operator[] ( size_t row) const
inlineconstexpr

Row access operator.

Allows 2D array-like indexing via matrix[row][col].

Parameters
rowZero-based row index.
Returns
const Reference to the row array.

Member Data Documentation

◆ Data

template<typename T, size_t Rows, size_t Cols>
std::array<std::array<T, Cols>, Rows> Crux::Matrix< T, Rows, Cols >::Data

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