pmp-library  1.0
Matrix< Scalar, M, N > Class Template Reference

Base class for MxN matrix. More...

#include <pmp/MatVec.h>

Public Types

typedef Scalar value_type
 the scalar type of the vector
 

Public Member Functions

 Matrix ()
 empty default constructor
 
 Matrix (Scalar s)
 construct with all entries being a given scalar (matrix and vector)
 
 Matrix (Scalar x, Scalar y)
 constructor for 2D vectors
 
 Matrix (Scalar x, Scalar y, Scalar z)
 constructor for 3D vectors
 
 Matrix (Scalar x, Scalar y, Scalar z, Scalar w)
 constructor for 4D vectors
 
 Matrix (Matrix< Scalar, 3, 1 > xyz, Scalar w)
 constructor for 4D vectors
 
 Matrix (Matrix< Scalar, 4, 1 > c0, Matrix< Scalar, 4, 1 > c1, Matrix< Scalar, 4, 1 > c2, Matrix< Scalar, 4, 1 > c3)
 construct 4x4 matrix from 4 column vectors
 
 Matrix (Scalar m00, Scalar m01, Scalar m02, Scalar m03, Scalar m10, Scalar m11, Scalar m12, Scalar m13, Scalar m20, Scalar m21, Scalar m22, Scalar m23, Scalar m30, Scalar m31, Scalar m32, Scalar m33)
 construct from 16 (row-wise) entries
 
template<typename OtherScalarType >
 Matrix (const Matrix< OtherScalarType, M, N > &m)
 copy constructor from other scalar type is also invoked for type-casting
 
Scalaroperator() (unsigned int i, unsigned int j)
 access entry at row i and column j
 
const Scalaroperator() (unsigned int i, unsigned int j) const
 const-access entry at row i and column j
 
Scalaroperator[] (unsigned int i)
 access i'th entry (use for vectors)
 
Scalar operator[] (unsigned int i) const
 const-access i'th entry (use for vectors)
 
const Scalardata () const
 const-access as scalar array
 
Scalardata ()
 access as scalar array
 
void normalize ()
 normalize matrix/vector by dividing through Frobenius/Euclidean norm
 
Matrix< Scalar, M, N > & operator/= (const Scalar s)
 divide matrix by scalar
 
Matrix< Scalar, M, N > & operator*= (const Scalar s)
 multply matrix by scalar
 
Matrix< Scalar, M, N > & operator-= (const Matrix< Scalar, M, N > &m)
 subtract other matrix from this matrix
 
bool operator== (const Matrix< Scalar, M, N > &other) const
 component-wise comparison
 
bool operator!= (const Matrix< Scalar, M, N > &other) const
 component-wise comparison
 

Static Public Member Functions

static constexpr int rows ()
 returns number of rows of the matrix
 
static constexpr int cols ()
 returns number of columns of the matrix
 
static constexpr int size ()
 returns the dimension of the vector (or size of the matrix, rows*cols)
 
static Matrix< Scalar, M, N > identity ()
 return identity matrix (only for square matrices, N==M) More...
 

Detailed Description

template<typename Scalar, int M, int N>
class pmp::Matrix< Scalar, M, N >

Base class for MxN matrix.