3 #ifndef DUNE_LOCALFUNCTIONS_UTILITY_LFEMATRIX_HH
4 #define DUNE_LOCALFUNCTIONS_UTILITY_LFEMATRIX_HH
14 template<
class F,
bool aligned = false >
17 template<
class F,
bool aligned >
21 typedef std::vector< F > Row;
22 typedef std::vector<Row> RealMatrix;
27 operator const RealMatrix & ()
const
32 operator RealMatrix & ()
37 template <
class Vector>
38 void row(
const unsigned int row, Vector &vec )
const
41 for (
int i=0; i<
cols(); ++i)
49 return matrix_[
row ][ col ];
56 return matrix_[
row ][ col ];
72 return &(matrix_[
row][0]);
78 return &(matrix_[
row][0]);
84 for (
unsigned int i=0; i<
rows; ++i)
93 std::vector<unsigned int> p(
rows());
94 for (
unsigned int j=0; j<
rows(); ++j)
96 for (
unsigned int j=0; j<
rows(); ++j)
100 Field max = std::abs( (*
this)(j,j) );
101 for (
unsigned int i=j+1; i<
rows(); ++i)
103 if ( std::abs( (*
this)(i,j) ) > max )
105 max = std::abs( (*
this)(i,j) );
114 for (
unsigned int k=0; k<
cols(); ++k)
115 std::swap( (*
this)(j,k), (*
this)(r,k) );
116 std::swap( p[j], p[r] );
120 for (
unsigned int i=0; i<
rows(); ++i)
123 for (
unsigned int k=0; k<
cols(); ++k)
126 for (
unsigned int i=0; i<
rows(); ++i)
129 (*this)(i,k) -= (*
this)(i,j)*(*
this)(j,k);
136 for (
unsigned int i=0; i<
rows(); ++i)
138 for (
unsigned int k=0; k<
rows(); ++k)
139 hv[ p[k] ] = (*
this)(i,k);
140 for (
unsigned int k=0; k<
rows(); ++k)
141 (*
this)(i,k) = hv[k];
148 unsigned int cols_,rows_;
151 template<
class Field,
bool aligned >
152 inline std::ostream &operator<<(std::ostream &out, const LFEMatrix<Field,aligned> &mat)
154 for (
unsigned int r=0; r<mat.rows(); ++r)
156 out << field_cast<double>(mat(r,0));
157 for (
unsigned int c=1; c<mat.cols(); ++c)
167 #endif // #ifndef DUNE_LOCALFUNCTIONS_UTILITY_LFEMATRIX_HH