Go to the documentation of this file.
4 #ifndef DUNE_PDELAB_GRIDOPERATOR_COMMON_LOCALMATRIX_HH
5 #define DUNE_PDELAB_GRIDOPERATOR_COMMON_LOCALMATRIX_HH
7 #include <dune/common/iteratorfacades.hh>
77 template<
typename LFSU,
typename LFSV>
83 _container(lfsv,i,lfsu,j) += _weight * v;
91 template<
typename LFSU,
typename LFSV>
97 _container(lfsv,i,lfsu,j) += v;
103 return _container.nrows();
109 return _container.ncols();
148 return _container.base();
157 return _container.base();
175 template<
typename T,
typename W = T>
217 :
public Dune::BidirectionalIteratorFacade<iterator,value_type>
234 return _m == other.
_m &&
_i == other.
_i &&
_j == other.
_j;
244 if (_j < _m->
ncols() - 1)
282 return iterator(*
this,0,0);
287 return iterator(*
this,
nrows(),0);
310 _container.resize(r*c);
318 std::fill(_container.begin(),_container.end(),t);
325 _container.assign(r*c,t);
337 template<
typename LFSU,
typename LFSV>
340 return getEntry(lfsv.localIndex(i),lfsu.localIndex(j));
350 template<
typename LFSU,
typename LFSV>
353 return getEntry(lfsv.localIndex(i),lfsu.localIndex(j));
359 using namespace std::placeholders;
364 std::bind(std::multiplies<T>(),x,_1)
382 template<
class X,
class R>
383 void umv (
const X& x, R& y)
const
393 template<
class X,
class R>
438 return _container[j*_rows + i];
452 return _container[j*_rows + i];
457 std::vector<T> _container;
461 template<
class Stream,
class T,
class W>
463 for(
int r = 0; r < m.
nrows(); ++r) {
466 for(
int c = 1; c < m.
ncols(); ++c)
480 #endif // DUNE_PDELAB_GRIDOPERATOR_COMMON_LOCALMATRIX_HH
const BaseContainer & base() const
Returns the underlying storage container (const version).
Definition: localmatrix.hh:422
void resetModified()
Resets the modification state of the view to not modified.
Definition: localmatrix.hh:123
iterator begin()
Definition: localmatrix.hh:280
C::weight_type weight_type
The type of the weight applied when accumulating contributions.
Definition: localmatrix.hh:39
std::vector< T > BaseContainer
The type of the underlying storage container.
Definition: localmatrix.hh:192
size_type ncols() const
Returns the number of columns.
Definition: localmatrix.hh:376
const Container & container() const
Returns the container (of type LocalMatrix) that this view is based on (const version).
Definition: localmatrix.hh:136
size_type nrows() const
Returns the number of rows.
Definition: localmatrix.hh:370
size_type col() const
Definition: localmatrix.hh:269
Definition: localmatrix.hh:216
WeightedMatrixAccumulationView WeightedAccumulationView
Export this type for uniform handling of the containers themselves and their views.
Definition: localmatrix.hh:43
WeightedMatrixAccumulationView< LocalMatrix > WeightedAccumulationView
An accumulate-only view of this container that automatically applies a weight to all contributions.
Definition: localmatrix.hh:214
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
W weight_type
The weight type of this container.
Definition: localmatrix.hh:211
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:78
void setWeight(weight_type weight)
Resets the weighting coefficient of the view.
Definition: localmatrix.hh:71
void increment()
Definition: localmatrix.hh:242
void resize(size_type r, size_type c)
Resize the matrix.
Definition: localmatrix.hh:308
BaseContainer::size_type size_type
The size type of this container.
Definition: localmatrix.hh:198
BaseContainer::const_reference const_reference
The const reference type of this container.
Definition: localmatrix.hh:204
iterator(LocalMatrix &m, size_type i, size_type j)
Definition: localmatrix.hh:226
BaseContainer::value_type value_type
The value type of this container.
Definition: localmatrix.hh:195
void decrement()
Definition: localmatrix.hh:253
C::size_type size_type
The size_type of the underlying container.
Definition: localmatrix.hh:53
size_type row() const
Definition: localmatrix.hh:264
LocalMatrix()
Default constructor.
Definition: localmatrix.hh:291
size_type ncols() const
Returns the number of colums of the underlying container.
Definition: localmatrix.hh:107
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:338
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:450
const BaseContainer & base() const
Returns the storage container of the underlying LocalVector (const version).
Definition: localmatrix.hh:155
WeightedAccumulationView weightedAccumulationView(weight_type weight)
Returns a weighted accumulate-only view of this matrix with the given weight.
Definition: localmatrix.hh:404
C::value_type value_type
The value type of the entries.
Definition: localmatrix.hh:36
LocalMatrix * _m
Definition: localmatrix.hh:274
size_type _i
Definition: localmatrix.hh:275
BaseContainer & base()
Returns the storage container of the underlying LocalMatrix.
Definition: localmatrix.hh:145
void assign(size_type r, size_type c, const T &t)
Resize the matrix and assign t to all entries.
Definition: localmatrix.hh:323
size_type nrows() const
Returns the number of rows of the underlying container.
Definition: localmatrix.hh:101
A dense matrix for storing data associated with the degrees of freedom of a pair of LocalFunctionSpac...
Definition: localmatrix.hh:184
LocalMatrix(size_type r, size_type c)
Construct a LocalMatrix with r rows and c columns.
Definition: localmatrix.hh:294
Container & container()
Returns the container (of type LocalMatrix) that this view is based on.
Definition: localmatrix.hh:129
iterator()
Definition: localmatrix.hh:220
BaseContainer & base()
Returns the underlying storage container.
Definition: localmatrix.hh:413
C Container
The type of the underlying container.
Definition: localmatrix.hh:27
weight_type weight()
Returns the weight associated with this view.
Definition: localmatrix.hh:60
iterator end()
Definition: localmatrix.hh:285
std::ostream & operator<<(std::ostream &s, const TimeSpec &t)
insert a timespec into an output stream
Definition: clock.cc:39
size_type _j
Definition: localmatrix.hh:276
bool modified() const
Returns whether this view has been written to.
Definition: localmatrix.hh:113
C & accessBaseContainer(C &c)
Definition: localvector.hh:302
Container::BaseContainer BaseContainer
The type of the storage container underlying the LocalVector.
Definition: localmatrix.hh:33
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:301
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:92
An accumulate-only view on a local matrix that automatically takes into account an accumulation weigh...
Definition: localmatrix.hh:21
WeightedMatrixAccumulationView(Container &container, weight_type weight)
Constructor.
Definition: localmatrix.hh:161
WeightedAccumulationView weightedAccumulationView(weight_type weight)
Returns a WeighedAccumulationView with some weight in addition to this view's weight.
Definition: localmatrix.hh:47
void umv(const X &x, R &y) const
y += A x
Definition: localmatrix.hh:383
bool equals(const iterator &other) const
Definition: localmatrix.hh:232
LocalMatrix & operator=(const T &t)
Assign t to all entries of the matrix.
Definition: localmatrix.hh:316
void usmv(const value_type &alpha, const X &x, R &y) const
y += alpha A x
Definition: localmatrix.hh:394
LocalMatrix & operator*=(const T &x)
Multiplies all entries of the matrix with x.
Definition: localmatrix.hh:357
value_type & getEntry(size_type i, size_type j)
Direct (unmapped) access to the (i,j)-th entry of the matrix.
Definition: localmatrix.hh:436
value_type & dereference() const
Definition: localmatrix.hh:237
BaseContainer::reference reference
The reference type of this container.
Definition: localmatrix.hh:201