5#ifndef DUNE_BASISMATRIX_HH
6#define DUNE_BASISMATRIX_HH
12#include <dune/localfunctions/utility/monomialbasis.hh>
13#include <dune/localfunctions/utility/polynomialbasis.hh>
25 template<
class PreBasis,
class Interpolation,
29 template<
class PreBasis,
class Interpolation,
31 struct BasisMatrixBase :
public DynamicMatrix<Field>
33 typedef DynamicMatrix<Field> Matrix;
35 BasisMatrixBase(
const PreBasis& preBasis,
36 const Interpolation& localInterpolation )
37 : cols_(preBasis.
size())
39 localInterpolation.interpolate( preBasis, *
this );
42 unsigned int cols ()
const
46 unsigned int rows ()
const
57 struct BasisMatrix< const MonomialBasis< geometryId, F >, Interpolation, Field >
58 :
public BasisMatrixBase< const MonomialBasis< geometryId, F >, Interpolation, Field >
60 typedef const MonomialBasis< geometryId, F > PreBasis;
61 typedef BasisMatrixBase<PreBasis,Interpolation,Field> Base;
62 typedef typename Base::Matrix Matrix;
64 BasisMatrix(
const PreBasis& preBasis,
65 const Interpolation& localInterpolation )
66 : Base(preBasis, localInterpolation)
68 template <
class Vector>
69 void row(
const unsigned int row, Vector &vec )
const
71 const unsigned int N = Matrix::rows();
72 assert( Matrix::cols() == N && vec.size() == N );
75 for (
unsigned int i=0; i<N; ++i)
79 template<
int dim,
class F,
82 struct BasisMatrix< const
Dune::VirtualMonomialBasis< dim, F >, Interpolation, Field >
83 :
public BasisMatrixBase< const VirtualMonomialBasis< dim, F >, Interpolation, Field >
85 typedef const VirtualMonomialBasis< dim, F > PreBasis;
86 typedef BasisMatrixBase<PreBasis,Interpolation,Field> Base;
87 typedef typename Base::Matrix Matrix;
89 BasisMatrix(
const PreBasis& preBasis,
90 const Interpolation& localInterpolation )
91 : Base(preBasis, localInterpolation)
93 template <
class Vector>
94 void row(
const unsigned int row, Vector &vec )
const
96 const unsigned int N = Matrix::rows();
97 assert( Matrix::cols() == N && vec.size() == N );
100 for (
unsigned int i=0; i<N; ++i)
104 template<
class Eval,
class CM,
class D,
class R,
107 struct BasisMatrix< const PolynomialBasis<Eval,CM,D,R>, Interpolation, Field >
108 :
public BasisMatrixBase< const PolynomialBasis<Eval,CM,D,R>, Interpolation, Field >
110 typedef const PolynomialBasis<Eval,CM,D,R> PreBasis;
111 typedef BasisMatrixBase<PreBasis,Interpolation,Field> Base;
112 typedef typename Base::Matrix Matrix;
114 BasisMatrix(
const PreBasis& preBasis,
115 const Interpolation& localInterpolation )
116 : Base(preBasis, localInterpolation),
119 unsigned int cols()
const
121 return preBasis_.matrix().baseSize() ;
123 template <
class Vector>
124 void row(
const unsigned int row, Vector &vec )
const
126 assert( Matrix::rows() == Matrix::cols() );
127 assert( vec.size() == preBasis_.matrix().baseSize() );
128 assert( Matrix::cols() == preBasis_.size() );
129 for (
unsigned int j=0; j<Matrix::cols(); ++j)
131 for (
unsigned int i=0; i<Matrix::rows(); ++i)
133 addRow(i,(*
this)[i][row],vec);
136 const PreBasis& preBasis_;
138 template<
class Eval,
class CM,
141 struct BasisMatrix< const PolynomialBasisWithMatrix<Eval,CM>, Interpolation, Field >
142 :
public BasisMatrixBase< const PolynomialBasisWithMatrix<Eval,CM>, Interpolation, Field >
144 typedef const PolynomialBasisWithMatrix<Eval,CM> PreBasis;
145 typedef BasisMatrixBase<PreBasis,Interpolation,Field> Base;
146 typedef typename Base::Matrix Matrix;
148 BasisMatrix(
const PreBasis& preBasis,
149 const Interpolation& localInterpolation )
150 : Base(preBasis, localInterpolation),
153 unsigned int cols()
const
155 return preBasis_.matrix().baseSize() ;
157 unsigned int rows ()
const
159 assert( Matrix::rows() == preBasis_.matrix().size() );
160 return preBasis_.matrix().size()*CM::blockSize ;
162 template <
class Vector>
163 void row(
const unsigned int row, Vector &vec )
const
165 unsigned int r = row / CM::blockSize;
166 assert( r < Matrix::rows() );
167 assert( Matrix::rows() == Matrix::cols() );
168 assert( vec.size() == preBasis_.matrix().baseSize() );
169 assert( Matrix::cols() == preBasis_.size() );
170 for (
unsigned int j=0; j<vec.size(); ++j)
172 for (
unsigned int i=0; i<Matrix::rows(); ++i)
174 addRow(i*CM::blockSize+row%CM::blockSize,(*
this)[i][r],vec);
177 const PreBasis& preBasis_;
void invert(bool doPivoting=true)
Compute inverse.
constexpr size_type rows() const
number of rows
Definition: densematrix.hh:709
IdType Id
An integral id representing a GeometryType.
Definition: type.hh:181
A few common exception classes.
This file implements a dense matrix with dynamic numbers of rows and columns.
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
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75