MAV'RIC
Public Member Functions | Friends
Mat< N, P, T > Class Template Reference

Templated matrix class. More...

#include <matrix.hpp>

List of all members.

Public Member Functions

 Mat (T value=0.0f, bool diag=false)
 Default constructor.
 Mat (const Mat< N, P > &mat)
 Copy constructor.
 Mat (const std::array< T, N *P > arr)
 Constructor from array.
 Mat (const std::initializer_list< T > list)
 Constructor from list.
uint32_t rows (void)
 Get number of rows.
uint32_t cols (void)
 Get number of columns.
uint32_t index (uint32_t i, uint32_t j)
 Return index in internal data array from row/column.
const T & operator() (const uint32_t &i, const uint32_t &j) const
 Safe access to matrix element.
T & operator() (const uint32_t &i, const uint32_t &j)
const T & operator[] (const uint32_t &index) const
 Direct access to matrix data.
T & operator[] (const uint32_t &index)
Mat add (const Mat &m) const
 Add to a matrix.
Mat add (const T value) const
 Add to a scalar.
Mat operator+ (const Mat &m) const
 Add to a matrix.
Mat operator+ (T value) const
 Add to a scalar.
void add_inplace (const Mat &m)
 Increment by a matrix (inplace operation)
void add_inplace (const T value)
 Increment by a scalar (inplace operation)
void operator+= (const Mat &m)
 Increment by a matrix (inplace operation)
void operator+= (const T value)
 Increment by a scalar (inplace operation)
Mat subtract (const Mat &m) const
 Subtract a matrix.
Mat subtract (const T value) const
 Subtract a scalar.
Mat operator- (const Mat &m) const
 Subtract a matrix.
Mat operator- (const T value) const
 Subtract a scalar.
void subtract_inplace (const Mat &m)
 Decrement by a matrix (inplace operation)
void subtract_inplace (const T value)
 Decrement by a scalar (inplace operation)
void operator-= (const Mat &m)
 Decrement by a matrix (inplace operation)
void operator-= (const T value)
 Decrement by a scalar (inplace operation)
Mat multiply (const Mat &m) const
 Multiply by a matrix.
Mat multiply (const T value) const
 Multiply by a scalar.
Mat operator* (const Mat &m) const
 Multiply by a matrix.
Mat operator* (const T value) const
 Multiply by a scalar.
void multiply_inplace (const Mat &m)
 Multiply by a matrix (inplace operation)
void multiply_inplace (const T value)
 Multiply by a scalar (inplace operation)
void operator*= (const Mat &m)
 Multiply by a matrix (inplace operation)
void operator*= (const T value)
 Multiply by a scalar (inplace operation)
template<uint32_t Q>
Mat< N, Q, T > dot (const Mat< P, Q, T > &m) const
 Dot product.
template<uint32_t Q>
Mat< N, Q, T > operator% (const Mat< P, Q, T > &m) const
 Dot product.
Mat< P, N, T > transpose (void) const
 Get transposed matrix.
Mat< P, N, T > operator~ (void) const
 Get transposed matrix.
Mat inverse (bool &success) const
 Get inversed matrix.
Mat inv (bool &success) const
 Get inversed matrix.
template<uint32_t I, uint32_t J, uint32_t Q, uint32_t R>
Mat insert (const Mat< Q, R, T > &m) const
 Insert a matrix into this one.
template<uint32_t I, uint32_t J, uint32_t Q, uint32_t R>
bool insert_inplace (const Mat< Q, R, T > &m)
 Insert a matrix into this one.
void clip (const Mat &min, const Mat &max)
 Clips matrix values between that of two matrices (element-wise)
void clip (float min, float max)
 Clips matrix values.

Friends

class mat::op
template<typename TT >
Mat operator+ (const T value, const Mat &m)
 Add a scalar to the matrix (ex: value + m)
template<typename TT >
Mat operator- (const T value, const Mat &m)
 Subtract a matrix to a scalar (ex: value - m)
template<typename TT >
Mat operator* (const T value, const Mat &m)
 Multiply a scalar to a matrix (ex: value * m)

Detailed Description

template<uint32_t N, uint32_t P, typename T = float>
class Mat< N, P, T >

Templated matrix class.

Template Parameters:
NNumber of rows
PNumber of columns
TType of data (default: float)

Constructor & Destructor Documentation

template<uint32_t N, uint32_t P, typename T>
Mat< N, P, T >::Mat ( value = 0.0f,
bool  diag = false 
)

Default constructor.

Parameters:
valueValue used to fill the matrix
diagFlag indicating if the matrix is diagonal
template<uint32_t N, uint32_t P, typename T>
Mat< N, P, T >::Mat ( const Mat< N, P > &  mat)

Copy constructor.

Parameters:
matMatrix to copy
template<uint32_t N, uint32_t P, typename T>
Mat< N, P, T >::Mat ( const std::array< T, N *P >  arr)

Constructor from array.

Compile-time size check, does not work on avr32

Parameters:
arrayArray of values
template<uint32_t N, uint32_t P, typename T>
Mat< N, P, T >::Mat ( const std::initializer_list< T >  list)

Constructor from list.

Runtime size check, works on avr32

Parameters:
arrayArray of values

Member Function Documentation

template<uint32_t N, uint32_t P, typename T >
Mat< N, P, T > Mat< N, P, T >::add ( const Mat< N, P, T > &  m) const

Add to a matrix.

Parameters:
mMatrix to add
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T>
Mat< N, P, T > Mat< N, P, T >::add ( const T  value) const

Add to a scalar.

Parameters:
valueScalar to add
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T >
void Mat< N, P, T >::add_inplace ( const Mat< N, P, T > &  m)

Increment by a matrix (inplace operation)

Parameters:
mMatrix to add
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T>
void Mat< N, P, T >::add_inplace ( const T  value)

Increment by a scalar (inplace operation)

Parameters:
valueScalar to add
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T >
void Mat< N, P, T >::clip ( const Mat< N, P, T > &  min,
const Mat< N, P, T > &  max 
)

Clips matrix values between that of two matrices (element-wise)

Parameters:
minMatrix with minimum values
maxMatrix with maximum values

Here is the caller graph for this function:

template<uint32_t N, uint32_t P, typename T >
void Mat< N, P, T >::clip ( float  min,
float  max 
)

Clips matrix values.

Parameters:
minMinimum value
maxMaximum value
template<uint32_t N, uint32_t P, typename T >
uint32_t Mat< N, P, T >::cols ( void  )

Get number of columns.

Returns:
P
template<uint32_t N, uint32_t P, typename T = float>
template<uint32_t Q>
Mat<N,Q,T> Mat< N, P, T >::dot ( const Mat< P, Q, T > &  m) const [inline]

Dot product.

For some reason, there is a compilation error if this method is defined in matrix.hxx

Parameters:
mMatrix to dot-multiply
Template Parameters:
QNumber of columns of 2nd matrix, also number of columns of result
Returns:
result

Here is the caller graph for this function:

template<uint32_t N, uint32_t P, typename T >
uint32_t Mat< N, P, T >::index ( uint32_t  i,
uint32_t  j 
)

Return index in internal data array from row/column.

Returns:
index
template<uint32_t N, uint32_t P, typename T>
template<uint32_t I, uint32_t J, uint32_t Q, uint32_t R>
Mat< N, P, T > Mat< N, P, T >::insert ( const Mat< Q, R, T > &  m) const

Insert a matrix into this one.

Parameters:
mMatrix to be inserted
iRow index of the first element where the matrix should be inserted
jColumn index of the first element where the matrix should be inserted
successFalse if the inserted matrix was to big to fit (in this case, the elements that fits are still inserted)
Returns:
New matrix
template<uint32_t N, uint32_t P, typename T>
template<uint32_t I, uint32_t J, uint32_t Q, uint32_t R>
bool Mat< N, P, T >::insert_inplace ( const Mat< Q, R, T > &  m)

Insert a matrix into this one.

Parameters:
mMatrix to be inserted
Template Parameters:
IRow index of the first top left element to be inserted (index in m1)
JColumn index of the first top left element to be inserted (index in m1)
QNumber of rows of 2nd matrix
RNumber of columns of 2nd matrix
Returns:
result
template<uint32_t N, uint32_t P, typename T >
Mat< N, P, T > Mat< N, P, T >::inv ( bool &  success) const

Get inversed matrix.

Parameters:
successIndicates if the matrix could be inverted
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T >
Mat< N, P, T > Mat< N, P, T >::inverse ( bool &  success) const

Get inversed matrix.

Parameters:
successIndicates if the matrix could be inverted
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T >
Mat< N, P, T > Mat< N, P, T >::multiply ( const Mat< N, P, T > &  m) const

Multiply by a matrix.

Parameters:
mMatrix to multiply
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T>
Mat< N, P, T > Mat< N, P, T >::multiply ( const T  value) const

Multiply by a scalar.

Parameters:
valueScalar to multiply
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T >
void Mat< N, P, T >::multiply_inplace ( const Mat< N, P, T > &  m)

Multiply by a matrix (inplace operation)

Parameters:
mMatrix to multiply
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T>
void Mat< N, P, T >::multiply_inplace ( const T  value)

Multiply by a scalar (inplace operation)

Parameters:
valueScalar to multiply
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T = float>
template<uint32_t Q>
Mat<N,Q,T> Mat< N, P, T >::operator% ( const Mat< P, Q, T > &  m) const [inline]

Dot product.

For some reason, there is a compilation error if this method is defined in matrix.hxx

Parameters:
mMatrix to dot-multiply
Template Parameters:
QNumber of columns of 2nd matrix, also number of columns of result
Returns:
result
template<uint32_t N, uint32_t P, typename T >
const T & Mat< N, P, T >::operator() ( const uint32_t &  i,
const uint32_t &  j 
) const

Safe access to matrix element.

Parameters:
iRow
jColumn
Returns:
M(i,j) when indices are correct, M(0,0) when indices overflow
template<uint32_t N, uint32_t P, typename T >
Mat< N, P, T > Mat< N, P, T >::operator* ( const Mat< N, P, T > &  m) const

Multiply by a matrix.

Parameters:
mMatrix to multiply
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T>
Mat< N, P, T > Mat< N, P, T >::operator* ( const T  value) const

Multiply by a scalar.

Parameters:
valueScalar to multiply
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T >
void Mat< N, P, T >::operator*= ( const Mat< N, P, T > &  m)

Multiply by a matrix (inplace operation)

Parameters:
mMatrix to multiply
Returns:
result
template<uint32_t N, uint32_t P, typename T>
void Mat< N, P, T >::operator*= ( const T  value)

Multiply by a scalar (inplace operation)

Parameters:
valueScalar to multiply
Returns:
result
template<uint32_t N, uint32_t P, typename T >
Mat< N, P, T > Mat< N, P, T >::operator+ ( const Mat< N, P, T > &  m) const

Add to a matrix.

Parameters:
mMatrix to add
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T>
Mat< N, P, T > Mat< N, P, T >::operator+ ( value) const

Add to a scalar.

Parameters:
valueScalar to add
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T >
void Mat< N, P, T >::operator+= ( const Mat< N, P, T > &  m)

Increment by a matrix (inplace operation)

Parameters:
mMatrix to add
Returns:
result
template<uint32_t N, uint32_t P, typename T>
void Mat< N, P, T >::operator+= ( const T  value)

Increment by a scalar (inplace operation)

Parameters:
valueScalar to add
Returns:
result
template<uint32_t N, uint32_t P, typename T >
Mat< N, P, T > Mat< N, P, T >::operator- ( const Mat< N, P, T > &  m) const

Subtract a matrix.

Parameters:
mMatrix to subtract
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T>
Mat< N, P, T > Mat< N, P, T >::operator- ( const T  value) const

Subtract a scalar.

Parameters:
valueScalar to subtract
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T >
void Mat< N, P, T >::operator-= ( const Mat< N, P, T > &  m)

Decrement by a matrix (inplace operation)

Parameters:
mMatrix to subtract
Returns:
result
template<uint32_t N, uint32_t P, typename T>
void Mat< N, P, T >::operator-= ( const T  value)

Decrement by a scalar (inplace operation)

Parameters:
valueScalar to subtract
Returns:
result
template<uint32_t N, uint32_t P, typename T >
const T & Mat< N, P, T >::operator[] ( const uint32_t &  index) const

Direct access to matrix data.

Parameters:
indexIndex in array (index=i*P+j for i-th row and j-th column)
Returns:
M[index] when index is correct, M(0,0) when index overflows
template<uint32_t N, uint32_t P, typename T >
Mat< P, N, T > Mat< N, P, T >::operator~ ( void  ) const

Get transposed matrix.

Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T >
uint32_t Mat< N, P, T >::rows ( void  )

Get number of rows.

Returns:
N
template<uint32_t N, uint32_t P, typename T >
Mat< N, P, T > Mat< N, P, T >::subtract ( const Mat< N, P, T > &  m) const

Subtract a matrix.

Parameters:
mMatrix to subtract
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T>
Mat< N, P, T > Mat< N, P, T >::subtract ( const T  value) const

Subtract a scalar.

Parameters:
valueScalar to subtract
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T >
void Mat< N, P, T >::subtract_inplace ( const Mat< N, P, T > &  m)

Decrement by a matrix (inplace operation)

Parameters:
mMatrix to subtract
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T>
void Mat< N, P, T >::subtract_inplace ( const T  value)

Decrement by a scalar (inplace operation)

Parameters:
valueScalar to subtract
Returns:
result

Here is the call graph for this function:

template<uint32_t N, uint32_t P, typename T >
Mat< P, N, T > Mat< N, P, T >::transpose ( void  ) const

Get transposed matrix.

Returns:
result

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

template<uint32_t N, uint32_t P, typename T = float>
friend class mat::op [friend]

Friend with op class, so that methods of op can access private members of Mat<N,P,T>

template<uint32_t N, uint32_t P, typename T = float>
template<typename TT >
Mat operator* ( const T  value,
const Mat< N, P, T > &  m 
) [friend]

Multiply a scalar to a matrix (ex: value * m)

Parameters:
valueScalar to multiply
mMatrix to multiply
Returns:
result
template<uint32_t N, uint32_t P, typename T = float>
template<typename TT >
Mat operator+ ( const T  value,
const Mat< N, P, T > &  m 
) [friend]

Add a scalar to the matrix (ex: value + m)

Parameters:
valueScalar to add
mScalar to add
Returns:
result
template<uint32_t N, uint32_t P, typename T = float>
template<typename TT >
Mat operator- ( const T  value,
const Mat< N, P, T > &  m 
) [friend]

Subtract a matrix to a scalar (ex: value - m)

Parameters:
valueScalar to subtract
Returns:
result

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines