21 #ifndef __EVT_MATRIX_HH__ 22 #define __EVT_MATRIX_HH__ 56 if ( _range != range ) {
58 for (
int row = 0; row < _range; row++ )
64 for (
int row = 0; row < range; row++ )
65 _mat[row] =
new T[range];
72 for (
int row = 0; row < _range; row++ )
73 for (
int col = 0; col < _range; col++ )
80 for (
int row = 0; row < _range; row++ )
88 std::ostringstream str;
90 for (
int row = 0; row < _range; row++ ) {
92 for (
int col = 0; col < _range; col++ )
93 str <<
"\t" << _mat[row][col];
94 str <<
"\t|" << std::endl;
109 return _mat[0][0] * _mat[1][1] - _mat[0][1] * _mat[1][0];
113 for (
int col = 0; col < _range; col++ ) {
115 sum += std::pow( -1., col ) * _mat[0][col] * minor->
det();
131 for (
int r = 0; r < _range; r++ )
132 for (
int c = 0; c < _range; c++ )
133 if ( ( r != row ) && ( c != col ) ) {
134 ( *minor )( minIndex / ( _range - 1 ),
135 minIndex % ( _range - 1 ) ) = _mat[r][c];
149 std::cerr <<
"This matrix has a null determinant and cannot be inverted. Returning zero matrix." 151 for (
int row = 0; row < _range; row++ )
152 for (
int col = 0; col < _range; col++ )
153 ( *inv )( row, col ) = 0.;
157 T determinant = det();
159 for (
int row = 0; row < _range; row++ )
160 for (
int col = 0; col < _range; col++ ) {
162 inv->
_mat[col][row] = std::pow( -1., row + col ) * minor->
det() /
175 std::cerr <<
"These matrices cannot be multiplied." << std::endl;
183 for (
int row = 0; row < left.
_range; row++ )
184 for (
int col = 0; col < right.
_range; col++ )
185 ( *mat )[row][col] = 0;
187 for (
int row = 0; row < left.
_range; row++ )
188 for (
int col = 0; col < right.
_range; col++ )
189 for (
int line = 0; line < right.
_range; line++ )
190 ( *mat )[row][col] += left.
_mat[row][line] *
191 right.
_mat[line][col];
EvtMatrix< T > * operator *(const EvtMatrix< T > &left, const EvtMatrix< T > &right)
EvtMatrix * min(int row, int col)
friend EvtMatrix< M > * operator *(const EvtMatrix< M > &left, const EvtMatrix< M > &right)
T & operator()(int row, int col)