Skip to content
Snippets Groups Projects
Commit 37effa1f authored by Markus Blatt's avatar Markus Blatt
Browse files

Added operator+=() and operator-=() for convenience.

[[Imported from SVN: r423]]
parent 0452484a
Branches
Tags
No related merge requests found
......@@ -991,6 +991,45 @@ namespace Dune {
}
/*! \brief Add the entries of another matrix to this one.
*
* \param b The matrix to add to this one. Its sparsity pattern
* has to be subset of the sparsity pattern of this matrix.
*/
BCRSMatrix& operator+= (const BCRSMatrix& b)
{
#ifdef DUNE_ISTL_WITH_CHECKING
if(N()!=b.N() || M() != b.M())
DUNE_THROW(RangeError, "Matrix sizes do not match!");
#endif
RowIterator endi=end();
ConstRowIterator j=b.begin();
for (RowIterator i=begin(); i!=endi; ++i, ++j) {
i->operator+=(*j);
}
return *this;
}
/*! \brief Substract the entries of another matrix to this one.
*
* \param b The matrix to add to this one. Its sparsity pattern
* has to be subset of the sparsity pattern of this matrix.
*/
BCRSMatrix& operator-= (const BCRSMatrix& b)
{
#ifdef DUNE_ISTL_WITH_CHECKING
if(N()!=b.N() || M() != b.M())
DUNE_THROW(RangeError, "Matrix sizes do not match!");
#endif
RowIterator endi=end();
ConstRowIterator j=b.begin();
for (RowIterator i=begin(); i!=endi; ++i, ++j) {
i->operator-=(*j);
}
return *this;
}
//===== linear maps
//! y += A x
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment