MorphoGraphX  2.0-1-227
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | Related Functions | List of all members
mgx::Matrix< nRows, nCols, T > Class Template Reference

#include <Matrix.hpp>

Public Types

typedef T value_type
 
typedef T & reference_type
 
typedef T * pointer_type
 
typedef T * iterator
 

Public Member Functions

CU_HOST_DEVICE Matrix (void)
 Create a matrix filled with 0s. More...
 
template<typename T1 >
CU_HOST_DEVICE Matrix (const Matrix< nRows, nCols, T1 > &mat)
 Copy a matrix. More...
 
template<typename T1 >
CU_HOST_DEVICE Matrix (const Vector< nCols, T1 > *vecs)
 Fill the matrix with the array of vectors. More...
 
template<typename T1 >
CU_HOST_DEVICE Matrix (const Vector< nCols, T1 > &r0, const Vector< nCols, T1 > &r1, const Vector< nCols, T1 > &r2)
 Initialize a 3 row matrix. More...
 
template<typename T1 >
CU_HOST_DEVICE Matrix (const T1 *values)
 Fill in the matrix with the values. More...
 
CU_HOST_DEVICE Matrix (const T *values)
 Fill in the matrix with the values. More...
 
CU_HOST_DEVICE Matrix (const T &value)
 Create a diagonal matrix. More...
 
const CU_HOST_DEVICE T * c_data () const
 Returns a constant raw pointer on the data. More...
 
CU_HOST_DEVICE T * data ()
 Returns a raw pointer on the data. More...
 
CU_HOST_DEVICE Matrix operator- (void) const
 Matrix subtraction. More...
 
CU_HOST_DEVICE Matrix operator+ (const Matrix &mat) const
 Matrix addition. More...
 
CU_HOST_DEVICE Matrix operator- (const Matrix &mat) const
 
CU_HOST_DEVICE Matrix operator* (const T &scalar) const
 Matrix-scalar multiplication. More...
 
CU_HOST_DEVICE Matrix operator/ (const T &scalar) const
 Matrix-scalar division. More...
 
CU_HOST_DEVICE Vector< nRows, T > operator* (const Vector< nCols, T > &vec) const
 Matrix*Column Vector. More...
 
CU_HOST_DEVICE Matrixoperator= (const Matrix &mat)
 
CU_HOST_DEVICE Matrixoperator+= (const Matrix &mat)
 
CU_HOST_DEVICE Matrixoperator-= (const Matrix &mat)
 
CU_HOST_DEVICE Matrixoperator*= (const T &scalar)
 
CU_HOST_DEVICE Matrixoperator/= (const T &scalar)
 
CU_HOST_DEVICE Matrixoperator*= (const Matrix &mat)
 
CU_HOST_DEVICE bool operator== (const Matrix &mat) const
 Element-wise equality. More...
 
CU_HOST_DEVICE bool operator!= (const Matrix &mat) const
 Element-wise inequality. More...
 
CU_HOST_DEVICE bool operator< (const Matrix &other) const
 Comparison operator. More...
 
CU_HOST_DEVICE Vector< nCols, T > & operator[] (size_t idx)
 Returns the nth row. More...
 
CU_HOST_DEVICE Vector< nCols, T > operator[] (size_t idx) const
 Returns the nth row. More...
 
CU_HOST_DEVICE T & operator() (size_t i, size_t j)
 Return the value at row i, column j. More...
 
CU_HOST_DEVICEoperator() (size_t i, size_t j) const
 Return the value at row i, column j. More...
 
CU_HOST_DEVICE Matrixzero (void)
 Set the matrix to all zero. More...
 
CU_HOST_DEVICE Matrixoperator= (const T &value)
 Set the matrix to a diagonal matrix. More...
 
CU_HOST_DEVICE Matrix< nCols, nRows, T > operator~ ()
 Transpose the matrix. More...
 
CU_HOST_DEVICEtrace () const
 Trace of the matrix. More...
 
CU_HOST_DEVICE void fillArray (T *array)
 
CU_HOST_DEVICE Vector< nRows, T > diag () const
 Return the diagonal vector, if the matrix is square. More...
 

Static Public Member Functions

static CU_HOST_DEVICE Vector< 2, size_t > size ()
 Returns the size of the matrix. More...
 
static CU_HOST_DEVICE size_t nbRows ()
 Returns the number of rows of the matrix. More...
 
static CU_HOST_DEVICE size_t nbColumns ()
 Returns the number of columns of the matrix. More...
 
static CU_HOST_DEVICE Matrix identity ()
 Returns an identity matrix. More...
 
static CU_HOST_DEVICE Matrix< 3, 3, T > rotation (const Vector< 3, T > &direction, T angle)
 Creates the 3x3 matrix corresponding to a rotation. More...
 
static CU_HOST_DEVICE Matrix< 4, 4, T > rotation (const Vector< 4, T > &direction, T angle)
 Creates the 4x4 matrix corresponding to a rotation. More...
 

Public Attributes

const typedef T & const_reference_type
 
const typedef T * const_pointer_type
 
const typedef T * const_iterator
 

Static Public Attributes

static const size_t numcols
 
static const size_t numrows
 

Friends

CU_HOST_DEVICE friend Matrix operator* (const T &scalar, const Matrix &mat)
 Matrix-scalar multiplication. More...
 
QTextStream & operator<< (QTextStream &out, const Matrix &mat)
 
QTextStream & operator>> (QTextStream &in, Matrix &mat)
 
CU_HOST_DEVICE friend std::ostream & operator<< (std::ostream &out, const Matrix &mat)
 
CU_HOST_DEVICE friend std::istream & operator>> (std::istream &in, Matrix &mat)
 

Related Functions

(Note that these are not member functions.)

template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Vector< nCols, T > operator* (const Vector< nCols, T > &vec, const Matrix< nRows, nCols, T > &mat)
 Row-Vector - Matrix multipliation. More...
 
template<size_t nRows, size_t nSize, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > operator* (const Matrix< nRows, nSize, T > &mat1, const Matrix< nSize, nCols, T > &mat2)
 Matrix multiplication. More...
 
template<typename T >
T CU_HOST_DEVICE det (const Matrix< 1, 1, T > &mat)
 Determinant of the matrix. More...
 
template<typename T >
T CU_HOST_DEVICE det (const Matrix< 2, 2, T > &mat)
 Determinant of the matrix. More...
 
template<typename T >
T CU_HOST_DEVICE det (const Matrix< 3, 3, T > &mat)
 Determinant of the matrix. More...
 
template<size_t nRows, typename T >
T CU_HOST_DEVICE det (const Matrix< nRows, nRows, T > &mat)
 Determinant of the matrix. More...
 
template<size_t nRows, typename T >
CU_HOST_DEVICEcofactor (const Matrix< nRows, nRows, T > &mat, size_t i, size_t j)
 Returns the cofactor of the matrix for position (i,j) More...
 
template<typename T >
CU_HOST_DEVICE Matrix< 1, 1, T > inverse (const Matrix< 1, 1, T > &mat)
 Inverse the matrix. More...
 
template<typename T >
CU_HOST_DEVICE Matrix< 2, 2, T > inverse (const Matrix< 2, 2, T > &mat)
 Inverse the matrix. More...
 
template<typename T >
CU_HOST_DEVICE Matrix< 3, 3, T > inverse (const Matrix< 3, 3, T > &mat)
 Inverse the matrix. More...
 
template<typename T >
CU_HOST_DEVICE Matrix< 4, 4, T > inverse (const Matrix< 4, 4, T > &mat)
 Inverse the matrix. More...
 
template<size_t nRows, typename T >
CU_HOST_DEVICE Matrix< nRows, nRows, T > inverse (const Matrix< nRows, nRows, T > &mat)
 Inverse the matrix. More...
 
template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nCols, nRows, T > transpose (const Matrix< nRows, nCols, T > &mat)
 Transpose a matrix. More...
 
template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICEnorm (const Matrix< nRows, nCols, T > &mat)
 Return the norm of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICEnormsq (const Matrix< nRows, nCols, T > &mat)
 Return the square norm of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map (const T &(*fct)(const T &), const Matrix< nRows, nCols, T > &m)
 Apply a unary function to each element of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map (T(*fct)(T), const Matrix< nRows, nCols, T > &m)
 Apply a unary function to each element of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map (T(*fct)(const T &), const Matrix< nRows, nCols, T > &m)
 Apply a unary function to each element of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T , typename T1 >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map (const T &(*fct)(const T1 &), const Matrix< nRows, nCols, T1 > &m)
 Apply a unary function to each element of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T , typename T1 >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map (T(*fct)(T1), const Matrix< nRows, nCols, T1 > &m)
 Apply a unary function to each element of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T , typename T1 >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map (T(*fct)(const T1 &), const Matrix< nRows, nCols, T1 > &m)
 Apply a unary function to each element of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map (T(*fct)(T, T), const Matrix< nRows, nCols, T > &m1, const Matrix< nRows, nCols, T > &m2)
 Apply a binary function to each element of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map (T(*fct)(const T &, const T &), const Matrix< nRows, nCols, T > &m1, const Matrix< nRows, nCols, T > &m2)
 Apply a binary function to each element of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map (const T &(*fct)(const T &, const T &), const Matrix< nRows, nCols, T > &m1, const Matrix< nRows, nCols, T > &m2)
 Apply a binary function to each element of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T , typename T1 , typename T2 >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map (T(*fct)(T1, T2), const Matrix< nRows, nCols, T1 > &m1, const Matrix< nRows, nCols, T2 > &m2)
 Apply a binary function to each element of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T , typename T1 , typename T2 >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map (T(*fct)(const T1 &, const T2 &), const Matrix< nRows, nCols, T1 > &m1, const Matrix< nRows, nCols, T2 > &m2)
 Apply a binary function to each element of the matrix. More...
 
template<size_t nRows, size_t nCols, typename T , typename T1 , typename T2 >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map (const T &(*fct)(const T1 &, const T2 &), const Matrix< nRows, nCols, T1 > &m1, const Matrix< nRows, nCols, T2 > &m2)
 Apply a binary function to each element of the matrix. More...
 

Detailed Description

template<size_t nRows, size_t nCols, typename T = double>
class mgx::Matrix< nRows, nCols, T >

Class representing a fixed-size dense matrix.

Definition at line 39 of file Matrix.hpp.

Member Typedef Documentation

◆ iterator

template<size_t nRows, size_t nCols, typename T = double>
typedef T* mgx::Matrix< nRows, nCols, T >::iterator

Definition at line 49 of file Matrix.hpp.

◆ pointer_type

template<size_t nRows, size_t nCols, typename T = double>
typedef T* mgx::Matrix< nRows, nCols, T >::pointer_type

Definition at line 47 of file Matrix.hpp.

◆ reference_type

template<size_t nRows, size_t nCols, typename T = double>
typedef T& mgx::Matrix< nRows, nCols, T >::reference_type

Definition at line 45 of file Matrix.hpp.

◆ value_type

template<size_t nRows, size_t nCols, typename T = double>
typedef T mgx::Matrix< nRows, nCols, T >::value_type

Definition at line 44 of file Matrix.hpp.

Constructor & Destructor Documentation

◆ Matrix() [1/7]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE mgx::Matrix< nRows, nCols, T >::Matrix ( void  )
inline

Create a matrix filled with 0s.

Definition at line 59 of file Matrix.hpp.

◆ Matrix() [2/7]

template<size_t nRows, size_t nCols, typename T = double>
template<typename T1 >
CU_HOST_DEVICE mgx::Matrix< nRows, nCols, T >::Matrix ( const Matrix< nRows, nCols, T1 > &  mat)
inline

Copy a matrix.

Can be used to cast a matrix onto another type.

Definition at line 71 of file Matrix.hpp.

◆ Matrix() [3/7]

template<size_t nRows, size_t nCols, typename T = double>
template<typename T1 >
CU_HOST_DEVICE mgx::Matrix< nRows, nCols, T >::Matrix ( const Vector< nCols, T1 > *  vecs)
inline

Fill the matrix with the array of vectors.

Parameters
vecsArray of nRows vectors.

Definition at line 83 of file Matrix.hpp.

◆ Matrix() [4/7]

template<size_t nRows, size_t nCols, typename T = double>
template<typename T1 >
CU_HOST_DEVICE mgx::Matrix< nRows, nCols, T >::Matrix ( const Vector< nCols, T1 > &  r0,
const Vector< nCols, T1 > &  r1,
const Vector< nCols, T1 > &  r2 
)
inline

Initialize a 3 row matrix.

Definition at line 93 of file Matrix.hpp.

◆ Matrix() [5/7]

template<size_t nRows, size_t nCols, typename T = double>
template<typename T1 >
CU_HOST_DEVICE mgx::Matrix< nRows, nCols, T >::Matrix ( const T1 *  values)
inline

Fill in the matrix with the values.

Parameters
valuesnRows*nCols array. If c_style is true, values is rows first (i.e. the first values correspond to the first row). Otherwise, values are columns first.
c_styleDetermine the ordering of values.

Definition at line 111 of file Matrix.hpp.

◆ Matrix() [6/7]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE mgx::Matrix< nRows, nCols, T >::Matrix ( const T *  values)
inline

Fill in the matrix with the values.

Parameters
valuesnRows*nCols array. If c_style is true, values is rows first (i.e. the first values correspond to the first row). Otherwise, values are columns first.
c_styleDetermine the ordering of values.

Definition at line 127 of file Matrix.hpp.

◆ Matrix() [7/7]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE mgx::Matrix< nRows, nCols, T >::Matrix ( const T &  value)
inline

Create a diagonal matrix.

Parameters
valueValue placed on the diagonal.

Definition at line 139 of file Matrix.hpp.

Member Function Documentation

◆ c_data()

template<size_t nRows, size_t nCols, typename T = double>
const CU_HOST_DEVICE T* mgx::Matrix< nRows, nCols, T >::c_data ( ) const
inline

Returns a constant raw pointer on the data.

The data are organised on by rows. (i.e. in the opposite order as OpenGL)

Definition at line 178 of file Matrix.hpp.

◆ data()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE T* mgx::Matrix< nRows, nCols, T >::data ( )
inline

Returns a raw pointer on the data.

The data are organised on by rows. (i.e. in the opposite order as OpenGL)

Definition at line 188 of file Matrix.hpp.

◆ diag()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Vector<nRows, T> mgx::Matrix< nRows, nCols, T >::diag ( ) const
inline

Return the diagonal vector, if the matrix is square.

Definition at line 560 of file Matrix.hpp.

◆ fillArray()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE void mgx::Matrix< nRows, nCols, T >::fillArray ( T *  array)
inline

Definition at line 551 of file Matrix.hpp.

◆ identity()

template<size_t nRows, size_t nCols, typename T = double>
static CU_HOST_DEVICE Matrix mgx::Matrix< nRows, nCols, T >::identity ( )
inlinestatic

Returns an identity matrix.

Definition at line 444 of file Matrix.hpp.

◆ nbColumns()

template<size_t nRows, size_t nCols, typename T = double>
static CU_HOST_DEVICE size_t mgx::Matrix< nRows, nCols, T >::nbColumns ( )
inlinestatic

Returns the number of columns of the matrix.

Definition at line 168 of file Matrix.hpp.

◆ nbRows()

template<size_t nRows, size_t nCols, typename T = double>
static CU_HOST_DEVICE size_t mgx::Matrix< nRows, nCols, T >::nbRows ( )
inlinestatic

Returns the number of rows of the matrix.

Definition at line 160 of file Matrix.hpp.

◆ operator!=()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE bool mgx::Matrix< nRows, nCols, T >::operator!= ( const Matrix< nRows, nCols, T > &  mat) const
inline

Element-wise inequality.

Definition at line 343 of file Matrix.hpp.

◆ operator()() [1/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE T& mgx::Matrix< nRows, nCols, T >::operator() ( size_t  i,
size_t  j 
)
inline

Return the value at row i, column j.

Definition at line 428 of file Matrix.hpp.

◆ operator()() [2/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE T mgx::Matrix< nRows, nCols, T >::operator() ( size_t  i,
size_t  j 
) const
inline

Return the value at row i, column j.

Definition at line 436 of file Matrix.hpp.

◆ operator*() [1/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix mgx::Matrix< nRows, nCols, T >::operator* ( const T &  scalar) const
inline

Matrix-scalar multiplication.

Definition at line 238 of file Matrix.hpp.

◆ operator*() [2/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Vector<nRows, T> mgx::Matrix< nRows, nCols, T >::operator* ( const Vector< nCols, T > &  vec) const
inline

Matrix*Column Vector.

Definition at line 280 of file Matrix.hpp.

◆ operator*=() [1/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix& mgx::Matrix< nRows, nCols, T >::operator*= ( const Matrix< nRows, nCols, T > &  mat)
inline

Definition at line 322 of file Matrix.hpp.

◆ operator*=() [2/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix& mgx::Matrix< nRows, nCols, T >::operator*= ( const T &  scalar)
inline

Definition at line 312 of file Matrix.hpp.

◆ operator+()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix mgx::Matrix< nRows, nCols, T >::operator+ ( const Matrix< nRows, nCols, T > &  mat) const
inline

Matrix addition.

Matrix subtraction

Definition at line 210 of file Matrix.hpp.

◆ operator+=()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix& mgx::Matrix< nRows, nCols, T >::operator+= ( const Matrix< nRows, nCols, T > &  mat)
inline

Definition at line 302 of file Matrix.hpp.

◆ operator-() [1/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix mgx::Matrix< nRows, nCols, T >::operator- ( const Matrix< nRows, nCols, T > &  mat) const
inline

Definition at line 224 of file Matrix.hpp.

◆ operator-() [2/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix mgx::Matrix< nRows, nCols, T >::operator- ( void  ) const
inline

Matrix subtraction.

Definition at line 196 of file Matrix.hpp.

◆ operator-=()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix& mgx::Matrix< nRows, nCols, T >::operator-= ( const Matrix< nRows, nCols, T > &  mat)
inline

Definition at line 307 of file Matrix.hpp.

◆ operator/()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix mgx::Matrix< nRows, nCols, T >::operator/ ( const T &  scalar) const
inline

Matrix-scalar division.

Definition at line 252 of file Matrix.hpp.

◆ operator/=()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix& mgx::Matrix< nRows, nCols, T >::operator/= ( const T &  scalar)
inline

Definition at line 317 of file Matrix.hpp.

◆ operator<()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE bool mgx::Matrix< nRows, nCols, T >::operator< ( const Matrix< nRows, nCols, T > &  other) const
inline

Comparison operator.

Compare the axis in row order.

Definition at line 353 of file Matrix.hpp.

◆ operator=() [1/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix& mgx::Matrix< nRows, nCols, T >::operator= ( const Matrix< nRows, nCols, T > &  mat)
inline

Definition at line 293 of file Matrix.hpp.

◆ operator=() [2/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix& mgx::Matrix< nRows, nCols, T >::operator= ( const T &  value)
inline

Set the matrix to a diagonal matrix.

Parameters
valueValue to put on the diagonal

Definition at line 468 of file Matrix.hpp.

◆ operator==()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE bool mgx::Matrix< nRows, nCols, T >::operator== ( const Matrix< nRows, nCols, T > &  mat) const
inline

Element-wise equality.

Definition at line 330 of file Matrix.hpp.

◆ operator[]() [1/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Vector<nCols, T>& mgx::Matrix< nRows, nCols, T >::operator[] ( size_t  idx)
inline

Returns the nth row.

Parameters
idxIndex of the returned row

Definition at line 410 of file Matrix.hpp.

◆ operator[]() [2/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Vector<nCols, T> mgx::Matrix< nRows, nCols, T >::operator[] ( size_t  idx) const
inline

Returns the nth row.

Parameters
idxIndex of the returned row

Definition at line 420 of file Matrix.hpp.

◆ operator~()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix<nCols, nRows, T> mgx::Matrix< nRows, nCols, T >::operator~ ( )
inline

Transpose the matrix.

Definition at line 485 of file Matrix.hpp.

◆ rotation() [1/2]

template<size_t nRows, size_t nCols, typename T = double>
static CU_HOST_DEVICE Matrix<3, 3, T> mgx::Matrix< nRows, nCols, T >::rotation ( const Vector< 3, T > &  direction,
angle 
)
inlinestatic

Creates the 3x3 matrix corresponding to a rotation.

Parameters
directionAxes of the rotation
angleAngle of the rotation

Definition at line 501 of file Matrix.hpp.

◆ rotation() [2/2]

template<size_t nRows, size_t nCols, typename T = double>
static CU_HOST_DEVICE Matrix<4, 4, T> mgx::Matrix< nRows, nCols, T >::rotation ( const Vector< 4, T > &  direction,
angle 
)
inlinestatic

Creates the 4x4 matrix corresponding to a rotation.

Parameters
directionAxes of the rotation
angleAngle of the rotation

Definition at line 522 of file Matrix.hpp.

◆ size()

template<size_t nRows, size_t nCols, typename T = double>
static CU_HOST_DEVICE Vector<2, size_t> mgx::Matrix< nRows, nCols, T >::size ( )
inlinestatic

Returns the size of the matrix.

First element is number of rows, second is number of columns

Definition at line 152 of file Matrix.hpp.

◆ trace()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE T mgx::Matrix< nRows, nCols, T >::trace ( ) const
inline

Trace of the matrix.

Definition at line 541 of file Matrix.hpp.

◆ zero()

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE Matrix& mgx::Matrix< nRows, nCols, T >::zero ( void  )
inline

Set the matrix to all zero.

Definition at line 454 of file Matrix.hpp.

Friends And Related Function Documentation

◆ cofactor()

template<size_t nRows, typename T >
CU_HOST_DEVICE T cofactor ( const Matrix< nRows, nRows, T > &  mat,
size_t  i,
size_t  j 
)
related

Returns the cofactor of the matrix for position (i,j)

Definition at line 992 of file Matrix.hpp.

◆ det() [1/4]

template<typename T >
T CU_HOST_DEVICE det ( const Matrix< 1, 1, T > &  mat)
related

Determinant of the matrix.

Definition at line 946 of file Matrix.hpp.

◆ det() [2/4]

template<typename T >
T CU_HOST_DEVICE det ( const Matrix< 2, 2, T > &  mat)
related

Determinant of the matrix.

Definition at line 950 of file Matrix.hpp.

◆ det() [3/4]

template<typename T >
T CU_HOST_DEVICE det ( const Matrix< 3, 3, T > &  mat)
related

Determinant of the matrix.

Definition at line 955 of file Matrix.hpp.

◆ det() [4/4]

template<size_t nRows, typename T >
T CU_HOST_DEVICE det ( const Matrix< nRows, nRows, T > &  mat)
related

Determinant of the matrix.

Warning
the method used is $O(n^3)$ complexity !

Definition at line 961 of file Matrix.hpp.

◆ inverse() [1/5]

template<typename T >
CU_HOST_DEVICE Matrix< 1, 1, T > inverse ( const Matrix< 1, 1, T > &  mat)
related

Inverse the matrix.

Definition at line 1001 of file Matrix.hpp.

◆ inverse() [2/5]

template<typename T >
CU_HOST_DEVICE Matrix< 2, 2, T > inverse ( const Matrix< 2, 2, T > &  mat)
related

Inverse the matrix.

Definition at line 1008 of file Matrix.hpp.

◆ inverse() [3/5]

template<typename T >
CU_HOST_DEVICE Matrix< 3, 3, T > inverse ( const Matrix< 3, 3, T > &  mat)
related

Inverse the matrix.

Definition at line 1022 of file Matrix.hpp.

◆ inverse() [4/5]

template<typename T >
CU_HOST_DEVICE Matrix< 4, 4, T > inverse ( const Matrix< 4, 4, T > &  mat)
related

Inverse the matrix.

Definition at line 1041 of file Matrix.hpp.

◆ inverse() [5/5]

template<size_t nRows, typename T >
CU_HOST_DEVICE Matrix< nRows, nRows, T > inverse ( const Matrix< nRows, nRows, T > &  mat)
related

Inverse the matrix.

Warning
This algorithm is sub-optimal

Definition at line 1100 of file Matrix.hpp.

◆ map() [1/12]

template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map ( const T &(*)(const T &)  fct,
const Matrix< nRows, nCols, T > &  m 
)
related

Apply a unary function to each element of the matrix.

Definition at line 684 of file Matrix.hpp.

◆ map() [2/12]

template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map ( const T &(*)(const T &, const T &)  fct,
const Matrix< nRows, nCols, T > &  m1,
const Matrix< nRows, nCols, T > &  m2 
)
related

Apply a binary function to each element of the matrix.

Definition at line 840 of file Matrix.hpp.

◆ map() [3/12]

template<size_t nRows, size_t nCols, typename T , typename T1 >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map ( const T &(*)(const T1 &)  fct,
const Matrix< nRows, nCols, T1 > &  m 
)
related

Apply a unary function to each element of the matrix.

Definition at line 741 of file Matrix.hpp.

◆ map() [4/12]

template<size_t nRows, size_t nCols, typename T , typename T1 , typename T2 >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map ( const T &(*)(const T1 &, const T2 &)  fct,
const Matrix< nRows, nCols, T1 > &  m1,
const Matrix< nRows, nCols, T2 > &  m2 
)
related

Apply a binary function to each element of the matrix.

Definition at line 903 of file Matrix.hpp.

◆ map() [5/12]

template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map ( T(*)(const T &)  fct,
const Matrix< nRows, nCols, T > &  m 
)
related

Apply a unary function to each element of the matrix.

Definition at line 722 of file Matrix.hpp.

◆ map() [6/12]

template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map ( T(*)(const T &, const T &)  fct,
const Matrix< nRows, nCols, T > &  m1,
const Matrix< nRows, nCols, T > &  m2 
)
related

Apply a binary function to each element of the matrix.

Definition at line 819 of file Matrix.hpp.

◆ map() [7/12]

template<size_t nRows, size_t nCols, typename T , typename T1 >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map ( T(*)(const T1 &)  fct,
const Matrix< nRows, nCols, T1 > &  m 
)
related

Apply a unary function to each element of the matrix.

Definition at line 779 of file Matrix.hpp.

◆ map() [8/12]

template<size_t nRows, size_t nCols, typename T , typename T1 , typename T2 >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map ( T(*)(const T1 &, const T2 &)  fct,
const Matrix< nRows, nCols, T1 > &  m1,
const Matrix< nRows, nCols, T2 > &  m2 
)
related

Apply a binary function to each element of the matrix.

Definition at line 882 of file Matrix.hpp.

◆ map() [9/12]

template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map ( T(*)(T)  fct,
const Matrix< nRows, nCols, T > &  m 
)
related

Apply a unary function to each element of the matrix.

Definition at line 703 of file Matrix.hpp.

◆ map() [10/12]

template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map ( T(*)(T, T)  fct,
const Matrix< nRows, nCols, T > &  m1,
const Matrix< nRows, nCols, T > &  m2 
)
related

Apply a binary function to each element of the matrix.

Definition at line 798 of file Matrix.hpp.

◆ map() [11/12]

template<size_t nRows, size_t nCols, typename T , typename T1 >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map ( T(*)(T1)  fct,
const Matrix< nRows, nCols, T1 > &  m 
)
related

Apply a unary function to each element of the matrix.

Definition at line 760 of file Matrix.hpp.

◆ map() [12/12]

template<size_t nRows, size_t nCols, typename T , typename T1 , typename T2 >
CU_HOST_DEVICE Matrix< nRows, nCols, T > map ( T(*)(T1, T2)  fct,
const Matrix< nRows, nCols, T1 > &  m1,
const Matrix< nRows, nCols, T2 > &  m2 
)
related

Apply a binary function to each element of the matrix.

Definition at line 861 of file Matrix.hpp.

◆ norm()

template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE T norm ( const Matrix< nRows, nCols, T > &  mat)
related

Return the norm of the matrix.

The norm is defined as the square-root of the sum of the square of the values.

Definition at line 1134 of file Matrix.hpp.

◆ normsq()

template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE T normsq ( const Matrix< nRows, nCols, T > &  mat)
related

Return the square norm of the matrix.

See also
norm(const Matrix&)

Definition at line 1123 of file Matrix.hpp.

◆ operator*() [1/3]

template<size_t nRows, size_t nSize, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nRows, nCols, T > operator* ( const Matrix< nRows, nSize, T > &  mat1,
const Matrix< nSize, nCols, T > &  mat2 
)
related

Matrix multiplication.

◆ operator* [2/3]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE friend Matrix operator* ( const T &  scalar,
const Matrix< nRows, nCols, T > &  mat 
)
friend

Matrix-scalar multiplication.

Definition at line 266 of file Matrix.hpp.

◆ operator*() [3/3]

template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Vector< nCols, T > operator* ( const Vector< nCols, T > &  vec,
const Matrix< nRows, nCols, T > &  mat 
)
related

Row-Vector - Matrix multipliation.

Definition at line 919 of file Matrix.hpp.

◆ operator<< [1/2]

template<size_t nRows, size_t nCols, typename T = double>
QTextStream& operator<< ( QTextStream &  out,
const Matrix< nRows, nCols, T > &  mat 
)
friend

Definition at line 365 of file Matrix.hpp.

◆ operator<< [2/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE friend std::ostream& operator<< ( std::ostream &  out,
const Matrix< nRows, nCols, T > &  mat 
)
friend

Definition at line 385 of file Matrix.hpp.

◆ operator>> [1/2]

template<size_t nRows, size_t nCols, typename T = double>
QTextStream& operator>> ( QTextStream &  in,
Matrix< nRows, nCols, T > &  mat 
)
friend

Definition at line 376 of file Matrix.hpp.

◆ operator>> [2/2]

template<size_t nRows, size_t nCols, typename T = double>
CU_HOST_DEVICE friend std::istream& operator>> ( std::istream &  in,
Matrix< nRows, nCols, T > &  mat 
)
friend

Definition at line 397 of file Matrix.hpp.

◆ transpose()

template<size_t nRows, size_t nCols, typename T >
CU_HOST_DEVICE Matrix< nCols, nRows, T > transpose ( const Matrix< nRows, nCols, T > &  mat)
related

Transpose a matrix.

Definition at line 1114 of file Matrix.hpp.

Member Data Documentation

◆ const_iterator

template<size_t nRows, size_t nCols, typename T = double>
const typedef T* mgx::Matrix< nRows, nCols, T >::const_iterator

Definition at line 50 of file Matrix.hpp.

◆ const_pointer_type

template<size_t nRows, size_t nCols, typename T = double>
const typedef T* mgx::Matrix< nRows, nCols, T >::const_pointer_type

Definition at line 48 of file Matrix.hpp.

◆ const_reference_type

template<size_t nRows, size_t nCols, typename T = double>
const typedef T& mgx::Matrix< nRows, nCols, T >::const_reference_type

Definition at line 46 of file Matrix.hpp.

◆ numcols

template<size_t nRows, size_t nCols, typename T = double>
const size_t mgx::Matrix< nRows, nCols, T >::numcols
static

Definition at line 52 of file Matrix.hpp.

◆ numrows

template<size_t nRows, size_t nCols, typename T = double>
const size_t mgx::Matrix< nRows, nCols, T >::numrows
static

Definition at line 53 of file Matrix.hpp.


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