MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
math::Matrix< T, N, M > Class Template Reference

Matrix class for arbitrary dimensions and types. More...

#include <matrix.h>

Public Types

typedef T ValueType
 

Public Member Functions

template<typename O >
 Matrix (Matrix< O, N, M > const &other)
 Copy ctor from matrix of different type.
 
 Matrix (Matrix< T, N, M > const &other)
 Copy ctor from matrix of same type.
 
 Matrix (T const &value)
 Ctor that initializes ALL elements.
 
 Matrix (T const *values)
 Ctor taking a pointer to initialize values.
 
 Matrix (void)
 Default ctor that leaves values uninitialized.
 
T * begin (void)
 
T const * begin (void) const
 
Vector< T, N > col (int index) const
 Returns a column of the matrix as vector.
 
Matrix< T, N, M-1 > delete_col (int index) const
 Returns a new matrix with the specified column deleted.
 
Matrix< T, N-1, M > delete_row (int index) const
 Returns a new matrix with the specified row deleted.
 
T * end (void)
 
T const * end (void) const
 
Matrix< T, N, M > & fill (T const &value)
 Fills all vector elements with the given value.
 
template<int O>
Matrix< T, N, M+O > hstack (Matrix< T, N, O > const &other) const
 Stacks this (left) and another matrix (right) horizontally.
 
Matrix< T, N, M+1 > hstack (Vector< T, N > const &other) const
 Stacks this matrix (left) and another vector (right) horizontally.
 
bool is_similar (Matrix< T, N, M > const &other, T const &epsilon) const
 Component-wise similarity using epsilon checks.
 
bool is_square (void) const
 Tests if the matrix is square.
 
maximum (void) const
 Returns the largest element in the matrix.
 
minimum (void) const
 Returns the smallest element in the matrix.
 
template<int U>
Matrix< T, N, U > mult (Matrix< T, M, U > const &rhs) const
 Matrix with matrix multiplication.
 
Vector< T, N > mult (Vector< T, M > const &rhs) const
 Matrix with vector multiplication.
 
Vector< T, N-1 > mult (Vector< T, M-1 > const &rhs, T const &v) const
 Matrix with smaller vector multiplication.
 
Matrix< T, N, M > & negate (void)
 Component-wise negation on self, returns self.
 
Matrix< T, N, M > negated (void) const
 Returns a component-wise negation on copy of self.
 
bool operator!= (Matrix< T, N, M > const &rhs) const
 Comparison operator.
 
T & operator() (int row, int col)
 Element access operator.
 
T const & operator() (int row, int col) const
 Const element access operator.
 
template<int U>
Matrix< T, N, U > operator* (Matrix< T, M, U > const &rhs) const
 Multiplication with other matrix.
 
Matrix< T, N, M > operator* (T const &rhs) const
 Component-wise multiplication with scalar.
 
Vector< T, N > operator* (Vector< T, M > const &rhs) const
 Multiplication with other vector.
 
T * operator* (void)
 Dereference operator to value array.
 
T const * operator* (void) const
 Const dereference operator to value array.
 
Matrix< T, N, M > & operator*= (T const &rhs)
 Component-wise self-multiplication with scalar.
 
Matrix< T, N, M > operator+ (Matrix< T, N, M > const &rhs) const
 Addition with other matrix.
 
Matrix< T, N, M > operator+ (T const &rhs) const
 Component-wise addition with scalar.
 
Matrix< T, N, M > & operator+= (Matrix< T, N, M > const &rhs)
 Self-addition with other matrix.
 
Matrix< T, N, M > & operator+= (T const &rhs)
 Component-wise self-addition with scalar.
 
Matrix< T, N, M > operator- (Matrix< T, N, M > const &rhs) const
 Substraction with other matrix.
 
Matrix< T, N, M > operator- (T const &rhs) const
 Component-wise substraction with scalar.
 
Matrix< T, N, M > operator- (void) const
 Component-wise negation.
 
Matrix< T, N, M > & operator-= (Matrix< T, N, M > const &rhs)
 Self-substraction with other matrix.
 
Matrix< T, N, M > & operator-= (T const &rhs)
 Component-wise self-substraction with scalar.
 
Matrix< T, N, M > operator/ (T const &rhs) const
 Component-wise division by scalar.
 
Matrix< T, N, M > & operator/= (T const &rhs)
 Component-wise self-division by scalar.
 
template<typename O >
Matrix< T, N, M > & operator= (Matrix< O, N, M > const &rhs)
 Assignment operator from different type.
 
Matrix< T, N, M > & operator= (Matrix< T, N, M > const &rhs)
 Assignment operator.
 
bool operator== (Matrix< T, N, M > const &rhs) const
 Comparison operator.
 
T & operator[] (unsigned int i)
 Element linear access operator.
 
T const & operator[] (unsigned int i) const
 Const element linear access operator.
 
Vector< T, M > row (int index) const
 Returns a row of the matrix as vector.
 
Matrix< T, M, N > & transpose (void)
 Transpose the current matrix.
 
Matrix< T, M, N > transposed (void) const
 Returns a transposed copy of self by treating rows as columns.
 
template<int O>
Matrix< T, N+O, M > vstack (Matrix< T, O, M > const &other) const
 Stacks this (top) and another matrix (bottom) vertically.
 
Matrix< T, N+1, M > vstack (Vector< T, M > const &other) const
 Stacks this matrix (top) and another vector (bottom) vertically.
 

Static Public Attributes

static int constexpr cols = M
 
static int constexpr rows = N
 

Protected Attributes

m [N *M]
 

Detailed Description

template<typename T, int N, int M>
class math::Matrix< T, N, M >

Matrix class for arbitrary dimensions and types.

This class uses conventions from mathematics:

Type: Matrix<T,ROWS,COLS> Access: M(row, col)

E.g., a matrix with 3 rows and 4 columns has type Matrix<T,3,4>. The lower right element is accessed with M(2,3);

Definition at line 53 of file matrix.h.

Member Typedef Documentation

◆ ValueType

template<typename T , int N, int M>
typedef T math::Matrix< T, N, M >::ValueType

Definition at line 56 of file matrix.h.

Constructor & Destructor Documentation

◆ Matrix() [1/5]

template<typename T , int N, int M>
math::Matrix< T, N, M >::Matrix ( void  )
inline

Default ctor that leaves values uninitialized.

Definition at line 231 of file matrix.h.

◆ Matrix() [2/5]

template<typename T , int N, int M>
math::Matrix< T, N, M >::Matrix ( T const *  values)
inlineexplicit

Ctor taking a pointer to initialize values.

Definition at line 237 of file matrix.h.

◆ Matrix() [3/5]

template<typename T , int N, int M>
math::Matrix< T, N, M >::Matrix ( T const &  value)
inlineexplicit

Ctor that initializes ALL elements.

Definition at line 244 of file matrix.h.

◆ Matrix() [4/5]

template<typename T , int N, int M>
math::Matrix< T, N, M >::Matrix ( Matrix< T, N, M > const &  other)
inline

Copy ctor from matrix of same type.

Definition at line 251 of file matrix.h.

◆ Matrix() [5/5]

template<typename T , int N, int M>
template<typename O >
math::Matrix< T, N, M >::Matrix ( Matrix< O, N, M > const &  other)
inline

Copy ctor from matrix of different type.

Definition at line 259 of file matrix.h.

Member Function Documentation

◆ begin() [1/2]

template<typename T , int N, int M>
T * math::Matrix< T, N, M >::begin ( void  )
inline

Definition at line 506 of file matrix.h.

◆ begin() [2/2]

template<typename T , int N, int M>
T const * math::Matrix< T, N, M >::begin ( void  ) const
inline

Definition at line 513 of file matrix.h.

◆ col()

template<typename T , int N, int M>
Vector< T, N > math::Matrix< T, N, M >::col ( int  index) const
inline

Returns a column of the matrix as vector.

Definition at line 330 of file matrix.h.

◆ delete_col()

template<typename T , int N, int M>
Matrix< T, N, M-1 > math::Matrix< T, N, M >::delete_col ( int  index) const
inline

Returns a new matrix with the specified column deleted.

Definition at line 408 of file matrix.h.

◆ delete_row()

template<typename T , int N, int M>
Matrix< T, N-1, M > math::Matrix< T, N, M >::delete_row ( int  index) const
inline

Returns a new matrix with the specified row deleted.

Definition at line 392 of file matrix.h.

◆ end() [1/2]

template<typename T , int N, int M>
T * math::Matrix< T, N, M >::end ( void  )
inline

Definition at line 520 of file matrix.h.

◆ end() [2/2]

template<typename T , int N, int M>
T const * math::Matrix< T, N, M >::end ( void  ) const
inline

Definition at line 527 of file matrix.h.

◆ fill()

template<typename T , int N, int M>
Matrix< T, N, M > & math::Matrix< T, N, M >::fill ( T const &  value)
inline

Fills all vector elements with the given value.

Definition at line 294 of file matrix.h.

◆ hstack() [1/2]

template<typename T , int N, int M>
template<int O>
Matrix< T, N, M+O > math::Matrix< T, N, M >::hstack ( Matrix< T, N, O > const &  other) const
inline

Stacks this (left) and another matrix (right) horizontally.

Definition at line 341 of file matrix.h.

◆ hstack() [2/2]

template<typename T , int N, int M>
Matrix< T, N, M+1 > math::Matrix< T, N, M >::hstack ( Vector< T, N > const &  other) const
inline

Stacks this matrix (left) and another vector (right) horizontally.

Definition at line 367 of file matrix.h.

◆ is_similar()

template<typename T , int N, int M>
bool math::Matrix< T, N, M >::is_similar ( Matrix< T, N, M > const &  other,
T const &  epsilon 
) const
inline

Component-wise similarity using epsilon checks.

Definition at line 496 of file matrix.h.

◆ is_square()

template<typename T , int N, int M>
bool math::Matrix< T, N, M >::is_square ( void  ) const
inline

Tests if the matrix is square.

Definition at line 302 of file matrix.h.

◆ maximum()

template<typename T , int N, int M>
T math::Matrix< T, N, M >::maximum ( void  ) const
inline

Returns the largest element in the matrix.

Definition at line 316 of file matrix.h.

◆ minimum()

template<typename T , int N, int M>
T math::Matrix< T, N, M >::minimum ( void  ) const
inline

Returns the smallest element in the matrix.

Definition at line 309 of file matrix.h.

◆ mult() [1/3]

template<typename T , int N, int M>
template<int U>
Matrix< T, N, U > math::Matrix< T, N, M >::mult ( Matrix< T, M, U > const &  rhs) const
inline

Matrix with matrix multiplication.

Definition at line 462 of file matrix.h.

◆ mult() [2/3]

template<typename T , int N, int M>
Vector< T, N > math::Matrix< T, N, M >::mult ( Vector< T, M > const &  rhs) const
inline

Matrix with vector multiplication.

Definition at line 475 of file matrix.h.

◆ mult() [3/3]

template<typename T , int N, int M>
Vector< T, N-1 > math::Matrix< T, N, M >::mult ( Vector< T, M-1 > const &  rhs,
T const &  v 
) const
inline

Matrix with smaller vector multiplication.

Definition at line 485 of file matrix.h.

◆ negate()

template<typename T , int N, int M>
Matrix< T, N, M > & math::Matrix< T, N, M >::negate ( void  )
inline

Component-wise negation on self, returns self.

Definition at line 426 of file matrix.h.

◆ negated()

template<typename T , int N, int M>
Matrix< T, N, M > math::Matrix< T, N, M >::negated ( void  ) const
inline

Returns a component-wise negation on copy of self.

Definition at line 434 of file matrix.h.

◆ operator!=()

template<typename T , int N, int M>
bool math::Matrix< T, N, M >::operator!= ( Matrix< T, N, M > const &  rhs) const
inline

Comparison operator.

Definition at line 584 of file matrix.h.

◆ operator()() [1/2]

template<typename T , int N, int M>
T & math::Matrix< T, N, M >::operator() ( int  row,
int  col 
)
inline

Element access operator.

Definition at line 550 of file matrix.h.

◆ operator()() [2/2]

template<typename T , int N, int M>
T const & math::Matrix< T, N, M >::operator() ( int  row,
int  col 
) const
inline

Const element access operator.

Definition at line 557 of file matrix.h.

◆ operator*() [1/5]

template<typename T , int N, int M>
template<int U>
Matrix< T, N, U > math::Matrix< T, N, M >::operator* ( Matrix< T, M, U > const &  rhs) const
inline

Multiplication with other matrix.

Definition at line 631 of file matrix.h.

◆ operator*() [2/5]

template<typename T , int N, int M>
Matrix< T, N, M > math::Matrix< T, N, M >::operator* ( T const &  rhs) const
inline

Component-wise multiplication with scalar.

Definition at line 698 of file matrix.h.

◆ operator*() [3/5]

template<typename T , int N, int M>
Vector< T, N > math::Matrix< T, N, M >::operator* ( Vector< T, M > const &  rhs) const
inline

Multiplication with other vector.

Definition at line 638 of file matrix.h.

◆ operator*() [4/5]

template<typename T , int N, int M>
T * math::Matrix< T, N, M >::operator* ( void  )
inline

Dereference operator to value array.

Definition at line 536 of file matrix.h.

◆ operator*() [5/5]

template<typename T , int N, int M>
T const * math::Matrix< T, N, M >::operator* ( void  ) const
inline

Const dereference operator to value array.

Definition at line 543 of file matrix.h.

◆ operator*=()

template<typename T , int N, int M>
Matrix< T, N, M > & math::Matrix< T, N, M >::operator*= ( T const &  rhs)
inline

Component-wise self-multiplication with scalar.

Definition at line 690 of file matrix.h.

◆ operator+() [1/2]

template<typename T , int N, int M>
Matrix< T, N, M > math::Matrix< T, N, M >::operator+ ( Matrix< T, N, M > const &  rhs) const
inline

Addition with other matrix.

Definition at line 653 of file matrix.h.

◆ operator+() [2/2]

template<typename T , int N, int M>
Matrix< T, N, M > math::Matrix< T, N, M >::operator+ ( T const &  rhs) const
inline

Component-wise addition with scalar.

Definition at line 683 of file matrix.h.

◆ operator+=() [1/2]

template<typename T , int N, int M>
Matrix< T, N, M > & math::Matrix< T, N, M >::operator+= ( Matrix< T, N, M > const &  rhs)
inline

Self-addition with other matrix.

Definition at line 645 of file matrix.h.

◆ operator+=() [2/2]

template<typename T , int N, int M>
Matrix< T, N, M > & math::Matrix< T, N, M >::operator+= ( T const &  rhs)
inline

Component-wise self-addition with scalar.

Definition at line 675 of file matrix.h.

◆ operator-() [1/3]

template<typename T , int N, int M>
Matrix< T, N, M > math::Matrix< T, N, M >::operator- ( Matrix< T, N, M > const &  rhs) const
inline

Substraction with other matrix.

Definition at line 623 of file matrix.h.

◆ operator-() [2/3]

template<typename T , int N, int M>
Matrix< T, N, M > math::Matrix< T, N, M >::operator- ( T const &  rhs) const
inline

Component-wise substraction with scalar.

Definition at line 668 of file matrix.h.

◆ operator-() [3/3]

template<typename T , int N, int M>
Matrix< T, N, M > math::Matrix< T, N, M >::operator- ( void  ) const
inline

Component-wise negation.

Definition at line 608 of file matrix.h.

◆ operator-=() [1/2]

template<typename T , int N, int M>
Matrix< T, N, M > & math::Matrix< T, N, M >::operator-= ( Matrix< T, N, M > const &  rhs)
inline

Self-substraction with other matrix.

Definition at line 615 of file matrix.h.

◆ operator-=() [2/2]

template<typename T , int N, int M>
Matrix< T, N, M > & math::Matrix< T, N, M >::operator-= ( T const &  rhs)
inline

Component-wise self-substraction with scalar.

Definition at line 660 of file matrix.h.

◆ operator/()

template<typename T , int N, int M>
Matrix< T, N, M > math::Matrix< T, N, M >::operator/ ( T const &  rhs) const
inline

Component-wise division by scalar.

Definition at line 713 of file matrix.h.

◆ operator/=()

template<typename T , int N, int M>
Matrix< T, N, M > & math::Matrix< T, N, M >::operator/= ( T const &  rhs)
inline

Component-wise self-division by scalar.

Definition at line 705 of file matrix.h.

◆ operator=() [1/2]

template<typename T , int N, int M>
template<typename O >
Matrix< T, N, M > & math::Matrix< T, N, M >::operator= ( Matrix< O, N, M > const &  rhs)
inline

Assignment operator from different type.

Definition at line 600 of file matrix.h.

◆ operator=() [2/2]

template<typename T , int N, int M>
Matrix< T, N, M > & math::Matrix< T, N, M >::operator= ( Matrix< T, N, M > const &  rhs)
inline

Assignment operator.

Definition at line 591 of file matrix.h.

◆ operator==()

template<typename T , int N, int M>
bool math::Matrix< T, N, M >::operator== ( Matrix< T, N, M > const &  rhs) const
inline

Comparison operator.

Definition at line 577 of file matrix.h.

◆ operator[]() [1/2]

template<typename T , int N, int M>
T & math::Matrix< T, N, M >::operator[] ( unsigned int  i)
inline

Element linear access operator.

Definition at line 563 of file matrix.h.

◆ operator[]() [2/2]

template<typename T , int N, int M>
T const & math::Matrix< T, N, M >::operator[] ( unsigned int  i) const
inline

Const element linear access operator.

Definition at line 570 of file matrix.h.

◆ row()

template<typename T , int N, int M>
Vector< T, M > math::Matrix< T, N, M >::row ( int  index) const
inline

Returns a row of the matrix as vector.

Definition at line 323 of file matrix.h.

◆ transpose()

template<typename T , int N, int M>
Matrix< T, M, N > & math::Matrix< T, N, M >::transpose ( void  )
inline

Transpose the current matrix.

Only available for square matrices.

Definition at line 441 of file matrix.h.

◆ transposed()

template<typename T , int N, int M>
Matrix< T, M, N > math::Matrix< T, N, M >::transposed ( void  ) const
inline

Returns a transposed copy of self by treating rows as columns.

Definition at line 448 of file matrix.h.

◆ vstack() [1/2]

template<typename T , int N, int M>
template<int O>
Matrix< T, N+O, M > math::Matrix< T, N, M >::vstack ( Matrix< T, O, M > const &  other) const
inline

Stacks this (top) and another matrix (bottom) vertically.

Definition at line 357 of file matrix.h.

◆ vstack() [2/2]

template<typename T , int N, int M>
Matrix< T, N+1, M > math::Matrix< T, N, M >::vstack ( Vector< T, M > const &  other) const
inline

Stacks this matrix (top) and another vector (bottom) vertically.

Definition at line 382 of file matrix.h.

Member Data Documentation

◆ cols

template<typename T , int N, int M>
int constexpr math::Matrix< T, N, M >::cols = M
staticconstexpr

Definition at line 59 of file matrix.h.

◆ m

template<typename T , int N, int M>
T math::Matrix< T, N, M >::m[N *M]
protected

Definition at line 212 of file matrix.h.

◆ rows

template<typename T , int N, int M>
int constexpr math::Matrix< T, N, M >::rows = N
staticconstexpr

Definition at line 58 of file matrix.h.


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