5#ifndef DUNE_LOCALFUNCTIONS_UTILITY_LFEMATRIX_HH
6#define DUNE_LOCALFUNCTIONS_UTILITY_LFEMATRIX_HH
17 class [[deprecated(
"The usage of LFEMatrix is discouraged. Use DynamicMatrix instead")]]
LFEMatrix
19 typedef std::vector< F > Row;
20 typedef std::vector<Row> RealMatrix;
25 operator const RealMatrix & ()
const
30 operator RealMatrix & ()
35 template <
class Vector>
36 void row(
const unsigned int row, Vector &vec )
const
39 for (
int i=0; i<cols(); ++i)
43 const Field &operator() (
const unsigned int row,
const unsigned int col )
const
47 return matrix_[ row ][ col ];
50 Field &operator() (
const unsigned int row,
const unsigned int col )
54 return matrix_[ row ][ col ];
70 return &(matrix_[row][0]);
76 return &(matrix_[row][0]);
79 void resize (
const unsigned int rows,
const unsigned int cols )
82 for (
unsigned int i=0; i<rows; ++i)
83 matrix_[i].resize(cols);
91 assert( rows() == cols() );
92 std::vector<unsigned int> p(rows());
93 for (
unsigned int j=0; j<rows(); ++j)
95 for (
unsigned int j=0; j<rows(); ++j)
99 Field max = abs( (*
this)(j,j) );
100 for (
unsigned int i=j+1; i<rows(); ++i)
102 if ( abs( (*
this)(i,j) ) > max )
104 max = abs( (*
this)(i,j) );
113 for (
unsigned int k=0; k<cols(); ++k)
114 std::swap( (*
this)(j,k), (*
this)(r,k) );
115 std::swap( p[j], p[r] );
119 for (
unsigned int i=0; i<rows(); ++i)
122 for (
unsigned int k=0; k<cols(); ++k)
125 for (
unsigned int i=0; i<rows(); ++i)
128 (*this)(i,k) -= (*
this)(i,j)*(*
this)(j,k);
135 for (
unsigned int i=0; i<rows(); ++i)
137 for (
unsigned int k=0; k<rows(); ++k)
138 hv[ p[k] ] = (*
this)(i,k);
139 for (
unsigned int k=0; k<rows(); ++k)
140 (*
this)(i,k) = hv[k];
147 unsigned int cols_,rows_;
150 template<
class Field >
153 for (
unsigned int r=0; r<mat.
rows(); ++r)
155 out << field_cast<double>(mat(r,0));
156 for (
unsigned int c=1; c<mat.
cols(); ++c)
158 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:151
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:73
unsigned int cols() const
Definition lfematrix.hh:62
const Field * rowPtr(const unsigned int row) const
Definition lfematrix.hh:67
void resize(const unsigned int rows, const unsigned int cols)
Definition lfematrix.hh:79
void row(const unsigned int row, Vector &vec) const
Definition lfematrix.hh:36
unsigned int rows() const
Definition lfematrix.hh:57
bool invert()
Definition lfematrix.hh:88
F Field
Definition lfematrix.hh:23