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 ];
57 unsigned int rows ()
const
62 unsigned int cols ()
const
67 const Field *rowPtr (
const unsigned int row )
const
70 return &(matrix_[row][0]);
73 Field *rowPtr (
const unsigned int row )
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) );
108 if (
max == Zero<Field>())
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] );
118 Field hr = Unity<Field>()/(*this)(j,j);
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 >
151 inline std::ostream &operator<<(std::ostream &out,
const LFEMatrix<Field> &mat)
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));
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:484
Dune namespace.
Definition: alignedallocator.hh:13
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition: field.hh:159