5#ifndef DUNE_LOCALFUNCTIONS_UTILITY_LFEMATRIX_HH
6#define DUNE_LOCALFUNCTIONS_UTILITY_LFEMATRIX_HH
20 typedef std::vector< F > Row;
21 typedef std::vector<Row> RealMatrix;
26 operator const RealMatrix & ()
const
31 operator RealMatrix & ()
36 template <
class Vector>
37 void row(
const unsigned int row, Vector &vec )
const
40 for (
int i=0; i<
cols(); ++i)
48 return matrix_[
row ][ col ];
55 return matrix_[
row ][ col ];
71 return &(matrix_[
row][0]);
77 return &(matrix_[
row][0]);
83 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 = abs( (*
this)(j,j) );
101 for (
unsigned int i=j+1; i<
rows(); ++i)
103 if ( abs( (*
this)(i,j) ) > max )
105 max = 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 >
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)
159 out <<
" , " << field_cast<double>(mat(r,c));
Definition bdfmcube.hh:18
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition field.hh:159
std::ostream & operator<<(std::ostream &out, const LFEMatrix< Field > &mat)
Definition lfematrix.hh:152
A class representing the unit of a given Field.
Definition field.hh:30
A class representing the zero of a given Field.
Definition field.hh:79
Definition lfematrix.hh:18
Field * rowPtr(const unsigned int row)
Definition lfematrix.hh:74
unsigned int cols() const
Definition lfematrix.hh:63
const Field * rowPtr(const unsigned int row) const
Definition lfematrix.hh:68
void resize(const unsigned int rows, const unsigned int cols)
Definition lfematrix.hh:80
const Field & operator()(const unsigned int row, const unsigned int col) const
Definition lfematrix.hh:44
void row(const unsigned int row, Vector &vec) const
Definition lfematrix.hh:37
unsigned int rows() const
Definition lfematrix.hh:58
bool invert()
Definition lfematrix.hh:89
F Field
Definition lfematrix.hh:24