cgv
cgv::math::fmat< T, N, M > Class Template Reference

matrix of fixed size dimensions More...

#include <fmat.h>

Inheritance diagram for cgv::math::fmat< T, N, M >:
cgv::math::fvec< T, N *M >

Public Types

typedef fvec< T, N *M > base_type
 base type is a vector with sufficent number of elements
 
typedef fmat< T, N, M > this_type
 base type is a vector with sufficent number of elements
 

Public Member Functions

 fmat ()
 standard constructor
 
 fmat (const T &c)
 construct a matrix with all elements set to c
 
 fmat (cgv::type::uint32_type n, cgv::type::uint32_type m, const T *a, bool column_major=true)
 creates a matrix from an array a of given dimensions - by default in column major format
 
template<typename S >
 fmat (cgv::type::uint32_type n, cgv::type::uint32_type m, const S *a, bool column_major=true)
 creates a matrix from an array a of given dimensions but different type - by default in column major format
 
template<typename S >
 fmat (const fmat< S, N, M > &m)
 copy constructor for matrix with different element type
 
template<typename T1 , typename T2 >
 fmat (const fvec< T1, N > &v, const fvec< T2, M > &w)
 construct from outer product of vector v and w
 
template<typename S >
fmat< T, N, M > & operator= (const fmat< S, N, M > &m)
 assignment of a matrix with a different element type
 
this_typeoperator= (const T &s)
 assignment of a scalar s to each element of the matrix
 
bool is_square () const
 returns true if matrix is a square matrix
 
T & operator() (unsigned i, unsigned j)
 access to the element in the ith row in column j
 
const T & operator() (unsigned i, unsigned j) const
 const access to the element in the ith row on column j
 
this_type operator* (const T &s) const
 scalar multiplication

 
fmat< T, N, M > & operator/= (const T &s)
 in place division by a scalar
 
const fmat< T, N, M > operator/ (const T &s) const
 division by a scalar
 
fmat< T, N, M > & operator+= (const T &s)
 in place addition by a scalar
 
const fmat< T, N, M > operator+ (const T &s)
 componentwise addition of a scalar
 
fmat< T, N, M > & operator-= (const T &s)
 in place substraction of a scalar
 
const fmat< T, N, M > operator- (const T &s)
 componentwise subtraction of a scalar
 
const fmat< T, N, M > operator- () const
 negation operator
 
template<typename S >
fmat< T, N, M > & operator+= (const fmat< S, N, M > &m)
 in place addition of matrix
 
template<typename S >
fmat< T, N, M > & operator-= (const fmat< S, N, M > &m)
 in place subtraction of matrix
 
template<typename S >
const fmat< T, N, M > operator+ (const fmat< S, N, M > m2) const
 matrix addition
 
template<typename S >
const fmat< T, N, M > operator- (const fmat< S, N, M > m2) const
 matrix subtraction
 
template<typename S >
const fmat< T, N, M > operator*= (const fmat< S, N, N > &m2)
 in place matrix multiplication with a ncols x ncols matrix m2
 
template<typename S , cgv::type::uint32_type L>
const fmat< T, N, L > operator* (const fmat< S, M, L > &m2) const
 multiplication with a ncols x M matrix m2
 
template<typename S >
const fvec< T, N > operator* (const fvec< S, M > &v) const
 matrix vector multiplication
 
const fvec< T, M > row (unsigned i) const
 extract a row from the matrix as a vector, this is done by a type cast
 
void set_row (unsigned i, const fvec< T, M > &v)
 set row i of the matrix to vector v
 
const fvec< T, N > & col (unsigned j) const
 extract a column of the matrix as a vector
 
void set_col (unsigned j, const fvec< T, N > &v)
 set column j of the matrix to vector v
 
trace () const
 returns the trace
 
void transpose ()
 transpose matrix
 
frobenius_norm () const
 returns the frobenius norm of matrix m
 
void identity ()
 set identity matrix
 
const_reverse_iterator rend () const
 reverse iterator pointing to the end of reverse iteration
 
void set (const T &x, const T &y)
 set the first two components
 
void set (const T &x, const T &y, const T &z)
 set the first three components
 
void set (const T &x, const T &y, const T &z, const T &w)
 set the first four components
 
void fill (const T &a)
 fill elements of vector with scalar v
 
void zeros ()
 fill the vector with zeros
 
void ones ()
 fill the vector with ones
 
fvec< T, N+1 > lift () const
 convert to homogeneous version by adding a 1
 
vec< T > to_vec () const
 conversion to vector type
 
T & x ()
 first element
 
const T & x () const
 first element of const vector
 
T & y ()
 second element
 
const T & y () const
 second element of const vector
 
T & z ()
 third element
 
const T & z () const
 third element of const vector
 
T & w ()
 fourth element
 
const T & w () const
 fourth element of const vector
 
T & operator() (const int i)
 access i'th element
 
const T & operator() (const int i) const
 access i'th element of const vector
 
 operator T* ()
 cast into array. This allows calls like glVertex<N><T>v(p) instead of glVertex<N><T,N>(p.x(),p.y(),....)
 
 operator const T * () const
 cast into const array
 
fvec< T, N > & operator+= (const fvec< S, N > &_v)
 in place vector addition
 
fvec< T, N > & operator-= (const fvec< S, N > &_v)
 in place vector subtraction
 
fvec< T, N > & operator*= (const fvec< S, N > &_v)
 in place componentwise vector multiplication
 
fvec< T, N > & operator/= (const fvec< S, N > &_v)
 in place componentwise vector division
 
fvec< T, N > operator+ (const fvec< S, N > &v) const
 vector addition
 
fvec< T, N > operator+ (const T &s) const
 componentwise addition of scalar
 
fvec< T, N > operator- (const T &s) const
 componentwise subtraction of scalar
 
fvec< T, N > operator- (const fvec< S, N > &v) const
 vector subtraction
 
fvec< T, N > operator* (const fvec< S, N > &v) const
 componentwise vector multiplication
 
fvec< T, N > operator/ (const fvec< S, N > &v) const
 componentwise vector division
 
bool operator== (const fvec< S, N > &v) const
 test for equality
 
bool operator!= (const fvec< S, N > &v) const
 test for inequality
 
length () const
 length of the vector L2-Norm
 
void abs ()
 componentwise absolute values
 
void ceil ()
 ceil componentwise
 
void floor ()
 floor componentwise
 
void round ()
 round componentwise
 
sqr_length () const
 square length of vector
 
double normalize ()
 normalize the vector using the L2-Norm and return the length
 

Static Public Member Functions

static unsigned nrows ()
 number of rows
 
static unsigned ncols ()
 number of columns
 
static fvec< T, N > from_vec (const vec< T > &)
 conversion from vector
 
static cgv::type::uint32_type size ()
 return number of elements
 

Detailed Description

template<typename T, cgv::type::uint32_type N, cgv::type::uint32_type M>
class cgv::math::fmat< T, N, M >

matrix of fixed size dimensions

Template arguments are

  • T ... coordinate type
  • N ... number of rows
  • M ... number of columns Matrix elements can be accessed with the (i,j)-operator with 0-based indices. For example A(i,j) accesses the matrix element in the (i+1)th row and the (j+1)th column.

The matrix inherits the functionality of a N*M dimensional vector and is stored in column major format. This means that A(i,j)=A(j*M+i).


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