Allolib  1.0
C++ Components For Interactive Multimedia
al::Mat< N, T > Class Template Reference

Fixed-size n-by-n square matrix. More...

#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/math/al_Mat.hpp>

Public Member Functions

 Mat ()
 Default constructor that initializes elements to zero.
 
template<class U >
 Mat (const U *arr)
 
template<class U >
 Mat (const Mat< N, U > &src)
 
 Mat (const MatNoInit &v)
 Construct without initializing elements.
 
 Mat (const T &r1c1, const T &r1c2, const T &r2c1, const T &r2c2)
 2x2 matrix constructor with element initialization
 
 Mat (const T &r1c1, const T &r1c2, const T &r1c3, const T &r2c1, const T &r2c2, const T &r2c3, const T &r3c1, const T &r3c2, const T &r3c3)
 3x3 matrix constructor with element initialization
 
 Mat (const T &r1c1, const T &r1c2, const T &r1c3, const T &r1c4, const T &r2c1, const T &r2c2, const T &r2c3, const T &r2c4, const T &r3c1, const T &r3c2, const T &r3c3, const T &r3c4, const T &r4c1, const T &r4c2, const T &r4c3, const T &r4c4)
 4x4 matrix constructor with element initialization
 
const T * elems () const
 Get read-only pointer to elements.
 
T * elems ()
 Get read-write pointer to elements.
 
T & operator[] (int i)
 Set element at index with no bounds checking.
 
const T & operator[] (int i) const
 Get element at index with no bounds checking.
 
T & operator() (int i, int j)
 Set element at row i, column j.
 
const T & operator() (int i, int j) const
 Get element at row i, column j.
 
Vec< N, T > col (int i) const
 Return column i as vector.
 
Vec< N, T > row (int i) const
 Return row i as vector.
 
Vec< N, T > diagonal () const
 Return diagonal.
 
Mattranspose ()
 Transpose elements.
 
template<int M>
Mat< M, T > sub (int row=0, int col=0) const
 Get an MxM submatrix.
 
Mat< N - 1, T > submatrix (int row, int col) const
 Returns a submatrix by removing one row and column.
 
Vec< N *N, T > & vec ()
 Return matrix punned as a vector.
 
Matoperator*= (const Mat &v)
 
Matoperator+= (const Mat &v)
 
Matoperator-= (const Mat &v)
 
Matoperator+= (const T &v)
 
Matoperator-= (const T &v)
 
Matoperator*= (const T &v)
 
Matoperator/= (const T &v)
 
Mat operator- () const
 
Mat operator+ (const Mat &v) const
 
Mat operator- (const Mat &v) const
 
Mat operator* (const Mat &v) const
 
Mat operator+ (const T &v) const
 
Mat operator- (const T &v) const
 
Mat operator* (const T &v) const
 
Mat operator/ (const T &v) const
 
Matset (const T &v)
 Set all elements to value.
 
template<class U >
Matset (const Mat< N, U > &v)
 Set elements from another matrix.
 
template<class U >
Matset (const U *arr)
 Set elements in column-major order from C array.
 
template<class U >
Matset (const U *arr, int numElements, int matOffset, int matStride=1)
 Set elements in column-major order from C array. More...
 
Matset (const T &r1c1, const T &r1c2, const T &r2c1, const T &r2c2, int row=0, int col=0)
 Set 2-by-2 (sub)matrix from arguments.
 
Matset (const T &r1c1, const T &r1c2, const T &r1c3, const T &r2c1, const T &r2c2, const T &r2c3, const T &r3c1, const T &r3c2, const T &r3c3, int row=0, int col=0)
 Set 3-by-3 (sub)matrix from arguments.
 
Matset (const T &r1c1, const T &r1c2, const T &r1c3, const T &r1c4, const T &r2c1, const T &r2c2, const T &r2c3, const T &r2c4, const T &r3c1, const T &r3c2, const T &r3c3, const T &r3c4, const T &r4c1, const T &r4c2, const T &r4c3, const T &r4c4, int row=0, int col=0)
 Set 4-by-4 (sub)matrix from arguments.
 
MatsetCol2 (const T &v1, const T &v2, int col=0, int row=0)
 Set a (sub)column.
 
MatsetCol3 (const T &v1, const T &v2, const T &v3, int col=0, int row=0)
 Set a (sub)column.
 
MatsetCol4 (const T &v1, const T &v2, const T &v3, const T &v4, int col=0, int row=0)
 Set a (sub)column.
 
MatsetIdentity ()
 Set elements on diagonal to one and all others to zero.
 
cofactor (int row, int col) const
 Get cofactor.
 
Mat< N, T > cofactorMatrix () const
 Get cofactor matrix.
 
trace () const
 Get trace (sum of diagonal elements)
 
Mat< N, T > inversed () const
 
Matrotate (double angle, int dim1, int dim2)
 Rotate transformation matrix on a local plane (A' = AR) More...
 
template<int M>
MatrotateGlobal (double angle, int dim1, int dim2)
 Rotate submatrix on a global plane (A' = RA)
 
MatrotateGlobal (double angle, int dim1, int dim2)
 Rotate transformation matrix on a global plane (A' = RA)
 
template<class V >
Matscale (const Vec< N - 1, V > &amount)
 Scale transformation matrix.
 
template<class V >
Matscale (const V &amount)
 Scale transformation matrix by uniform amount.
 
template<typename... Vals>
Matscale (Vals... vals)
 Scale transformation matrix.
 
template<class V >
MatscaleGlobal (const Vec< N - 1, V > &amount)
 Scale transformation matrix global coordinates.
 
template<class V >
Mattranslate (const Vec< N - 1, V > &amount)
 Translate transformation matrix.
 
template<class V >
Mattranslate (const V &amount)
 Translate transformation matrix by same amount in all directions.
 
template<typename... Vals>
Mattranslate (Vals... vals)
 Translate transformation matrix.
 
void print (std::ostream &stream) const
 Print to file (stream)
 

Static Public Member Functions

static Mat identity ()
 Get identity matrix.
 
static Mat rotation (double angle, int dim1, int dim2)
 Get a rotation transform matrix.
 
template<class V >
static Mat scaling (const Vec< N - 1, V > &v)
 Get a scaling transform matrix.
 
template<class V >
static Mat scaling (V v)
 Get a scaling transform matrix.
 
template<typename... Vals>
static Mat scaling (Vals... vals)
 Get a scaling transform matrix.
 
template<class V >
static Mat translation (const Vec< N - 1, V > &v)
 Get a translation transform matrix.
 
template<typename... Vals>
static Mat translation (Vals... vals)
 Get a translation transform matrix.
 
static Matpun (T *src)
 Returns C array type punned into a matrix.
 
static const Matpun (const T *src)
 
static int size ()
 Returns total number of elements.
 
static Matmultiply (Mat &r, const Mat &a, const Mat &b)
 Computes matrix product r = a * b. More...
 
template<class U >
static Vec< N, U > & multiply (Vec< N, U > &r, const Mat &m, const Vec< N, U > &vCol)
 Computes product of matrix multiplied by column vector, r = m * vCol.
 
template<class U >
static Vec< N, U > & multiply (Vec< N, U > &r, const Vec< N, U > &vRow, const Mat &m)
 Computes product of row vector multiplied by matrix, r = vRow * m.
 

Public Attributes

mElems [N *N]
 Column-major array of elements.
 

Detailed Description

template<int N, class T>
class al::Mat< N, T >

Fixed-size n-by-n square matrix.

Elements are stored in column-major format.

Definition at line 78 of file al_Mat.hpp.

Constructor & Destructor Documentation

◆ Mat() [1/2]

template<int N, class T >
template<class U >
al::Mat< N, T >::Mat ( const U *  arr)
inline
Parameters
[in]arrone dimensional array in column-major

Definition at line 91 of file al_Mat.hpp.

◆ Mat() [2/2]

template<int N, class T >
template<class U >
al::Mat< N, T >::Mat ( const Mat< N, U > &  src)
inline
Parameters
[in]srcmatrix with same dimension, but possibly different type

Definition at line 97 of file al_Mat.hpp.

Member Function Documentation

◆ multiply()

template<int N, class T >
static Mat& al::Mat< N, T >::multiply ( Mat< N, T > &  r,
const Mat< N, T > &  a,
const Mat< N, T > &  b 
)
inlinestatic

Computes matrix product r = a * b.

Returns reference to result

Definition at line 305 of file al_Mat.hpp.

◆ rotate()

template<int N, class T >
Mat& al::Mat< N, T >::rotate ( double  angle,
int  dim1,
int  dim2 
)
inline

Rotate transformation matrix on a local plane (A' = AR)

Parameters
[in]angleangle of rotation, in radians
[in]dim1local coordinate frame axis to rotate away from
[in]dim2local coordinate frame axis to rotate towards

Definition at line 470 of file al_Mat.hpp.

◆ set()

template<int N, class T >
template<class U >
Mat& al::Mat< N, T >::set ( const U *  arr,
int  numElements,
int  matOffset,
int  matStride = 1 
)
inline

Set elements in column-major order from C array.

Parameters
[in]arr1D array from which to copy (stride=1)
[in]numElementsnumber of elements to copy
[in]matOffsetindex offset into matrix
[in]matStrideamount to stride through matrix

Definition at line 357 of file al_Mat.hpp.


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