1#ifndef CLASSIC_LUMatrix_HH
2#define CLASSIC_LUMatrix_HH
104 throw SizeError(
"LUMatrix::LUMatrix()",
"Matrix is not square.");
114 for(
int i = 0; i <
nr; i++) {
115 double maximum = 0.0;
117 for(
int j = 0; j <
nr; j++) {
118 double temp = std::abs(
decomp[i][j]);
119 if(temp > maximum) maximum = temp;
123 scaleVector[i] = 1.0 / maximum;
127 for(
int j = 0; j <
nr; j++) {
129 for(
int i = 0; i < j; i++) {
130 for(
int k = 0; k < i; k++) {
136 double maximum = 0.0;
140 for(
int i = j; i <
nr; i++) {
141 for(
int k = 0; k < j; k++) {
146 double dum = std::abs(scaleVector[i] *
decomp[i][j]);
157 decomp.swapRows(col_max, j);
158 std::swap(scaleVector[col_max], scaleVector[j]);
165 T dum = T(1) /
decomp[j][j];
166 for(
int i = j + 1; i <
nr; i++)
decomp[i][j] *= dum;
184template <
class T>
template <
class I>
inline
198 for(
int i = 0; i <
nr; i++) {
204 for(
int j = ii; j < i; j++) {
207 }
else if(
sum != 0) {
214 for(
int i =
nr; i > 0;) {
218 for(
int j = i + 1; j <
nr; j++) {
231 throw SizeError(
"LUMatrix::backSubstitute()",
"Inconsistent dimensions.");
241 throw SizeError(
"LUMatrix::backSubstitute()",
"Inconsistent dimensions.");
244 for(
int column = 0; column < M.
ncols(); column++) {
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
iterator begin()
Get beginning of data.
int size() const
Get array size.
int nrows() const
Get number of rows.
col_iterator col_begin(int c)
Get column iterator.
int ncols() const
Get number of columns.
void backSubstitute(Iterator) const
LUMatrix(const Matrix< T > &m)
Constructor.
void backSubstitute(Vector< T > &B) const
Back substitution.
Matrix< T > inverse() const
Get inverse.
LUMatrix< T > & operator=(const LUMatrix< T > &)
Singular matrix exception.