3#ifndef DUNE_LOCALFUNCTIONS_UTILITY_LFEMATRIX_HH
4#define DUNE_LOCALFUNCTIONS_UTILITY_LFEMATRIX_HH
18 typedef std::vector< F > Row;
19 typedef std::vector<Row> RealMatrix;
24 operator const RealMatrix & ()
const
29 operator RealMatrix & ()
34 template <
class Vector>
35 void row(
const unsigned int row, Vector &vec )
const
38 for (
int i=0; i<
cols(); ++i)
46 return matrix_[
row ][ col ];
53 return matrix_[
row ][ col ];
69 return &(matrix_[
row][0]);
75 return &(matrix_[
row][0]);
81 for (
unsigned int i=0; i<
rows; ++i)
91 std::vector<unsigned int> p(
rows());
92 for (
unsigned int j=0; j<
rows(); ++j)
94 for (
unsigned int j=0; j<
rows(); ++j)
98 Field max = abs( (*
this)(j,j) );
99 for (
unsigned int i=j+1; i<
rows(); ++i)
101 if ( abs( (*
this)(i,j) ) > max )
103 max = abs( (*
this)(i,j) );
112 for (
unsigned int k=0; k<
cols(); ++k)
113 std::swap( (*
this)(j,k), (*
this)(r,k) );
114 std::swap( p[j], p[r] );
118 for (
unsigned int i=0; i<
rows(); ++i)
121 for (
unsigned int k=0; k<
cols(); ++k)
124 for (
unsigned int i=0; i<
rows(); ++i)
127 (*this)(i,k) -= (*
this)(i,j)*(*
this)(j,k);
134 for (
unsigned int i=0; i<
rows(); ++i)
136 for (
unsigned int k=0; k<
rows(); ++k)
137 hv[ p[k] ] = (*
this)(i,k);
138 for (
unsigned int k=0; k<
rows(); ++k)
139 (*
this)(i,k) = hv[k];
146 unsigned int cols_,rows_;
149 template<
class Field >
152 for (
unsigned int r=0; r<mat.
rows(); ++r)
154 out << field_cast<double>(mat(r,0));
155 for (
unsigned int c=1; c<mat.
cols(); ++c)
157 out <<
" , " << field_cast<double>(mat(r,c));
Definition: bdfmcube.hh:16
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition: field.hh:157
std::ostream & operator<<(std::ostream &out, const LFEMatrix< Field > &mat)
Definition: lfematrix.hh:150
A class representing the unit of a given Field.
Definition: field.hh:28
A class representing the zero of a given Field.
Definition: field.hh:77
Definition: lfematrix.hh:16
Field * rowPtr(const unsigned int row)
Definition: lfematrix.hh:72
unsigned int cols() const
Definition: lfematrix.hh:61
const Field * rowPtr(const unsigned int row) const
Definition: lfematrix.hh:66
void resize(const unsigned int rows, const unsigned int cols)
Definition: lfematrix.hh:78
const Field & operator()(const unsigned int row, const unsigned int col) const
Definition: lfematrix.hh:42
void row(const unsigned int row, Vector &vec) const
Definition: lfematrix.hh:35
unsigned int rows() const
Definition: lfematrix.hh:56
bool invert()
Definition: lfematrix.hh:87
F Field
Definition: lfematrix.hh:22