1#ifndef CLASSIC_LUMatrix_HH
2#define CLASSIC_LUMatrix_HH
96 decomp(rhs.decomp), index(rhs.index)
102 decomp(rhs), index(rhs.nrows()) {
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++) {
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++) {
157 decomp.swapRows(col_max, j);
158 std::swap(scaleVector[col_max], scaleVector[j]);
166 for(
int i = j + 1; i <
nr; i++)
decomp[i][j] *= dum;
184template <
class T>
template <
class I>
inline
195 int nr = decomp.nrows();
198 for(
int i = 0; i <
nr; i++) {
204 for(
int j = ii; j < i; j++) {
205 sum -= decomp[i][j] * iter[j];
207 }
else if(
sum != 0) {
214 for(
int i =
nr; i > 0;) {
218 for(
int j = i + 1; j <
nr; j++) {
219 sum -= decomp[i][j] * iter[j];
223 iter[i] =
sum / decomp[i][i];
230 if(B.
size() != decomp.nrows()) {
231 throw SizeError(
"LUMatrix::backSubstitute()",
"Inconsistent dimensions.");
234 backSubstitute(B.
begin());
240 if(M.
nrows() != decomp.nrows()) {
241 throw SizeError(
"LUMatrix::backSubstitute()",
"Inconsistent dimensions.");
244 for(
int column = 0; column < M.
ncols(); column++) {
252 int nr = decomp.nrows();
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
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.
Triangle decomposition of a matrix.
void backSubstitute(Iterator) const
void backSubstitute(Vector< T > &B) const
Back substitution.
Matrix< T > inverse() const
Get inverse.
LUMatrix< T > & operator=(const LUMatrix< T > &)
Singular matrix exception.