Not Enough Math
Lightweight zero-dependency C++ math library
Loading...
Searching...
No Matches
nem::mat< _T, _C, _R > Struct Template Reference

#include <mat.hpp>

Public Types

using ITEM_TYPE = _T
 
using COLUMN_TYPE = nem::vec<ITEM_TYPE, ROWS>
 
using ROW_TYPE = nem::vec<ITEM_TYPE, COLUMNS>
 

Public Member Functions

constexpr COLUMN_TYPEcolumn (size_t index)
 
constexpr const COLUMN_TYPEcolumn (size_t index) const
 
constexpr COLUMN_TYPEoperator[] (size_t col)
 
constexpr const COLUMN_TYPEoperator[] (size_t col) const
 
constexpr ITEM_TYPEat (size_t row, size_t col)
 
constexpr const ITEM_TYPEat (size_t row, size_t col) const
 
constexpr ITEM_TYPE item (size_t i) const
 
constexpr const ITEM_TYPEitem_ptr (size_t i) const
 
constexpr ITEM_TYPEitem_ptr (size_t i)
 
constexpr mat ()
 
constexpr mat (ITEM_TYPE scalar)
 
constexpr mat (std::initializer_list< std::initializer_list< ITEM_TYPE > > rows)
 
constexpr matoperator+= (const mat &other)
 

Static Public Member Functions

static constexpr mat NaN ()
 

Public Attributes

union { 
 
   ITEM_TYPE   data [ITEM_COUNT] = { 0 } 
 
   COLUMN_TYPE   columns [COLUMNS
 
};  
 

Static Public Attributes

static constexpr size_t COLUMNS = _C
 
static constexpr size_t ROWS = _R
 
static constexpr size_t ITEM_COUNT = ROWS * COLUMNS
 

Friends

template<size_t OTHER_COLUMNS>
constexpr friend mat< ITEM_TYPE, OTHER_COLUMNS, ROWSoperator* (const mat &lhs, const mat< ITEM_TYPE, OTHER_COLUMNS, COLUMNS > &rhs)
 
constexpr friend mat operator+ (mat lhs, const mat &rhs)
 
constexpr friend bool operator== (const mat &lhs, const mat &rhs)
 
constexpr friend bool operator!= (const mat &lhs, const mat &rhs)
 
constexpr friend nem::vec< ITEM_TYPE, ROWSoperator* (const mat &lhs, const nem::vec< ITEM_TYPE, COLUMNS > &rhs)
 

Detailed Description

template<nem::scalar_type _T, size_t _C, size_t _R>
struct nem::mat< _T, _C, _R >

Definition at line 10 of file mat.hpp.

Member Typedef Documentation

◆ COLUMN_TYPE

template<nem::scalar_type _T, size_t _C, size_t _R>
using nem::mat< _T, _C, _R >::COLUMN_TYPE = nem::vec<ITEM_TYPE, ROWS>

Definition at line 16 of file mat.hpp.

◆ ITEM_TYPE

template<nem::scalar_type _T, size_t _C, size_t _R>
using nem::mat< _T, _C, _R >::ITEM_TYPE = _T

Definition at line 15 of file mat.hpp.

◆ ROW_TYPE

template<nem::scalar_type _T, size_t _C, size_t _R>
using nem::mat< _T, _C, _R >::ROW_TYPE = nem::vec<ITEM_TYPE, COLUMNS>

Definition at line 17 of file mat.hpp.

Constructor & Destructor Documentation

◆ mat() [1/3]

template<nem::scalar_type _T, size_t _C, size_t _R>
nem::mat< _T, _C, _R >::mat ( )
inlineconstexpr

Definition at line 53 of file mat.hpp.

◆ mat() [2/3]

template<nem::scalar_type _T, size_t _C, size_t _R>
nem::mat< _T, _C, _R >::mat ( ITEM_TYPE scalar)
inlineconstexpr

Definition at line 54 of file mat.hpp.

◆ mat() [3/3]

template<nem::scalar_type _T, size_t _C, size_t _R>
nem::mat< _T, _C, _R >::mat ( std::initializer_list< std::initializer_list< ITEM_TYPE > > rows)
inlineconstexpr

Takes ROWS lists of COLUMNS values each, matching how a matrix reads on paper, and scatters them into the column-major storage.

Definition at line 64 of file mat.hpp.

Member Function Documentation

◆ at() [1/2]

template<nem::scalar_type _T, size_t _C, size_t _R>
ITEM_TYPE & nem::mat< _T, _C, _R >::at ( size_t row,
size_t col )
inlineconstexpr

Definition at line 46 of file mat.hpp.

◆ at() [2/2]

template<nem::scalar_type _T, size_t _C, size_t _R>
const ITEM_TYPE & nem::mat< _T, _C, _R >::at ( size_t row,
size_t col ) const
inlineconstexpr

Definition at line 47 of file mat.hpp.

◆ column() [1/2]

template<nem::scalar_type _T, size_t _C, size_t _R>
COLUMN_TYPE & nem::mat< _T, _C, _R >::column ( size_t index)
inlineconstexpr

Definition at line 40 of file mat.hpp.

◆ column() [2/2]

template<nem::scalar_type _T, size_t _C, size_t _R>
const COLUMN_TYPE & nem::mat< _T, _C, _R >::column ( size_t index) const
inlineconstexpr

Definition at line 41 of file mat.hpp.

◆ item()

template<nem::scalar_type _T, size_t _C, size_t _R>
ITEM_TYPE nem::mat< _T, _C, _R >::item ( size_t i) const
inlineconstexpr

Definition at line 49 of file mat.hpp.

◆ item_ptr() [1/2]

template<nem::scalar_type _T, size_t _C, size_t _R>
ITEM_TYPE * nem::mat< _T, _C, _R >::item_ptr ( size_t i)
inlineconstexpr

Definition at line 51 of file mat.hpp.

◆ item_ptr() [2/2]

template<nem::scalar_type _T, size_t _C, size_t _R>
const ITEM_TYPE * nem::mat< _T, _C, _R >::item_ptr ( size_t i) const
inlineconstexpr

Definition at line 50 of file mat.hpp.

◆ NaN()

template<nem::scalar_type _T, size_t _C, size_t _R>
static constexpr mat nem::mat< _T, _C, _R >::NaN ( )
inlinestaticconstexpr

Definition at line 101 of file mat.hpp.

◆ operator+=()

template<nem::scalar_type _T, size_t _C, size_t _R>
mat & nem::mat< _T, _C, _R >::operator+= ( const mat< _T, _C, _R > & other)
inlineconstexpr

Definition at line 103 of file mat.hpp.

◆ operator[]() [1/2]

template<nem::scalar_type _T, size_t _C, size_t _R>
COLUMN_TYPE & nem::mat< _T, _C, _R >::operator[] ( size_t col)
inlineconstexpr

Definition at line 43 of file mat.hpp.

◆ operator[]() [2/2]

template<nem::scalar_type _T, size_t _C, size_t _R>
const COLUMN_TYPE & nem::mat< _T, _C, _R >::operator[] ( size_t col) const
inlineconstexpr

Definition at line 44 of file mat.hpp.

Friends And Related Symbol Documentation

◆ operator!=

template<nem::scalar_type _T, size_t _C, size_t _R>
friend bool operator!= ( const mat< _T, _C, _R > & lhs,
const mat< _T, _C, _R > & rhs )
friend

Definition at line 130 of file mat.hpp.

◆ operator* [1/2]

template<nem::scalar_type _T, size_t _C, size_t _R>
template<size_t OTHER_COLUMNS>
friend mat< ITEM_TYPE, OTHER_COLUMNS, ROWS > operator* ( const mat< _T, _C, _R > & lhs,
const mat< ITEM_TYPE, OTHER_COLUMNS, COLUMNS > & rhs )
friend

Definition at line 85 of file mat.hpp.

◆ operator* [2/2]

template<nem::scalar_type _T, size_t _C, size_t _R>
friend nem::vec< ITEM_TYPE, ROWS > operator* ( const mat< _T, _C, _R > & lhs,
const nem::vec< ITEM_TYPE, COLUMNS > & rhs )
friend

Definition at line 135 of file mat.hpp.

◆ operator+

template<nem::scalar_type _T, size_t _C, size_t _R>
friend mat operator+ ( mat< _T, _C, _R > lhs,
const mat< _T, _C, _R > & rhs )
friend

Definition at line 112 of file mat.hpp.

◆ operator==

template<nem::scalar_type _T, size_t _C, size_t _R>
friend bool operator== ( const mat< _T, _C, _R > & lhs,
const mat< _T, _C, _R > & rhs )
friend

Definition at line 118 of file mat.hpp.

Member Data Documentation

◆ [union]

union { ... } nem::mat< _T, _C, _R >
       C

| m00 m01 m02 m03 Row 0 | m10 m11 m12 m13 Row 1 R | m20 m21 m22 m23 Row 2 | m30 m31 m32 m33 Row 3 | m40 m41 m42 m43 Row 4

Cl0 Cl1 Cl2 Cl3

Storage is column-major: columns[c] is contiguous in memory, and columns[c][r] is the element at row r, column c. operator[] indexes a column first (GLM-style); at(row, col) indexes by mathematical (row, column) notation instead.

◆ COLUMNS

template<nem::scalar_type _T, size_t _C, size_t _R>
size_t nem::mat< _T, _C, _R >::COLUMNS = _C
staticconstexpr

Definition at line 12 of file mat.hpp.

◆ columns

template<nem::scalar_type _T, size_t _C, size_t _R>
COLUMN_TYPE nem::mat< _T, _C, _R >::columns[COLUMNS]

Definition at line 37 of file mat.hpp.

◆ data

template<nem::scalar_type _T, size_t _C, size_t _R>
ITEM_TYPE nem::mat< _T, _C, _R >::data[ITEM_COUNT] = { 0 }

Definition at line 36 of file mat.hpp.

◆ ITEM_COUNT

template<nem::scalar_type _T, size_t _C, size_t _R>
size_t nem::mat< _T, _C, _R >::ITEM_COUNT = ROWS * COLUMNS
staticconstexpr

Definition at line 14 of file mat.hpp.

◆ ROWS

template<nem::scalar_type _T, size_t _C, size_t _R>
size_t nem::mat< _T, _C, _R >::ROWS = _R
staticconstexpr

Definition at line 13 of file mat.hpp.


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