Perform operations on matrices. More...
#include <matrix.hpp>
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.   | |
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.
| 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)
| m1 | First matrix to add | 
| m2 | Second matrix to add | 
| res | Result | 
| N | Number of rows | 
| P | Number of columns | 
| T | Type of data | 

| 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)
| m1 | First matrix to add | 
| value | Value to add | 
| res | Result | 
| N | Number of rows | 
| P | Number of columns | 
| T | Type of data | 
| 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)
| m | Matrix to clip | 
| min | Matrix with minimum values | 
| max | Matrix with maximum values | 
| void mat::op::clip | ( | Mat< N, P, T > & | m, | 
| float | min, | ||
| float | max | ||
| ) |  [static] | 
        
Clips matrix values.
| m | Matrix to clip | 
| min | Minimum value | 
| max | Maximum value | 
| 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
| m1 | First matrix to multiply | 
| m2 | Second matrix to multiply | 
| res | Result | 
| N | Number of rows of 1st matrix , also number of rows of output matrix | 
| P | Number of columns of 1st matrix , also number of rows of 2nd matrix | 
| Q | Number of columns of 2nd matrix , also number of columns of output matrix | 
| T | Type of data | 
| 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
| m1 | Matrix in which the other matrix will be inserted | 
| m2 | Matrix which will be inserted | 
| res | Matrix which will be inserted | 
| N | Number of rows of 1st matrix | 
| P | Number of columns of 1st matrix | 
| I | Row index of the first top left element to be inserted (index in m1) | 
| J | Column index of the first top left element to be inserted (index in m1) | 
| Q | Number of rows of 2nd matrix | 
| R | Number of columns of 2nd matrix | 
| T | Type of data | 
| 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
| m1 | Matrix in which the other matrix will be inserted | 
| m2 | Matrix which will be inserted | 
| N | Number of rows of 1st matrix | 
| P | Number of columns of 1st matrix | 
| I | Row index of the first top left element to be inserted (index in m1) | 
| J | Column index of the first top left element to be inserted (index in m1) | 
| Q | Number of rows of 2nd matrix | 
| R | Number of columns of 2nd matrix | 
| T | Type of data | 
TODO General matrix inversion using Gauss-Jordan reduction
| bool mat::op::inverse | ( | const Mat< 1, 1, float > & | m, | 
| Mat< 1, 1, float > & | res | ||
| ) | 
Inversion of 1x1 matrix (closed form)
| bool mat::op::inverse | ( | const Mat< 2, 2, float > & | m, | 
| Mat< 2, 2, float > & | res | ||
| ) | 
Inversion of 2x2 matrix (closed form)
| bool mat::op::inverse | ( | const Mat< 3, 3, float > & | m, | 
| Mat< 3, 3, float > & | res | ||
| ) | 
Inversion of 3x3 matrix (closed form)
| 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
| 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
| m | Square matrix to inverse | 
| res | Result | 
| N | Number of rows | 
| T | Type of data | 

| 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)
| m1 | First matrix to multiply | 
| m2 | Second matrix to multiply | 
| res | Result | 
| N | Number of rows | 
| P | Number of columns | 
| T | Type of data | 

| 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)
| m1 | First matrix to multiply | 
| value | Value to multiply | 
| res | Result | 
| N | Number of rows | 
| P | Number of columns | 
| T | Type of data | 
| 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)
| m1 | First matrix to subtract | 
| m2 | Second matrix to subtract | 
| res | Result | 
| N | Number of rows | 
| P | Number of columns | 
| T | Type of data | 

| 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)
| m1 | First matrix to subtract | 
| value | Value to subtract | 
| res | Result | 
| N | Number of rows | 
| P | Number of columns | 
| T | Type of data | 
| 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
| m1 | Matrix to transpose | 
| res | Result | 
| N | Number of rows | 
| P | Number of columns | 
| T | Type of data | 

 1.7.6.1