15#ifndef __EVT_MATRIX_HH__
16#define __EVT_MATRIX_HH__
32 T&
operator()(
int row,
int col ) {
return _mat[ row ][ col ]; }
49 if ( _range != range )
53 for (
int row = 0; row < _range; row++ )
58 _mat =
new T*[ range ];
59 for (
int row = 0; row < range; row++ )
60 _mat[ row ] =
new T[ range ];
67 for (
int row = 0; row < _range; row++ )
68 for (
int col = 0; col < _range; col++ )
69 _mat[ row ][ col ] = 0.;
75 for(
int row = 0; row < _range; row++ )
83 std::ostringstream str;
85 for (
int row = 0; row < _range; row++ )
88 for (
int col = 0; col < _range; col++ )
89 str <<
"\t" << _mat[ row ][ col ];
90 str <<
"\t|" << std::endl;
100 return _mat[ 0 ][ 0 ];
105 return _mat[ 0 ][ 0 ] * _mat[ 1 ][ 1 ] - _mat[ 0 ][ 1 ] * _mat[ 1 ][ 0 ];
109 for (
int col = 0; col < _range; col++ )
112 sum += std::pow( -1., col ) * _mat[ 0 ][ col ] * minor->
det();
128 for (
int r = 0; r < _range; r++ )
129 for (
int c = 0; c < _range; c++ )
130 if ( ( r != row ) && ( c != col ) )
132 (*minor)( minIndex / ( _range - 1 ), minIndex % ( _range - 1 ) ) = _mat[ r ][ c ];
147 std::cerr <<
"This matrix has a null determinant and cannot be inverted. Returning zero matrix." << std::endl;
148 for (
int row = 0; row < _range; row++ )
149 for (
int col = 0; col < _range; col++ )
150 (*inv)( row, col ) = 0.;
154 T determinant = det();
156 for (
int row = 0; row < _range; row++ )
157 for (
int col = 0; col < _range; col++ )
160 inv->_mat[col][row] = std::pow( -1., row + col ) * minor->
det() / determinant;
172 if ( left._range != right._range )
174 std::cerr <<
"These matrices cannot be multiplied." << std::endl;
182 for (
int row = 0; row < left._range; row++ )
183 for (
int col = 0; col < right._range; col++ )
184 (*mat)[ row ][ col ] = 0;
186 for (
int row = 0; row < left._range; row++ )
187 for (
int col = 0; col < right._range; col++ )
188 for (
int line = 0; line < right._range; line++ )
189 (*mat)[ row ][ col ] += left._mat[ row ][ line ] * right._mat[ line ][ col ];
EvtMatrix< T > * operator*(const EvtMatrix< T > &left, const EvtMatrix< T > &right)
friend EvtMatrix< M > * operator*(const EvtMatrix< M > &left, const EvtMatrix< M > &right)
EvtMatrix * min(int row, int col)
EvtMatrix * min(int row, int col)
T & operator()(int row, int col)