FastUIDraw
Public Types | Public Member Functions | Friends | List of all members
fastuidraw::matrixNxM< N, M, T > Class Template Reference

A generic matrix class. The operator() is overloaded to access elements of the matrix as follows: More...

#include <matrix.hpp>

Public Types

enum  { number_rows = N, number_cols = M }
 
typedef vecN< T, N *M > raw_data_type
 Typedef to underlying vecN that holds the matrix data.
 

Public Member Functions

 matrixNxM (const matrixNxM &obj)
 
 matrixNxM (void)
 
T * c_ptr (void)
 
const T * c_ptr (void) const
 
T & col_row (unsigned int col, unsigned row)
 
const T & col_row (unsigned int col, unsigned row) const
 
T & operator() (unsigned int row, unsigned int col)
 
const T & operator() (unsigned int row, unsigned int col) const
 
matrixNxM operator* (T value) const
 
template<size_t K>
matrixNxM< N, K, T > operator* (const matrixNxM< M, K, T > &matrix) const
 
vecN< T, N > operator* (const vecN< T, M > &in) const
 
matrixNxM operator+ (const matrixNxM &matrix) const
 
matrixNxM operator- (const matrixNxM &matrix) const
 
vecN< T, N *M > & raw_data (void)
 
const vecN< T, N *M > & raw_data (void) const
 
void reset (void)
 
void swap (matrixNxM &obj)
 
void transpose (matrixNxM< M, N, T > &retval) const
 
matrixNxM< M, N, T > transpose (void) const
 

Friends

matrixNxM operator* (T value, const matrixNxM &matrix)
 
vecN< T, M > operator* (const vecN< T, N > &in, const matrixNxM &matrix)
 

Detailed Description

template<size_t N, size_t M, typename T = float>
class fastuidraw::matrixNxM< N, M, T >

A generic matrix class. The operator() is overloaded to access elements of the matrix as follows:

* matrix(0    , 0) matrix(0    , 1) matrix(0    , 2) ... matrix(0    , M - 1)
* matrix(1    , 0) matrix(1    , 1) matrix(1    , 2) ... matrix(1    , M - 1)
* .
* .
* .
* matrix(N - 2, 0) matrix(N - 2, 1) matrix(N - 1, 2) ... matrix(N - 2, M - 1)
* matrix(N - 1, 0) matrix(N - 1, 1) matrix(N - 1, 2) ... matrix(N - 1, M - 1)
* 

The data is represented internally with a 1-dimensional array with the packing order

matrix(row, color) <--> raw_data()[row + N * col]
Template Parameters
Nheight of matrix
Mwidth of matrix
Tmatrix entry type

Definition at line 59 of file matrix.hpp.

Member Enumeration Documentation

◆ anonymous enum

template<size_t N, size_t M, typename T = float>
anonymous enum
Enumerator
number_rows 

Enumeration value for size of the matrix.

number_cols 

Enumeration value for size of the matrix.

Definition at line 72 of file matrix.hpp.

Constructor & Destructor Documentation

◆ matrixNxM() [1/2]

template<size_t N, size_t M, typename T = float>
fastuidraw::matrixNxM< N, M, T >::matrixNxM ( const matrixNxM< N, M, T > &  obj)
inline

Copy-constructor for a NxN matrix.

Parameters
objmatrix to copy

Definition at line 89 of file matrix.hpp.

◆ matrixNxM() [2/2]

template<size_t N, size_t M, typename T = float>
fastuidraw::matrixNxM< N, M, T >::matrixNxM ( void  )
inline

Ctor. Initializes an NxN matrix as diagnols are 1 and other values are 0, for square matrices, that is the identity matrix.

Definition at line 99 of file matrix.hpp.

Member Function Documentation

◆ c_ptr() [1/2]

template<size_t N, size_t M, typename T = float>
T* fastuidraw::matrixNxM< N, M, T >::c_ptr ( void  )
inline

Returns a c-style pointer to the data.

Definition at line 133 of file matrix.hpp.

◆ c_ptr() [2/2]

template<size_t N, size_t M, typename T = float>
const T* fastuidraw::matrixNxM< N, M, T >::c_ptr ( void  ) const
inline

Returns a constant c-style pointer to the data.

Definition at line 139 of file matrix.hpp.

◆ col_row() [1/2]

template<size_t N, size_t M, typename T = float>
T& fastuidraw::matrixNxM< N, M, T >::col_row ( unsigned int  col,
unsigned  row 
)
inline

Returns the named entry of the matrix; provided as a conveniance to interface with systems where access of elements is column then row or to more easily access the transpose of the matrix.

Parameters
colcolumn(horizontal coordinate) in the matrix
rowrow(vertical coordinate) in the matrix

Definition at line 188 of file matrix.hpp.

◆ col_row() [2/2]

template<size_t N, size_t M, typename T = float>
const T& fastuidraw::matrixNxM< N, M, T >::col_row ( unsigned int  col,
unsigned  row 
) const
inline

Returns the named entry of the matrix; provided as a conveniance to interface with systems where access of elements is column then row or to more easily access the transpose of the matrix.

Parameters
colcolumn(horizontal coordinate) in the matrix
rowrow(vertical coordinate) in the matrix

Definition at line 204 of file matrix.hpp.

◆ operator()() [1/2]

template<size_t N, size_t M, typename T = float>
T& fastuidraw::matrixNxM< N, M, T >::operator() ( unsigned int  row,
unsigned int  col 
)
inline

Returns the named entry of the matrix

Parameters
rowrow(vertical coordinate) in the matrix
colcolumn(horizontal coordinate) in the matrix

Definition at line 159 of file matrix.hpp.

◆ operator()() [2/2]

template<size_t N, size_t M, typename T = float>
const T& fastuidraw::matrixNxM< N, M, T >::operator() ( unsigned int  row,
unsigned int  col 
) const
inline

Returns the named entry of the matrix

Parameters
rowrow(vertical coordinate) in the matrix
colcolumn(horizontal coordinate) in the matrix

Definition at line 172 of file matrix.hpp.

◆ operator*() [1/3]

template<size_t N, size_t M, typename T = float>
matrixNxM fastuidraw::matrixNxM< N, M, T >::operator* ( value) const
inline

Multiplies the matrix with a given scalar.

Parameters
valuescalar to multiply with

Definition at line 267 of file matrix.hpp.

◆ operator*() [2/3]

template<size_t N, size_t M, typename T = float>
template<size_t K>
matrixNxM<N, K, T> fastuidraw::matrixNxM< N, M, T >::operator* ( const matrixNxM< M, K, T > &  matrix) const
inline

Multiplies this matrix with the given matrix.

Parameters
matrixtarget matrix

Definition at line 295 of file matrix.hpp.

◆ operator*() [3/3]

template<size_t N, size_t M, typename T = float>
vecN<T, N> fastuidraw::matrixNxM< N, M, T >::operator* ( const vecN< T, M > &  in) const
inline

Computes the value of matrixNxM * vecN

Parameters
inright operand of multiply

Definition at line 319 of file matrix.hpp.

◆ operator+()

template<size_t N, size_t M, typename T = float>
matrixNxM fastuidraw::matrixNxM< N, M, T >::operator+ ( const matrixNxM< N, M, T > &  matrix) const
inline

Operator for adding matrices together.

Parameters
matrixtarget matrix

Definition at line 243 of file matrix.hpp.

◆ operator-()

template<size_t N, size_t M, typename T = float>
matrixNxM fastuidraw::matrixNxM< N, M, T >::operator- ( const matrixNxM< N, M, T > &  matrix) const
inline

Operator for substracting matrices from each other.

Parameters
matrixtarget matrix

Definition at line 255 of file matrix.hpp.

◆ raw_data() [1/2]

template<size_t N, size_t M, typename T = float>
vecN<T, N * M>& fastuidraw::matrixNxM< N, M, T >::raw_data ( void  )
inline

Returns a reference to raw data vector in the matrix.

Definition at line 145 of file matrix.hpp.

◆ raw_data() [2/2]

template<size_t N, size_t M, typename T = float>
const vecN<T, N * M>& fastuidraw::matrixNxM< N, M, T >::raw_data ( void  ) const
inline

Returns a const reference to the raw data vectors in the matrix.

Definition at line 151 of file matrix.hpp.

◆ reset()

template<size_t N, size_t M, typename T = float>
void fastuidraw::matrixNxM< N, M, T >::reset ( void  )
inline

Set matrix as identity.

Definition at line 108 of file matrix.hpp.

◆ swap()

template<size_t N, size_t M, typename T = float>
void fastuidraw::matrixNxM< N, M, T >::swap ( matrixNxM< N, M, T > &  obj)
inline

Swaps the values between this and the parameter matrix.

Parameters
objmatrix to swap values with

Definition at line 124 of file matrix.hpp.

◆ transpose() [1/2]

template<size_t N, size_t M, typename T = float>
void fastuidraw::matrixNxM< N, M, T >::transpose ( matrixNxM< M, N, T > &  retval) const
inline

Compute the transpose of the matrix

Parameters
retvallocation to which to write the transpose

Definition at line 216 of file matrix.hpp.

◆ transpose() [2/2]

template<size_t N, size_t M, typename T = float>
matrixNxM<M, N, T> fastuidraw::matrixNxM< N, M, T >::transpose ( void  ) const
inline

Returns a transpose of the matrix.

Definition at line 231 of file matrix.hpp.

Friends And Related Function Documentation

◆ operator* [1/2]

template<size_t N, size_t M, typename T = float>
matrixNxM operator* ( value,
const matrixNxM< N, M, T > &  matrix 
)
friend

Multiplies the given matrix with the given scalar and returns the resulting matrix.

Parameters
valuescalar to multiply with
matrixtarget matrix to multiply

Definition at line 282 of file matrix.hpp.

◆ operator* [2/2]

template<size_t N, size_t M, typename T = float>
vecN<T, M> operator* ( const vecN< T, N > &  in,
const matrixNxM< N, M, T > &  matrix 
)
friend

Computes the value of vecN * matrixNxM

Parameters
inleft operand of multiply
matrixright operand of multiply

Definition at line 342 of file matrix.hpp.


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