1#ifndef CLASSIC_FLUMatrix_HH
2#define CLASSIC_FLUMatrix_HH
41template <
class T,
int N>
74 template <
class Iterator>
88template <
class T,
int N>
94template <
class T,
int N>
96 decomp(rhs.decomp), index(rhs.index)
100template <
class T,
int N>
102 decomp(rhs), index(rhs.nrows()) {
109 for(
int i = 0; i < N; i++) {
110 double maximum = 0.0;
112 for(
int j = 0; j < N; j++) {
114 if(temp > maximum) maximum = temp;
118 scaleVector[i] = 1.0 / maximum;
122 for(
int j = 0; j < N; j++) {
124 for(
int i = 0; i < j; i++) {
125 for(
int k = 0; k < i; k++) {
131 double maximum = 0.0;
135 for(
int i = j; i < N; i++) {
136 for(
int k = 0; k < j; k++) {
153 std::swap(scaleVector[col_max], scaleVector[j]);
161 for(
int i = j + 1; i < N; i++)
decomp[i][j] *= dum;
166template <
class T,
int N>
171template <
class T,
int N>
179template <
class T,
int N>
template <
class I>
inline
191 for(
int i = 0; i < N; i++) {
197 for(
int j = ii; j < i; j++) {
198 sum -= decomp[i][j] * iter[j];
200 }
else if(
sum !=
T(0)) {
207 for(
int i = N; i > 0;) {
211 for(
int j = i + 1; j < N; j++) {
212 sum -= decomp[i][j] * iter[j];
216 iter[i] =
sum / decomp[i][i];
221template <
class T,
int N>
223 backSubstitute(B.
begin());
227template <
class T,
int N>
template <
int M>
229 for(
int column = 0; column < M; column++) {
230 backSubstitute(matrix.
col_begin(column));
235template <
class T,
int N>
238 result = result +
T(1);
239 backSubstitute(result);
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 iterator pointing to beginning of array.
col_iterator col_begin(int c)
Get column iterator.
void swapRows(int r1, int r2)
Exchange rows.
A templated representation of a LU-decomposition.
FMatrix< T, N, N > inverse() const
Get inverse.
void backSubstitute(FVector< T, N > &B) const
Back substitution.
FMatrix< T, N, N > decomp
void backSubstitute(Iterator) const
FLUMatrix< T, N > & operator=(const FLUMatrix &)
A templated representation for vectors.
Singular matrix exception.