[nnm] No Nonsense Math 0.5.0
A No-Nonsense, C++ 17, single-header-only Math library geared towards graphics programming.
Loading...
Searching...
No Matches
nnm::Matrix2< Real > Class Template Reference

#include <nnm.hpp>

Public Member Functions

constexpr Matrix2 ()
template<typename Other>
constexpr Matrix2 (const Matrix2< Other > &matrix)
constexpr Matrix2 (const Vector2< Real > &column0, const Vector2< Real > &column1)
constexpr Matrix2 (const Real col0_row0, const Real col0_row1, const Real col1_row0, const Real col1_row1)
constexpr Real trace () const
constexpr Real determinant () const
constexpr Real minor_at (const uint8_t column, const uint8_t row) const
constexpr Matrix2 minor () const
constexpr Real cofactor_at (const uint8_t column, const uint8_t row) const
constexpr Matrix2 cofactor () const
constexpr Matrix2 transpose () const
constexpr Matrix2 adjugate () const
constexpr Matrix2 unchecked_inverse () const
constexpr std::optional< Matrix2inverse () const
constexpr bool approx_equal (const Matrix2 &other) const
constexpr bool approx_zero () const
constexpr const Vector2< Real > & at (const uint8_t column) const
constexpr Vector2< Real > & at (const uint8_t column)
constexpr const Real & at (const uint8_t column, const uint8_t row) const
constexpr Real & at (const uint8_t column, const uint8_t row)
const Real * begin () const
const Real * end () const
Real * begin ()
Real * end ()
constexpr const Vector2< Real > & operator[] (const uint8_t column) const
constexpr Vector2< Real > & operator[] (const uint8_t column)
constexpr bool operator== (const Matrix2 &other) const
constexpr bool operator!= (const Matrix2 &other) const
constexpr Matrix2 operator+ (const Matrix2 &other) const
constexpr Matrix2operator+= (const Matrix2 &other)
constexpr Matrix2 operator- (const Matrix2 &other) const
constexpr Matrix2operator-= (const Matrix2 &other)
constexpr Matrix2 operator* (const Matrix2 &other) const
constexpr Matrix2operator*= (const Matrix2 &other)
constexpr Vector2< Real > operator* (const Vector2< Real > &vector) const
constexpr Matrix2 operator* (const Real value) const
constexpr Matrix2operator*= (const Real value)
constexpr Matrix2 operator/ (const Real value) const
constexpr Matrix2operator/= (const Real value)
constexpr bool operator< (const Matrix2 &other) const
constexpr operator bool () const

Static Public Member Functions

static constexpr Matrix2 all (const Real value)
static constexpr Matrix2 zero ()
static constexpr Matrix2 one ()
static constexpr Matrix2 identity ()

Public Attributes

Vector2< Real > columns [2]

Detailed Description

template<typename Real>
class nnm::Matrix2< Real >

2x2 matrix.

Template Parameters
RealFloating-point type.

Constructor & Destructor Documentation

◆ Matrix2() [1/4]

template<typename Real>
nnm::Matrix2< Real >::Matrix2 ( )
inlineconstexpr

Initialize with identity matrix.

◆ Matrix2() [2/4]

template<typename Real>
template<typename Other>
nnm::Matrix2< Real >::Matrix2 ( const Matrix2< Other > & matrix)
inlineexplicitconstexpr

Cast from another matrix type.

Template Parameters
OtherOther matrix type.
Parameters
matrixMatrix to cast from.

◆ Matrix2() [3/4]

template<typename Real>
nnm::Matrix2< Real >::Matrix2 ( const Vector2< Real > & column0,
const Vector2< Real > & column1 )
inlineconstexpr

Initialize with columns

Parameters
column0First column
column1Second column

◆ Matrix2() [4/4]

template<typename Real>
nnm::Matrix2< Real >::Matrix2 ( const Real col0_row0,
const Real col0_row1,
const Real col1_row0,
const Real col1_row1 )
inlineconstexpr

Initialize with elements

Parameters
col0_row0First column, first row
col0_row1First column, second row
col1_row0Second column, first row
col1_row1Second column, second row

Member Function Documentation

◆ adjugate()

template<typename Real>
Matrix2 nnm::Matrix2< Real >::adjugate ( ) const
inlinenodiscardconstexpr

Adjugate matrix.

Returns
Result.

◆ all()

template<typename Real>
constexpr Matrix2 nnm::Matrix2< Real >::all ( const Real value)
inlinestaticnodiscardconstexpr

Matrix with all elements equal to value.

Parameters
valueValue.
Returns
Result.

◆ approx_equal()

template<typename Real>
bool nnm::Matrix2< Real >::approx_equal ( const Matrix2< Real > & other) const
inlinenodiscardconstexpr

Element-wise approximate equality.

Parameters
otherOther matrix.
Returns
True if approximately equal, false otherwise.

◆ approx_zero()

template<typename Real>
bool nnm::Matrix2< Real >::approx_zero ( ) const
inlinenodiscardconstexpr

If all elements are approximately zero.

Returns
True if approximately zero, false otherwise.

◆ at() [1/4]

template<typename Real>
Vector2< Real > & nnm::Matrix2< Real >::at ( const uint8_t column)
inlineconstexpr

Reference to column at index.

Parameters
columnColumn.
Returns
Reference.

◆ at() [2/4]

template<typename Real>
const Vector2< Real > & nnm::Matrix2< Real >::at ( const uint8_t column) const
inlinenodiscardconstexpr

Constant reference to column at index.

Parameters
columnColumn.
Returns
Constant Reference.

◆ at() [3/4]

template<typename Real>
Real & nnm::Matrix2< Real >::at ( const uint8_t column,
const uint8_t row )
inlineconstexpr

Reference to element at column and row.

Parameters
columnColumn.
rowRow.
Returns
Reference.

◆ at() [4/4]

template<typename Real>
const Real & nnm::Matrix2< Real >::at ( const uint8_t column,
const uint8_t row ) const
inlinenodiscardconstexpr

Constant reference to element at column and row.

Parameters
columnColumn.
rowRow.
Returns
Constant reference.

◆ begin() [1/2]

template<typename Real>
Real * nnm::Matrix2< Real >::begin ( )
inline

Start iterator.

Returns
Iterator.

◆ begin() [2/2]

template<typename Real>
const Real * nnm::Matrix2< Real >::begin ( ) const
inlinenodiscard

Start constant iterator.

Returns
Constant iterator.

◆ cofactor()

template<typename Real>
Matrix2 nnm::Matrix2< Real >::cofactor ( ) const
inlinenodiscardconstexpr

Cofactor matrix.

Returns
Result.

◆ cofactor_at()

template<typename Real>
Real nnm::Matrix2< Real >::cofactor_at ( const uint8_t column,
const uint8_t row ) const
inlinenodiscardconstexpr

Cofactor at column and row.

Parameters
columnColumn
rowRow
Returns
Result.

◆ determinant()

template<typename Real>
Real nnm::Matrix2< Real >::determinant ( ) const
inlinenodiscardconstexpr

Determinant of matrix.

Returns
Result.

◆ end() [1/2]

template<typename Real>
Real * nnm::Matrix2< Real >::end ( )
inline

End iterator.

Returns
Iterator.

◆ end() [2/2]

template<typename Real>
const Real * nnm::Matrix2< Real >::end ( ) const
inlinenodiscard

End constant iterator.

Returns
Constant iterator.

◆ identity()

template<typename Real>
constexpr Matrix2 nnm::Matrix2< Real >::identity ( )
inlinestaticnodiscardconstexpr

Identity matrix.

Returns
Result.

◆ inverse()

template<typename Real>
std::optional< Matrix2 > nnm::Matrix2< Real >::inverse ( ) const
inlinenodiscardconstexpr

Inverse that returns null if the matrix does not have an inverse.

Returns
The inverse if there is one, null if not.

◆ minor()

template<typename Real>
Matrix2 nnm::Matrix2< Real >::minor ( ) const
inlinenodiscardconstexpr

Minor matrix.

Returns
Result.

◆ minor_at()

template<typename Real>
Real nnm::Matrix2< Real >::minor_at ( const uint8_t column,
const uint8_t row ) const
inlinenodiscardconstexpr

Minor matrix at column and row. This is the element with that particular row and column excluded.

Parameters
columnColumn
rowRow
Returns
Result.

◆ one()

template<typename Real>
constexpr Matrix2 nnm::Matrix2< Real >::one ( )
inlinestaticnodiscardconstexpr

Matrix with all elements equal to one.

Returns
Result.

◆ operator bool()

template<typename Real>
nnm::Matrix2< Real >::operator bool ( ) const
inlineexplicitconstexpr

Evaluates to false if all elements are zero, true otherwise.

◆ operator!=()

template<typename Real>
bool nnm::Matrix2< Real >::operator!= ( const Matrix2< Real > & other) const
inlineconstexpr

Element-wise inequality.

Parameters
otherOther matrix.
Returns
True if unequal, false otherwise.

◆ operator*() [1/3]

template<typename Real>
Matrix2 nnm::Matrix2< Real >::operator* ( const Matrix2< Real > & other) const
inlinenodiscardconstexpr

Matrix multiplication.

Parameters
otherOther matrix.
Returns
Result.

◆ operator*() [2/3]

template<typename Real>
Matrix2 nnm::Matrix2< Real >::operator* ( const Real value) const
inlinenodiscardconstexpr

Element-wise multiplication with value.

Parameters
valueValue.
Returns
Result.

◆ operator*() [3/3]

template<typename Real>
Vector2< Real > nnm::Matrix2< Real >::operator* ( const Vector2< Real > & vector) const
inlinenodiscardconstexpr

Matrix-vector multiplication.

Parameters
vectorVector.
Returns
Resulting two-dimensional matrix.

◆ operator*=() [1/2]

template<typename Real>
Matrix2 & nnm::Matrix2< Real >::operator*= ( const Matrix2< Real > & other)
inlineconstexpr

Matrix multiplication.

Parameters
otherOther matrix.
Returns
Reference to this modified matrix.

◆ operator*=() [2/2]

template<typename Real>
Matrix2 & nnm::Matrix2< Real >::operator*= ( const Real value)
inlineconstexpr

Element-wise multiplication with value.

Parameters
valueValue.
Returns
Reference to this modified matrix.

◆ operator+()

template<typename Real>
Matrix2 nnm::Matrix2< Real >::operator+ ( const Matrix2< Real > & other) const
inlinenodiscardconstexpr

Element-wise addition.

Parameters
otherOther matrix.
Returns
Result.

◆ operator+=()

template<typename Real>
Matrix2 & nnm::Matrix2< Real >::operator+= ( const Matrix2< Real > & other)
inlineconstexpr

Element-wise addition.

Parameters
otherOther matrix.
Returns
Reference to this modified matrix.

◆ operator-()

template<typename Real>
Matrix2 nnm::Matrix2< Real >::operator- ( const Matrix2< Real > & other) const
inlinenodiscardconstexpr

Element-wise subtraction.

Parameters
otherOther matrix.
Returns
Result.

◆ operator-=()

template<typename Real>
Matrix2 & nnm::Matrix2< Real >::operator-= ( const Matrix2< Real > & other)
inlineconstexpr

Element-wise subtraction.

Parameters
otherOther matrix.
Returns
Reference to this modified matrix.

◆ operator/()

template<typename Real>
Matrix2 nnm::Matrix2< Real >::operator/ ( const Real value) const
inlinenodiscardconstexpr

Element-wise division with value.

Parameters
valueValue.
Returns
Result.

◆ operator/=()

template<typename Real>
Matrix2 & nnm::Matrix2< Real >::operator/= ( const Real value)
inlineconstexpr

Element-wise division with value.

Parameters
valueValue.
Returns
Reference to this modified matrix.

◆ operator<()

template<typename Real>
bool nnm::Matrix2< Real >::operator< ( const Matrix2< Real > & other) const
inlineconstexpr

Lexicographical comparison between elements.

Parameters
otherOther matrix.
Returns
True if less than, false otherwise.

◆ operator==()

template<typename Real>
bool nnm::Matrix2< Real >::operator== ( const Matrix2< Real > & other) const
inlineconstexpr

Element-wise equality.

Parameters
otherOther matrix.
Returns
True if equal, false otherwise.

◆ operator[]() [1/2]

template<typename Real>
Vector2< Real > & nnm::Matrix2< Real >::operator[] ( const uint8_t column)
inlineconstexpr

Reference to column at index.

Parameters
columnColumn.
Returns
Reference.

◆ operator[]() [2/2]

template<typename Real>
const Vector2< Real > & nnm::Matrix2< Real >::operator[] ( const uint8_t column) const
inlineconstexpr

Constant Reference to column at index.

Parameters
columnColumn.
Returns
Constant reference.

◆ trace()

template<typename Real>
Real nnm::Matrix2< Real >::trace ( ) const
inlinenodiscardconstexpr

Sum of the matrix diagonal.

Returns
Result.

◆ transpose()

template<typename Real>
Matrix2 nnm::Matrix2< Real >::transpose ( ) const
inlinenodiscardconstexpr

Transpose matrix.

Returns
Result.

◆ unchecked_inverse()

template<typename Real>
Matrix2 nnm::Matrix2< Real >::unchecked_inverse ( ) const
inlinenodiscardconstexpr

Inverse without checking if the matrix is singular first.

Returns
Result.

◆ zero()

template<typename Real>
constexpr Matrix2 nnm::Matrix2< Real >::zero ( )
inlinestaticnodiscardconstexpr

Matrix with all elements equal to zero.

Returns
Result.

Member Data Documentation

◆ columns

template<typename Real>
Vector2<Real> nnm::Matrix2< Real >::columns[2]

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