4 #ifndef DUNE_PDELAB_GRIDOPERATOR_COMMON_LOCALMATRIX_HH
5 #define DUNE_PDELAB_GRIDOPERATOR_COMMON_LOCALMATRIX_HH
7 #include <dune/common/iteratorfacades.hh>
76 template<
typename LFSU,
typename LFSV>
82 _container(lfsv,i,lfsu,j) += _weight * v;
90 template<
typename LFSU,
typename LFSV>
96 _container(lfsv,i,lfsu,j) += v;
102 return _container.nrows();
108 return _container.ncols();
147 return _container.base();
156 return _container.base();
174 template<
typename T,
typename W = T>
216 :
public Dune::BidirectionalIteratorFacade<iterator,value_type>
233 return _m == other.
_m &&
_i == other.
_i &&
_j == other.
_j;
243 if (_j < _m->
ncols() - 1)
309 _container.resize(r*c);
317 std::fill(_container.begin(),_container.end(),t);
324 _container.assign(r*c,t);
336 template<
typename LFSU,
typename LFSV>
339 return getEntry(lfsv.localIndex(i),lfsu.localIndex(j));
349 template<
typename LFSU,
typename LFSV>
352 return getEntry(lfsv.localIndex(i),lfsu.localIndex(j));
358 using namespace std::placeholders;
363 std::bind(std::multiplies<T>(),x,_1)
381 template<
class X,
class R>
382 void umv (
const X& x, R& y)
const
392 template<
class X,
class R>
437 return _container[j*_rows + i];
451 return _container[j*_rows + i];
456 std::vector<T> _container;
460 template<
class Stream,
class T,
class W>
462 for(
int r = 0; r < m.
nrows(); ++r) {
465 for(
int c = 1; c < m.
ncols(); ++c)
C & accessBaseContainer(C &c)
Definition: localvector.hh:368
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
std::ostream & operator<<(std::ostream &s, const TimeSpec &t)
insert a timespec into an output stream
Definition: clock.cc:39
An accumulate-only view on a local matrix that automatically takes into account an accumulation weigh...
Definition: localmatrix.hh:22
C Container
The type of the underlying container.
Definition: localmatrix.hh:27
WeightedAccumulationView weightedAccumulationView(weight_type weight)
Returns a WeighedAccumulationView with some weight in addition to this view's weight.
Definition: localmatrix.hh:47
C::value_type value_type
The value type of the entries.
Definition: localmatrix.hh:36
BaseContainer & base()
Returns the storage container of the underlying LocalMatrix.
Definition: localmatrix.hh:144
Container & container()
Returns the container (of type LocalMatrix) that this view is based on.
Definition: localmatrix.hh:128
size_type ncols() const
Returns the number of colums of the underlying container.
Definition: localmatrix.hh:106
WeightedMatrixAccumulationView WeightedAccumulationView
Export this type for uniform handling of the containers themselves and their views.
Definition: localmatrix.hh:43
const Container & container() const
Returns the container (of type LocalMatrix) that this view is based on (const version).
Definition: localmatrix.hh:135
void setWeight(weight_type weight)
Resets the weighting coefficient of the view.
Definition: localmatrix.hh:70
const BaseContainer & base() const
Returns the storage container of the underlying LocalVector (const version).
Definition: localmatrix.hh:154
WeightedMatrixAccumulationView(Container &container, weight_type weight)
Constructor.
Definition: localmatrix.hh:160
void resetModified()
Resets the modification state of the view to not modified.
Definition: localmatrix.hh:122
size_type nrows() const
Returns the number of rows of the underlying container.
Definition: localmatrix.hh:100
void rawAccumulate(const LFSV &lfsv, size_type i, const LFSU &lfsu, size_type j, value_type v)
Adds v to the (i,j)-th entry of the underlying container without applying the current weight.
Definition: localmatrix.hh:91
bool modified() const
Returns whether this view has been written to.
Definition: localmatrix.hh:112
weight_type weight() const
Returns the weight associated with this view.
Definition: localmatrix.hh:60
C::size_type size_type
The size_type of the underlying container.
Definition: localmatrix.hh:53
Container::BaseContainer BaseContainer
The type of the storage container underlying the LocalVector.
Definition: localmatrix.hh:33
C::weight_type weight_type
The type of the weight applied when accumulating contributions.
Definition: localmatrix.hh:39
void accumulate(const LFSV &lfsv, size_type i, const LFSU &lfsu, size_type j, value_type v)
Applies the current weight to v and adds the result to the matrix entry associated with the i-th entr...
Definition: localmatrix.hh:77
A dense matrix for storing data associated with the degrees of freedom of a pair of LocalFunctionSpac...
Definition: localmatrix.hh:184
iterator begin()
Definition: localmatrix.hh:279
const value_type & getEntry(size_type i, size_type j) const
Direct (unmapped) access to the (i,j)-th entry of the matrix (const version).
Definition: localmatrix.hh:449
LocalMatrix()
Default constructor.
Definition: localmatrix.hh:290
BaseContainer & base()
Returns the underlying storage container.
Definition: localmatrix.hh:412
W weight_type
The weight type of this container.
Definition: localmatrix.hh:210
const BaseContainer & base() const
Returns the underlying storage container (const version).
Definition: localmatrix.hh:421
LocalMatrix(size_type r, size_type c)
Construct a LocalMatrix with r rows and c columns.
Definition: localmatrix.hh:293
LocalMatrix(size_type r, size_type c, const T &t)
Construct a LocalMatrix with r rows and c columns and initialize its entries with t.
Definition: localmatrix.hh:300
iterator end()
Definition: localmatrix.hh:284
size_type nrows() const
Returns the number of rows.
Definition: localmatrix.hh:369
WeightedMatrixAccumulationView< LocalMatrix > WeightedAccumulationView
An accumulate-only view of this container that automatically applies a weight to all contributions.
Definition: localmatrix.hh:213
T & operator()(const LFSV &lfsv, size_type i, const LFSU &lfsu, size_type j)
Access the value associated with the i-th DOF of lfsv and the j-th DOF of lfsu.
Definition: localmatrix.hh:337
BaseContainer::reference reference
The reference type of this container.
Definition: localmatrix.hh:200
void resize(size_type r, size_type c)
Resize the matrix.
Definition: localmatrix.hh:307
BaseContainer::size_type size_type
The size type of this container.
Definition: localmatrix.hh:197
BaseContainer::value_type value_type
The value type of this container.
Definition: localmatrix.hh:194
value_type & getEntry(size_type i, size_type j)
Direct (unmapped) access to the (i,j)-th entry of the matrix.
Definition: localmatrix.hh:435
LocalMatrix & operator=(const T &t)
Assign t to all entries of the matrix.
Definition: localmatrix.hh:315
void assign(size_type r, size_type c, const T &t)
Resize the matrix and assign t to all entries.
Definition: localmatrix.hh:322
LocalMatrix & operator*=(const T &x)
Multiplies all entries of the matrix with x.
Definition: localmatrix.hh:356
void umv(const X &x, R &y) const
y += A x
Definition: localmatrix.hh:382
size_type ncols() const
Returns the number of columns.
Definition: localmatrix.hh:375
std::vector< T > BaseContainer
The type of the underlying storage container.
Definition: localmatrix.hh:191
void usmv(const value_type &alpha, const X &x, R &y) const
y += alpha A x
Definition: localmatrix.hh:393
WeightedAccumulationView weightedAccumulationView(weight_type weight)
Returns a weighted accumulate-only view of this matrix with the given weight.
Definition: localmatrix.hh:403
BaseContainer::const_reference const_reference
The const reference type of this container.
Definition: localmatrix.hh:203
Definition: localmatrix.hh:217
iterator()
Definition: localmatrix.hh:219
bool equals(const iterator &other) const
Definition: localmatrix.hh:231
size_type _i
Definition: localmatrix.hh:274
iterator(LocalMatrix &m, size_type i, size_type j)
Definition: localmatrix.hh:225
size_type row() const
Definition: localmatrix.hh:263
LocalMatrix * _m
Definition: localmatrix.hh:273
value_type & dereference() const
Definition: localmatrix.hh:236
void decrement()
Definition: localmatrix.hh:252
size_type _j
Definition: localmatrix.hh:275
void increment()
Definition: localmatrix.hh:241
size_type col() const
Definition: localmatrix.hh:268