MAV'RIC
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions
mat::op Class Reference

Perform operations on matrices. More...

#include <matrix.hpp>

List of all members.

Public Member Functions

template<>
bool inverse (const Mat< 1, 1, float > &m, Mat< 1, 1, float > &res)
template<>
bool inverse (const Mat< 2, 2, float > &m, Mat< 2, 2, float > &res)
template<>
bool inverse (const Mat< 3, 3, float > &m, Mat< 3, 3, float > &res)
template<>
bool inverse (const Mat< 4, 4, float > &m, Mat< 4, 4, float > &res)

Static Public Member Functions

template<uint32_t N, uint32_t P, typename T >
static void add (const Mat< N, P, T > &m1, const Mat< N, P, T > &m2, Mat< N, P, T > &res)
 Add two matrices.
template<uint32_t N, uint32_t P, typename T >
static void add (const Mat< N, P, T > &m1, const T value, Mat< N, P, T > &res)
 Add a scalar to a matrix.
template<uint32_t N, uint32_t P, typename T >
static void subtract (const Mat< N, P, T > &m1, const Mat< N, P, T > &m2, Mat< N, P, T > &res)
 Subtract two matrices.
template<uint32_t N, uint32_t P, typename T >
static void subtract (const Mat< N, P, T > &m1, const T value, Mat< N, P, T > &res)
 Subtract a scalar to a matrix.
template<uint32_t N, uint32_t P, typename T >
static void multiply (const Mat< N, P, T > &m1, const Mat< N, P, T > &m2, Mat< N, P, T > &res)
 Multiply two matrices element per element.
template<uint32_t N, uint32_t P, typename T >
static void multiply (const Mat< N, P, T > &m1, const T value, Mat< N, P, T > &res)
 Multiply a scalar to a matrix.
template<uint32_t N, uint32_t P, typename T >
static void transpose (const Mat< N, P, T > &m, Mat< P, N, T > &res)
 Transpose a matrix.
template<uint32_t N, uint32_t P, uint32_t Q, typename T >
static void dot (const Mat< N, P, T > &m1, const Mat< P, Q, T > &m2, Mat< N, Q, T > &res)
 Matrix dot product.
template<uint32_t N, typename T >
static bool inverse (const Mat< N, N, T > &m, Mat< N, N, T > &res)
 Matrix dot product.
template<uint32_t N, uint32_t P, uint32_t I, uint32_t J, uint32_t Q, uint32_t R, typename T >
static bool insert (const Mat< N, P, T > &m1, const Mat< Q, R, T > &m2, Mat< N, P, T > &res)
 Insert a sub matrix into another matrix.
template<uint32_t N, uint32_t P, uint32_t I, uint32_t J, uint32_t Q, uint32_t R, typename T >
static bool insert_inplace (Mat< N, P, T > &m1, const Mat< Q, R, T > &m2)
 Insert a sub matrix into another matrix.
template<uint32_t N, uint32_t P, typename T >
static void clip (Mat< N, P, T > &m, const Mat< N, P, T > &min, const Mat< N, P, T > &max)
 Clips matrix values between that of two matrices (element-wise)
template<uint32_t N, uint32_t P, typename T >
static void clip (Mat< N, P, T > &m, float min, float max)
 Clips matrix values.

Detailed Description

Perform operations on matrices.

All methods are static (can be used as a namespace) This class is friend with Mat, so its methods can access private members of all specializations of Mat.


Member Function Documentation

template<uint32_t N, uint32_t P, typename T >
void mat::op::add ( const Mat< N, P, T > &  m1,
const Mat< N, P, T > &  m2,
Mat< N, P, T > &  res 
) [static]

Add two matrices.

Performs res = m1 + m2

Can be used for in place operations (ie. m1 or m2 can be references to the same matrix as res)

Parameters:
m1First matrix to add
m2Second matrix to add
resResult
Template Parameters:
NNumber of rows
PNumber of columns
TType of data

Here is the caller graph for this function:

template<uint32_t N, uint32_t P, typename T >
void mat::op::add ( const Mat< N, P, T > &  m1,
const T  value,
Mat< N, P, T > &  res 
) [static]

Add a scalar to a matrix.

Performs res = m1 + value

Can be used for in place operations (ie. m1 can be a reference to the same matrix as res)

Parameters:
m1First matrix to add
valueValue to add
resResult
Template Parameters:
NNumber of rows
PNumber of columns
TType of data
template<uint32_t N, uint32_t P, typename T >
void mat::op::clip ( Mat< N, P, T > &  m,
const Mat< N, P, T > &  min,
const Mat< N, P, T > &  max 
) [static]

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

Parameters:
mMatrix to clip
minMatrix with minimum values
maxMatrix with maximum values
template<uint32_t N, uint32_t P, typename T >
void mat::op::clip ( Mat< N, P, T > &  m,
float  min,
float  max 
) [static]

Clips matrix values.

Parameters:
mMatrix to clip
minMinimum value
maxMaximum value
template<uint32_t N, uint32_t P, uint32_t Q, typename T >
void mat::op::dot ( const Mat< N, P, T > &  m1,
const Mat< P, Q, T > &  m2,
Mat< N, Q, T > &  res 
) [static]

Matrix dot product.

Performs res = m1 . m2

Warning! Can NOT be used for in place operations

Parameters:
m1First matrix to multiply
m2Second matrix to multiply
resResult
Template Parameters:
NNumber of rows of 1st matrix , also number of rows of output matrix
PNumber of columns of 1st matrix , also number of rows of 2nd matrix
QNumber of columns of 2nd matrix , also number of columns of output matrix
TType of data
template<uint32_t N, uint32_t P, uint32_t I, uint32_t J, uint32_t Q, uint32_t R, typename T >
bool mat::op::insert ( const Mat< N, P, T > &  m1,
const Mat< Q, R, T > &  m2,
Mat< N, P, T > &  res 
) [static]

Insert a sub matrix into another matrix.

Insert matrix m2 into m1, at starting index (I, J) example: ```cpp // Create matrices Mat<10,11> m;

// Will copy content of m2 into m starting at 5th row and 6th column Mat<2,3> m2; Mat<10, 11> res2 = m.insert<5,6>(m2)

// This will not compile because the indeces are too large and m2 will not fit Mat<2,3> m3; Mat<10, 11> res3 = m.insert<8,8>(m3)

// This will not compile because m4 is too large Mat<100, 100> m4; Mat<10, 11> res4 = m.insert<5,6>(m4) ``` Warning! Can NOT be used for in place operations

Parameters:
m1Matrix in which the other matrix will be inserted
m2Matrix which will be inserted
resMatrix which will be inserted
Template Parameters:
NNumber of rows of 1st matrix
PNumber of columns of 1st matrix
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
TType of data
Returns:
success Return true if the matrix was inserted correctly, false if it was too big (in this case only the part that fitted was inserted)
template<uint32_t N, uint32_t P, uint32_t I, uint32_t J, uint32_t Q, uint32_t R, typename T >
bool mat::op::insert_inplace ( Mat< N, P, T > &  m1,
const Mat< Q, R, T > &  m2 
) [static]

Insert a sub matrix into another matrix.

Insert matrix m2 into m1, at starting index (I, J) example: ```cpp // Create matrices Mat<10,11> m;

// Will copy content of m2 into m starting at 5th row and 6th column Mat<2,3> m2; m.insert_inplace<5,6>(m2)

// This will not compile because the indeces are too large and m3 will not fit Mat<2,3> m3; m.insert_inplace<8,8>(m3)

// This will not compile because m4 is too large Mat<100, 100> m4; m.insert_inplace<5,6>(m4) ```

Warning! Can NOT be used for in place operations

Parameters:
m1Matrix in which the other matrix will be inserted
m2Matrix which will be inserted
Template Parameters:
NNumber of rows of 1st matrix
PNumber of columns of 1st matrix
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
TType of data
Returns:
success Return true if the matrix was inserted correctly, false if it was too big (in this case only the part that fitted was inserted)

TODO General matrix inversion using Gauss-Jordan reduction

template<>
bool mat::op::inverse ( const Mat< 1, 1, float > &  m,
Mat< 1, 1, float > &  res 
)

Inversion of 1x1 matrix (closed form)

template<>
bool mat::op::inverse ( const Mat< 2, 2, float > &  m,
Mat< 2, 2, float > &  res 
)

Inversion of 2x2 matrix (closed form)

template<>
bool mat::op::inverse ( const Mat< 3, 3, float > &  m,
Mat< 3, 3, float > &  res 
)

Inversion of 3x3 matrix (closed form)

template<>
bool mat::op::inverse ( const Mat< 4, 4, float > &  m,
Mat< 4, 4, float > &  res 
)

Inversion of 4x4 matrix (closed form)

Equations from www.cg.info.hiroshima-cu.ac.jp/~miyataki/knowledge/teche23.html

template<uint32_t N, typename T >
static bool mat::op::inverse ( const Mat< N, N, T > &  m,
Mat< N, N, T > &  res 
) [static]

Matrix dot product.

Performs res = m1 . m2

Warning! Can NOT be used for in place operations

Parameters:
mSquare matrix to inverse
resResult
Template Parameters:
NNumber of rows
TType of data
Returns:
success Indicates if the matrix could be inverted (true for success)

Here is the caller graph for this function:

template<uint32_t N, uint32_t P, typename T >
void mat::op::multiply ( const Mat< N, P, T > &  m1,
const Mat< N, P, T > &  m2,
Mat< N, P, T > &  res 
) [static]

Multiply two matrices element per element.

Performs res = m1 * m2 value per value

Can be used for in place operations (ie. m1 or m2 can be references to the same matrix as res)

Parameters:
m1First matrix to multiply
m2Second matrix to multiply
resResult
Template Parameters:
NNumber of rows
PNumber of columns
TType of data

Here is the caller graph for this function:

template<uint32_t N, uint32_t P, typename T >
void mat::op::multiply ( const Mat< N, P, T > &  m1,
const T  value,
Mat< N, P, T > &  res 
) [static]

Multiply a scalar to a matrix.

Performs res = m1 * value

Can be used for in place operations (ie. m1 can be a reference to the same matrix as res)

Parameters:
m1First matrix to multiply
valueValue to multiply
resResult
Template Parameters:
NNumber of rows
PNumber of columns
TType of data
template<uint32_t N, uint32_t P, typename T >
void mat::op::subtract ( const Mat< N, P, T > &  m1,
const Mat< N, P, T > &  m2,
Mat< N, P, T > &  res 
) [static]

Subtract two matrices.

Performs res = m1 - m2

Can be used for in place operations (ie. m1 or m2 can be references to the same matrix as res)

Parameters:
m1First matrix to subtract
m2Second matrix to subtract
resResult
Template Parameters:
NNumber of rows
PNumber of columns
TType of data

Here is the caller graph for this function:

template<uint32_t N, uint32_t P, typename T >
void mat::op::subtract ( const Mat< N, P, T > &  m1,
const T  value,
Mat< N, P, T > &  res 
) [static]

Subtract a scalar to a matrix.

Performs res = m1 - value

Can be used for in place operations (ie. m1 can be a reference to the same matrix as res)

Parameters:
m1First matrix to subtract
valueValue to subtract
resResult
Template Parameters:
NNumber of rows
PNumber of columns
TType of data
template<uint32_t N, uint32_t P, typename T >
void mat::op::transpose ( const Mat< N, P, T > &  m,
Mat< P, N, T > &  res 
) [static]

Transpose a matrix.

Performs res = m.T

Warning! Can NOT be used for in place operations

Parameters:
m1Matrix to transpose
resResult
Template Parameters:
NNumber of rows
PNumber of columns
TType of data

Here is the caller graph for this function:


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