soo
3D game math library
Loading...
Searching...
No Matches
soo::Matrix< T, Row, Col > Class Template Reference

Matrix class. More...

#include <matrix.h>

Public Member Functions

 Matrix (const std::initializer_list< std::initializer_list< T > > &list)
 Matrix (const Matrix &rhs) noexcept
 Matrix (Matrix &&rhs) noexcept
Matrixoperator= (const Matrix &rhs) noexcept
Matrixoperator= (Matrix &&rhs) noexcept
ColArray & operator[] (const size_t row) noexcept(false)
const ColArray & operator[] (const size_t row) const noexcept(false)
bool operator== (const Matrix &rhs) const noexcept
Matrix operator+ (const Matrix &rhs) const noexcept
Matrix operator- (const Matrix &rhs) const noexcept
template<size_t R, size_t C>
Matrix< T, Row, C > operator* (const Matrix< T, R, C > &rhs) const noexcept(false)
Matrix operator* (const T val) const noexcept
Vector3< T > operator* (const Vector3< T > &rhs) const
Matrixoperator+= (const Matrix &rhs) noexcept
Matrixoperator-= (const Matrix &rhs) noexcept
Matrixoperator*= (const T val) noexcept
template<typename Func>
requires std::invocable<Func, T&, const size_t, const size_t>
void forEachEntry (const Func &action)
Matrix< T, Col, Row > transpose () const noexcept
Matrix inverse2x2 () const noexcept(false)
Matrix inverse3x3 () const noexcept(false)
Matrix inverseNxN () const noexcept(false)

Static Public Member Functions

static constexpr size_t getRowSize () noexcept
static constexpr size_t getColSize () noexcept
static constexpr Matrix createIdentity () noexcept

Private Types

using ColArray = std::array<T, Col>

Private Attributes

std::array< ColArray, Row > entries

Detailed Description

template<std::floating_point T, size_t Row, size_t Col>
requires (Row > 0 && Col > 0)
class soo::Matrix< T, Row, Col >

Matrix class.

Template Parameters
TType of the entries. Must be a floating-point type.
RowThe number of rows.
ColThe number of columns.

Member Function Documentation

◆ forEachEntry()

template<std::floating_point T, size_t Row, size_t Col>
template<typename Func>
requires std::invocable<Func, T&, const size_t, const size_t>
void soo::Matrix< T, Row, Col >::forEachEntry ( const Func & action)
inline

Do an action for each entry.

Template Parameters
FuncParams must be (T& entry, const size_t row, const size_t col)
Parameters
actionCallable that will be invoked for each entry

◆ inverse2x2()

template<std::floating_point T, size_t Row, size_t Col>
Matrix soo::Matrix< T, Row, Col >::inverse2x2 ( ) const
inline

Only callable on 2 x 2 matrix

Returns
Inverse matrix

◆ inverse3x3()

template<std::floating_point T, size_t Row, size_t Col>
Matrix soo::Matrix< T, Row, Col >::inverse3x3 ( ) const
inline

Only callable on 3 x 3 matrix

Returns
Inverse matrix

◆ inverseNxN()

template<std::floating_point T, size_t Row, size_t Col>
Matrix soo::Matrix< T, Row, Col >::inverseNxN ( ) const
inline

Using Gauss-Jordan Elimination to get the inverse matrix. inverse2x2 or inverse3x3 functions are recommended for 2x2 or 3x3 matrices.

Returns
Inverse matrix

◆ operator*() [1/3]

template<std::floating_point T, size_t Row, size_t Col>
template<size_t R, size_t C>
Matrix< T, Row, C > soo::Matrix< T, Row, Col >::operator* ( const Matrix< T, R, C > & rhs) const
inline

Matrix multiplication.

Template Parameters
RRHS matrix's row size
CRHS matrix's column size

◆ operator*() [2/3]

template<std::floating_point T, size_t Row, size_t Col>
Matrix soo::Matrix< T, Row, Col >::operator* ( const T val) const
inlinenoexcept

Scalar multiplication.

◆ operator*() [3/3]

template<std::floating_point T, size_t Row, size_t Col>
Vector3< T > soo::Matrix< T, Row, Col >::operator* ( const Vector3< T > & rhs) const
inline

Vector multiplication.

◆ transpose()

template<std::floating_point T, size_t Row, size_t Col>
Matrix< T, Col, Row > soo::Matrix< T, Row, Col >::transpose ( ) const
inlinenoexcept
Returns
Transposed matrix of this

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