Class representing a fixed-size matrix. More...
#include <util/matrix.h>
Public Types | |
typedef const T * | const_iterator |
typedef const T * | const_pointer_type |
typedef const T & | const_reference_type |
typedef T * | iterator |
typedef T * | pointer_type |
typedef T & | reference_type |
typedef T | value_type |
Public Member Functions | |
const T * | c_data () const |
Returns a constant raw pointer on the data. | |
T * | data () |
Returns a raw pointer on the data. | |
void | fillArray (T *array, bool row_first=true) |
Matrix (const T &value) | |
Create a diagonal matrix. | |
Matrix (const T *values, bool c_style=true) | |
Fill in the matrix with the values . | |
template<typename T1 > | |
Matrix (const Vector< nCols, T1 > *vecs) | |
Fill the matrix with the array of vectors. | |
template<size_t nRows1, size_t nCols1, typename T1 > | |
Matrix (const Matrix< nRows1, nCols1, T1 > &mat) | |
Copy a matrix. | |
template<typename T1 > | |
Matrix (const Matrix< nRows, nCols, T1 > &mat) | |
Copy a matrix. | |
Matrix (const Matrix &mat) | |
Copy constructor. | |
Matrix (void) | |
Create a matrix filled with 0s. | |
bool | operator!= (const Matrix &mat) const |
T | operator() (size_t i, size_t j) const |
Return the value at row i , column j . | |
T & | operator() (size_t i, size_t j) |
Return the value at row i , column j . | |
Vector< nRows, T > | operator* (const Vector< nCols, T > &vec) const |
Matrix*Vector. | |
Matrix | operator* (const T &scalar) const |
Matrix-scalar multiplication. | |
Matrix & | operator*= (const Matrix &mat) |
Matrix & | operator*= (const T &scalar) |
Matrix | operator+ (const Matrix &mat) const |
Matrix addition. | |
Matrix & | operator+= (const Matrix &mat) |
Matrix | operator- (const Matrix &mat) const |
Matrix | operator- (void) const |
Matrix subtraction. | |
Matrix & | operator-= (const Matrix &mat) |
Matrix | operator/ (const T &scalar) const |
Matrix-scalar division. | |
Matrix & | operator/= (const T &scalar) |
Matrix & | operator= (const T &value) |
Set the matrix to a diagonal matrix. | |
Matrix & | operator= (const Matrix &mat) |
bool | operator== (const Matrix &mat) const |
Vector< nCols, T > | operator[] (size_t idx) const |
Returns the nth row. | |
Vector< nCols, T > & | operator[] (size_t idx) |
Returns the nth row. | |
Matrix< nCols, nRows, T > | operator~ () |
Transpose the matrix. | |
T | trace () const |
Trace of the matrix. | |
Matrix & | zero (void) |
Set the matrix to all zero. | |
Static Public Member Functions | |
static Matrix | identity () |
Returns an identity matrix. | |
static size_t | nbColumns () |
Returns the number of columns of the matrix. | |
static size_t | nbRows () |
Returns the number of rows of the matrix. | |
static Matrix< 4, 4, T > | rotation (const Vector< 4, T > &direction, T angle) |
Creates the 4x4 matrix corresponding to a rotation. | |
static Matrix< 3, 3, T > | rotation (const Vector< 3, T > &direction, T angle) |
Creates the 3x3 matrix corresponding to a rotation. | |
static Vector< 2, size_t > | size () |
Returns the size of the matrix. | |
Friends | |
Matrix | operator* (const T &scalar, const Matrix &mat) |
Matrix-scalar multiplication. | |
std::ostream & | operator<< (std::ostream &out, const Matrix &mat) |
QTextStream & | operator<< (QTextStream &out, const Matrix &mat) |
std::istream & | operator>> (std::istream &in, Matrix &mat) |
QTextStream & | operator>> (QTextStream &in, Matrix &mat) |
Related Functions | |
(Note that these are not member functions.) | |
template<size_t nRows, typename T > | |
T | cofactor (const Matrix< nRows, nRows, T > &mat, size_t i, size_t j) |
Returns the cofactor of the matrix for position (i,j). | |
template<size_t nRows, typename T > | |
T | det (const Matrix< nRows, nRows, T > &mat) |
Determinant of the matrix. | |
template<typename T > | |
T | det (const Matrix< 3, 3, T > &mat) |
Determinant of the matrix. | |
template<typename T > | |
T | det (const Matrix< 2, 2, T > &mat) |
Determinant of the matrix. | |
template<typename T > | |
T | det (const Matrix< 1, 1, T > &mat) |
Determinant of the matrix. | |
template<size_t nRows, typename T > | |
Matrix< nRows, nRows, T > | inverse (const Matrix< nRows, nRows, T > &mat) |
Inverse the matrix. | |
template<typename T > | |
Matrix< 3, 3, T > | inverse (const Matrix< 3, 3, T > &mat) |
Inverse the matrix. | |
template<typename T > | |
Matrix< 2, 2, T > | inverse (const Matrix< 2, 2, T > &mat) |
Inverse the matrix. | |
template<typename T > | |
Matrix< 1, 1, T > | inverse (const Matrix< 1, 1, T > &mat) |
Inverse the matrix. | |
template<size_t nRows, size_t nCols, typename T , typename T1 , typename T2 > | |
Matrix< nRows, nCols, T > | map (const T &(*fct)(const T1 &, const T2 &), const Matrix< nRows, nCols, T1 > &m1, const Matrix< nRows, nCols, T2 > &m2) |
Apply a binary function to each element of the matrix. | |
template<size_t nRows, size_t nCols, typename T , typename T1 , typename T2 > | |
Matrix< nRows, nCols, T > | map (T(*fct)(const T1 &, const T2 &), const Matrix< nRows, nCols, T1 > &m1, const Matrix< nRows, nCols, T2 > &m2) |
Apply a binary function to each element of the matrix. | |
template<size_t nRows, size_t nCols, typename T , typename T1 , typename T2 > | |
Matrix< nRows, nCols, T > | map (T(*fct)(T1, T2), const Matrix< nRows, nCols, T1 > &m1, const Matrix< nRows, nCols, T2 > &m2) |
Apply a binary function to each element of the matrix. | |
template<size_t nRows, size_t nCols, typename T > | |
Matrix< nRows, nCols, T > | map (const T &(*fct)(const T &, const T &), const Matrix< nRows, nCols, T > &m1, const Matrix< nRows, nCols, T > &m2) |
Apply a binary function to each element of the matrix. | |
template<size_t nRows, size_t nCols, typename T > | |
Matrix< nRows, nCols, T > | map (T(*fct)(const T &, const T &), const Matrix< nRows, nCols, T > &m1, const Matrix< nRows, nCols, T > &m2) |
Apply a binary function to each element of the matrix. | |
template<size_t nRows, size_t nCols, typename T > | |
Matrix< nRows, nCols, T > | map (T(*fct)(T, T), const Matrix< nRows, nCols, T > &m1, const Matrix< nRows, nCols, T > &m2) |
Apply a binary function to each element of the matrix. | |
template<size_t nRows, size_t nCols, typename T , typename T1 > | |
Matrix< nRows, nCols, T > | map (T(*fct)(const T1 &), const Matrix< nRows, nCols, T1 > &m) |
Apply a unary function to each element of the matrix. | |
template<size_t nRows, size_t nCols, typename T , typename T1 > | |
Matrix< nRows, nCols, T > | map (T(*fct)(T1), const Matrix< nRows, nCols, T1 > &m) |
Apply a unary function to each element of the matrix. | |
template<size_t nRows, size_t nCols, typename T , typename T1 > | |
Matrix< nRows, nCols, T > | map (const T &(*fct)(const T1 &), const Matrix< nRows, nCols, T1 > &m) |
Apply a unary function to each element of the matrix. | |
template<size_t nRows, size_t nCols, typename T > | |
Matrix< nRows, nCols, T > | map (T(*fct)(const T &), const Matrix< nRows, nCols, T > &m) |
Apply a unary function to each element of the matrix. | |
template<size_t nRows, size_t nCols, typename T > | |
Matrix< nRows, nCols, T > | map (T(*fct)(T), const Matrix< nRows, nCols, T > &m) |
Apply a unary function to each element of the matrix. | |
template<size_t nRows, size_t nCols, typename T > | |
Matrix< nRows, nCols, T > | map (const T &(*fct)(const T &), const Matrix< nRows, nCols, T > &m) |
Apply a unary function to each element of the matrix. | |
template<size_t nRows, size_t nCols, typename T > | |
T | norm (const Matrix< nRows, nCols, T > &mat) |
Return the norm of the matrix. | |
template<size_t nRows, size_t nCols, typename T > | |
T | normsq (const Matrix< nRows, nCols, T > &mat) |
Return the square norm of the matrix. | |
template<size_t nRows, size_t nSize, size_t nCols, typename T > | |
Matrix< nRows, nCols, T > | operator* (const Matrix< nRows, nSize, T > &mat1, const Matrix< nSize, nCols, T > &mat2) |
Matrix multiplication. | |
template<size_t nRows, size_t nCols, typename T > | |
Matrix< nCols, nRows, T > | transpose (const Matrix< nRows, nCols, T > &mat) |
Transpose a matrix. |
Class representing a fixed-size matrix.
This class is optimized for small-sized matrix (3x3 or 4x4).
Definition at line 25 of file matrix.h.
util::Matrix< nRows, nCols, T >::Matrix | ( | void | ) | [inline] |
util::Matrix< nRows, nCols, T >::Matrix | ( | const Matrix< nRows, nCols, T > & | mat | ) | [inline] |
util::Matrix< nRows, nCols, T >::Matrix | ( | const Matrix< nRows, nCols, T1 > & | mat | ) | [inline, explicit] |
util::Matrix< nRows, nCols, T >::Matrix | ( | const Matrix< nRows1, nCols1, T1 > & | mat | ) | [inline, explicit] |
Copy a matrix.
Can be used to copy a matrix with more or less dimensions.
If the input has more dimensions, then the extra ones are just ignored. If the input has less dimensions, 1s are inserted in the diagonal, and 0s outside
Definition at line 79 of file matrix.h.
00080 { 00081 int rowMax = nRows1 < nRows ? nRows1 : nRows; 00082 int colMax = nCols1 < nCols ? nCols1 : nCols; 00083 for(size_t i = 0 ; i < rowMax ; i++) 00084 { 00085 Vector<nCols,T>& c = rows[i]; 00086 const Vector<nCols1,T1>& c1 = mat[i]; 00087 for(size_t j = 0 ; j < colMax ; j++) 00088 c[j] = c1[j]; 00089 if(colMax < nCols) 00090 for(size_t j = colMax ; j < nCols ; ++j) 00091 c[j] = i==j ? T(1) : T(0); 00092 } 00093 if(rowMax < nRows) 00094 { 00095 for(size_t i = rowMax ; i < nRows ; ++i) 00096 { 00097 Vector<nCols,T>& c = rows[i]; 00098 for(size_t j = colMax ; j < nCols ; ++j) 00099 c[j] = i==j ? T(1) : T(0); 00100 } 00101 } 00102 }
util::Matrix< nRows, nCols, T >::Matrix | ( | const Vector< nCols, T1 > * | vecs | ) | [inline] |
util::Matrix< nRows, nCols, T >::Matrix | ( | const T * | values, | |
bool | c_style = true | |||
) | [inline] |
Fill in the matrix with the values
.
values | nRows*nCols array. If c_style is true, values is rows first (i.e. the first values correspond to the first row). Otherwise, values are columns first. | |
c_style | Determine the ordering of values. |
Definition at line 130 of file matrix.h.
00131 { 00132 if(c_style) 00133 { 00134 for(size_t i = 0 ; i < nRows ; i++) 00135 { 00136 rows[i] = Vector<nCols,T>(values + (i*nCols)); 00137 } 00138 } 00139 else 00140 { 00141 for(size_t i = 0 ; i < nRows ; i++) 00142 for(size_t j = 0 ; j < nCols ; j++) 00143 { 00144 rows[i][j] = values[i+j*nRows]; 00145 } 00146 } 00147 }
util::Matrix< nRows, nCols, T >::Matrix | ( | const T & | value | ) | [inline] |
const T* util::Matrix< nRows, nCols, T >::c_data | ( | ) | const [inline] |
T* util::Matrix< nRows, nCols, T >::data | ( | ) | [inline] |
static Matrix util::Matrix< nRows, nCols, T >::identity | ( | ) | [inline, static] |
static size_t util::Matrix< nRows, nCols, T >::nbColumns | ( | ) | [inline, static] |
static size_t util::Matrix< nRows, nCols, T >::nbRows | ( | ) | [inline, static] |
T util::Matrix< nRows, nCols, T >::operator() | ( | size_t | i, | |
size_t | j | |||
) | const [inline] |
T& util::Matrix< nRows, nCols, T >::operator() | ( | size_t | i, | |
size_t | j | |||
) | [inline] |
Vector<nRows,T> util::Matrix< nRows, nCols, T >::operator* | ( | const Vector< nCols, T > & | vec | ) | const [inline] |
Matrix util::Matrix< nRows, nCols, T >::operator* | ( | const T & | scalar | ) | const [inline] |
Matrix util::Matrix< nRows, nCols, T >::operator+ | ( | const Matrix< nRows, nCols, T > & | mat | ) | const [inline] |
Matrix util::Matrix< nRows, nCols, T >::operator- | ( | void | ) | const [inline] |
Matrix util::Matrix< nRows, nCols, T >::operator/ | ( | const T & | scalar | ) | const [inline] |
Matrix& util::Matrix< nRows, nCols, T >::operator= | ( | const T & | value | ) | [inline] |
Set the matrix to a diagonal matrix.
value | Value to put on the diagonal |
Vector<nCols,T> util::Matrix< nRows, nCols, T >::operator[] | ( | size_t | idx | ) | const [inline] |
Vector<nCols,T>& util::Matrix< nRows, nCols, T >::operator[] | ( | size_t | idx | ) | [inline] |
Matrix<nCols,nRows,T> util::Matrix< nRows, nCols, T >::operator~ | ( | ) | [inline] |
static Matrix<4,4,T> util::Matrix< nRows, nCols, T >::rotation | ( | const Vector< 4, T > & | direction, | |
T | angle | |||
) | [inline, static] |
Creates the 4x4 matrix corresponding to a rotation.
direction | Axes of the rotation | |
angle | Angle of the rotation |
Definition at line 485 of file matrix.h.
00486 { 00487 T ca = std::cos( angle ); 00488 T sa = std::sin( angle ); 00489 Matrix<4,4,T> r; 00490 double x = direction.x()/direction.t(); 00491 double y = direction.y()/direction.t(); 00492 double z = direction.z()/direction.t(); 00493 r[ 0 ].set( ca+(1-ca)*x*x, (1-ca)*x*y-sa*z, (1-ca)*z*x+sa*y, 0 ); 00494 r[ 1 ].set( (1-ca)*y*x+sa*z, ca+(1-ca)*y*y, (1-ca)*z*y-sa*x, 0 ); 00495 r[ 2 ].set( (1-ca)*x*z-sa*y, (1-ca)*y*z+sa*x, ca+(1-ca)*z*z, 0 ); 00496 r[ 3 ].set( 0, 0, 0, 1 ); 00497 return r; 00498 }
static Matrix<3,3,T> util::Matrix< nRows, nCols, T >::rotation | ( | const Vector< 3, T > & | direction, | |
T | angle | |||
) | [inline, static] |
Creates the 3x3 matrix corresponding to a rotation.
direction | Axes of the rotation | |
angle | Angle of the rotation |
Definition at line 465 of file matrix.h.
00466 { 00467 T ca = std::cos( angle ); 00468 T sa = std::sin( angle ); 00469 Matrix<3,3,T> r; 00470 double x = direction.x(); 00471 double y = direction.y(); 00472 double z = direction.z(); 00473 r[ 0 ].set( ca+(1-ca)*x*x, (1-ca)*x*y-sa*z, (1-ca)*z*x+sa*y ); 00474 r[ 1 ].set( (1-ca)*y*x+sa*z, ca+(1-ca)*y*y, (1-ca)*z*y-sa*x ); 00475 r[ 2 ].set( (1-ca)*x*z-sa*y, (1-ca)*y*z+sa*x, ca+(1-ca)*z*z ); 00476 return r; 00477 }
static Vector<2,size_t> util::Matrix< nRows, nCols, T >::size | ( | ) | [inline, static] |
T util::Matrix< nRows, nCols, T >::trace | ( | ) | const [inline] |
Matrix& util::Matrix< nRows, nCols, T >::zero | ( | void | ) | [inline] |
T cofactor | ( | const Matrix< nRows, nRows, T > & | mat, | |
size_t | i, | |||
size_t | j | |||
) | [related] |
Returns the cofactor of the matrix for position (i,j).
T det | ( | const Matrix< nRows, nRows, T > & | mat | ) | [related] |
Determinant of the matrix.
T det | ( | const Matrix< 3, 3, T > & | mat | ) | [related] |
Determinant of the matrix.
T det | ( | const Matrix< 2, 2, T > & | mat | ) | [related] |
Determinant of the matrix.
T det | ( | const Matrix< 1, 1, T > & | mat | ) | [related] |
Determinant of the matrix.
Matrix< nRows, nRows, T > inverse | ( | const Matrix< nRows, nRows, T > & | mat | ) | [related] |
Inverse the matrix.
Inverse the matrix.
Inverse the matrix.
Inverse the matrix.
Matrix< nRows, nCols, T > map | ( | const T &(*)(const T1 &, const T2 &) | fct, | |
const Matrix< nRows, nCols, T1 > & | m1, | |||
const Matrix< nRows, nCols, T2 > & | m2 | |||
) | [related] |
Apply a binary function to each element of the matrix.
Definition at line 876 of file matrix.h.
00877 { 00878 Matrix<nRows,nCols,T> result; 00879 for(size_t i = 0 ; i < nRows ; ++i) 00880 { 00881 const Vector<nCols,T1>& mrow1 = m1[i]; 00882 const Vector<nCols,T2>& mrow2 = m2[i]; 00883 Vector<nCols,T>& rrow = result[i]; 00884 for(size_t j = 0 ; j < nCols ; ++j) 00885 { 00886 rrow[j] = (*fct)(mrow1[j], mrow2[j]); 00887 } 00888 } 00889 return result; 00890 }
Matrix< nRows, nCols, T > map | ( | T(*)(const T1 &, const T2 &) | fct, | |
const Matrix< nRows, nCols, T1 > & | m1, | |||
const Matrix< nRows, nCols, T2 > & | m2 | |||
) | [related] |
Apply a binary function to each element of the matrix.
Definition at line 854 of file matrix.h.
00855 { 00856 Matrix<nRows,nCols,T> result; 00857 for(size_t i = 0 ; i < nRows ; ++i) 00858 { 00859 const Vector<nCols,T1>& mrow1 = m1[i]; 00860 const Vector<nCols,T2>& mrow2 = m2[i]; 00861 Vector<nCols,T>& rrow = result[i]; 00862 for(size_t j = 0 ; j < nCols ; ++j) 00863 { 00864 rrow[j] = (*fct)(mrow1[j], mrow2[j]); 00865 } 00866 } 00867 return result; 00868 }
Matrix< nRows, nCols, T > map | ( | T(*)(T1, T2) | fct, | |
const Matrix< nRows, nCols, T1 > & | m1, | |||
const Matrix< nRows, nCols, T2 > & | m2 | |||
) | [related] |
Apply a binary function to each element of the matrix.
Definition at line 832 of file matrix.h.
00833 { 00834 Matrix<nRows,nCols,T> result; 00835 for(size_t i = 0 ; i < nRows ; ++i) 00836 { 00837 const Vector<nCols,T1>& mrow1 = m1[i]; 00838 const Vector<nCols,T2>& mrow2 = m2[i]; 00839 Vector<nCols,T>& rrow = result[i]; 00840 for(size_t j = 0 ; j < nCols ; ++j) 00841 { 00842 rrow[j] = (*fct)(mrow1[j], mrow2[j]); 00843 } 00844 } 00845 return result; 00846 }
Matrix< nRows, nCols, T > map | ( | const T &(*)(const T &, const T &) | fct, | |
const Matrix< nRows, nCols, T > & | m1, | |||
const Matrix< nRows, nCols, T > & | m2 | |||
) | [related] |
Apply a binary function to each element of the matrix.
Definition at line 810 of file matrix.h.
00811 { 00812 Matrix<nRows,nCols,T> result; 00813 for(size_t i = 0 ; i < nRows ; ++i) 00814 { 00815 const Vector<nCols,T>& mrow1 = m1[i]; 00816 const Vector<nCols,T>& mrow2 = m2[i]; 00817 Vector<nCols,T>& rrow = result[i]; 00818 for(size_t j = 0 ; j < nCols ; ++j) 00819 { 00820 rrow[j] = (*fct)(mrow1[j], mrow2[j]); 00821 } 00822 } 00823 return result; 00824 }
Matrix< nRows, nCols, T > map | ( | T(*)(const T &, const T &) | fct, | |
const Matrix< nRows, nCols, T > & | m1, | |||
const Matrix< nRows, nCols, T > & | m2 | |||
) | [related] |
Apply a binary function to each element of the matrix.
Definition at line 788 of file matrix.h.
00789 { 00790 Matrix<nRows,nCols,T> result; 00791 for(size_t i = 0 ; i < nRows ; ++i) 00792 { 00793 const Vector<nCols,T>& mrow1 = m1[i]; 00794 const Vector<nCols,T>& mrow2 = m2[i]; 00795 Vector<nCols,T>& rrow = result[i]; 00796 for(size_t j = 0 ; j < nCols ; ++j) 00797 { 00798 rrow[j] = (*fct)(mrow1[j], mrow2[j]); 00799 } 00800 } 00801 return result; 00802 }
Matrix< nRows, nCols, T > map | ( | T(*)(T, T) | fct, | |
const Matrix< nRows, nCols, T > & | m1, | |||
const Matrix< nRows, nCols, T > & | m2 | |||
) | [related] |
Apply a binary function to each element of the matrix.
Definition at line 766 of file matrix.h.
00767 { 00768 Matrix<nRows,nCols,T> result; 00769 for(size_t i = 0 ; i < nRows ; ++i) 00770 { 00771 const Vector<nCols,T>& mrow1 = m1[i]; 00772 const Vector<nCols,T>& mrow2 = m2[i]; 00773 Vector<nCols,T>& rrow = result[i]; 00774 for(size_t j = 0 ; j < nCols ; ++j) 00775 { 00776 rrow[j] = (*fct)(mrow1[j], mrow2[j]); 00777 } 00778 } 00779 return result; 00780 }
Matrix< nRows, nCols, T > map | ( | T(*)(const T1 &) | fct, | |
const Matrix< nRows, nCols, T1 > & | m | |||
) | [related] |
Apply a unary function to each element of the matrix.
Definition at line 745 of file matrix.h.
00746 { 00747 Matrix<nRows,nCols,T> result; 00748 for(size_t i = 0 ; i < nRows ; ++i) 00749 { 00750 const Vector<nCols,T1>& mrow = m[i]; 00751 Vector<nCols,T>& rrow = result[i]; 00752 for(size_t j = 0 ; j < nCols ; ++j) 00753 { 00754 rrow[j] = (*fct)(mrow[j]); 00755 } 00756 } 00757 return result; 00758 }
Matrix< nRows, nCols, T > map | ( | T(*)(T1) | fct, | |
const Matrix< nRows, nCols, T1 > & | m | |||
) | [related] |
Apply a unary function to each element of the matrix.
Definition at line 723 of file matrix.h.
00724 { 00725 Matrix<nRows,nCols,T> result; 00726 for(size_t i = 0 ; i < nRows ; ++i) 00727 { 00728 const Vector<nCols,T1>& mrow = m[i]; 00729 Vector<nCols,T>& rrow = result[i]; 00730 for(size_t j = 0 ; j < nCols ; ++j) 00731 { 00732 rrow[j] = (*fct)(mrow[j]); 00733 } 00734 } 00735 return result; 00736 }
Matrix< nRows, nCols, T > map | ( | const T &(*)(const T1 &) | fct, | |
const Matrix< nRows, nCols, T1 > & | m | |||
) | [related] |
Apply a unary function to each element of the matrix.
Definition at line 702 of file matrix.h.
00703 { 00704 Matrix<nRows,nCols,T> result; 00705 for(size_t i = 0 ; i < nRows ; ++i) 00706 { 00707 const Vector<nCols,T1>& mrow = m[i]; 00708 Vector<nCols,T>& rrow = result[i]; 00709 for(size_t j = 0 ; j < nCols ; ++j) 00710 { 00711 rrow[j] = (*fct)(mrow[j]); 00712 } 00713 } 00714 return result; 00715 }
Matrix< nRows, nCols, T > map | ( | T(*)(const T &) | fct, | |
const Matrix< nRows, nCols, T > & | m | |||
) | [related] |
Apply a unary function to each element of the matrix.
Definition at line 681 of file matrix.h.
00682 { 00683 Matrix<nRows,nCols,T> result; 00684 for(size_t i = 0 ; i < nRows ; ++i) 00685 { 00686 const Vector<nCols,T>& mrow = m[i]; 00687 Vector<nCols,T>& rrow = result[i]; 00688 for(size_t j = 0 ; j < nCols ; ++j) 00689 { 00690 rrow[j] = (*fct)(mrow[j]); 00691 } 00692 } 00693 return result; 00694 }
Matrix< nRows, nCols, T > map | ( | T(*)(T) | fct, | |
const Matrix< nRows, nCols, T > & | m | |||
) | [related] |
Apply a unary function to each element of the matrix.
Definition at line 659 of file matrix.h.
00660 { 00661 Matrix<nRows,nCols,T> result; 00662 for(size_t i = 0 ; i < nRows ; ++i) 00663 { 00664 const Vector<nCols,T>& mrow = m[i]; 00665 Vector<nCols,T>& rrow = result[i]; 00666 for(size_t j = 0 ; j < nCols ; ++j) 00667 { 00668 rrow[j] = (*fct)(mrow[j]); 00669 } 00670 } 00671 return result; 00672 }
Matrix< nRows, nCols, T > map | ( | const T &(*)(const T &) | fct, | |
const Matrix< nRows, nCols, T > & | m | |||
) | [related] |
Apply a unary function to each element of the matrix.
Definition at line 638 of file matrix.h.
00639 { 00640 Matrix<nRows,nCols,T> result; 00641 for(size_t i = 0 ; i < nRows ; ++i) 00642 { 00643 const Vector<nCols,T>& mrow = m[i]; 00644 Vector<nCols,T>& rrow = result[i]; 00645 for(size_t j = 0 ; j < nCols ; ++j) 00646 { 00647 rrow[j] = (*fct)(mrow[j]); 00648 } 00649 } 00650 return result; 00651 }
T norm | ( | const Matrix< nRows, nCols, T > & | mat | ) | [related] |
Return the norm of the matrix.
The norm is defined as the square-root of the sum of the square of the values.
T normsq | ( | const Matrix< nRows, nCols, T > & | mat | ) | [related] |
Return the square norm of the matrix.
Matrix< nRows, nCols, T > operator* | ( | const Matrix< nRows, nSize, T > & | mat1, | |
const Matrix< nSize, nCols, T > & | mat2 | |||
) | [related] |
Matrix multiplication.
Matrix< nCols, nRows, T > transpose | ( | const Matrix< nRows, nCols, T > & | mat | ) | [related] |
Transpose a matrix.