Skip to content
Snippets Groups Projects
Commit 3285e2d3 authored by Oliver Sander's avatar Oliver Sander
Browse files

Implement method 'setSize' for BDMatrix

parent 060707dc
No related branches found
No related tags found
1 merge request!110Implement the method 'setSize' for BDMatrix and BTDMatrix
Pipeline #
......@@ -74,6 +74,24 @@ namespace Dune {
(*this)[i][i] = *it;
}
/** \brief Resize the matrix. Invalidates the content! */
void setSize(size_type size)
{
this->BCRSMatrix<B,A>::setSize(size, // rows
size, // columns
size); // nonzeros
for (int i=0; i<size; i++)
this->BCRSMatrix<B,A>::setrowsize(i, 1);
this->BCRSMatrix<B,A>::endrowsizes();
for (int i=0; i<size; i++)
this->BCRSMatrix<B,A>::addindex(i, i);
this->BCRSMatrix<B,A>::endindices();
}
//! assignment
BDMatrix& operator= (const BDMatrix& other) {
this->BCRSMatrix<B,A>::operator=(other);
......
......@@ -389,6 +389,11 @@ int main()
BDMatrix<FieldMatrix<double,2,2> > bdMatrix2 = { {{1,0},{0,1}}, {{0,1},{-1,0}}};
testSuperMatrix(bdMatrix2);
// test whether resizing works
bdMatrix2.setSize(5);
bdMatrix2 = 4.0;
testSuperMatrix(bdMatrix);
// ////////////////////////////////////////////////////////////////////////
// Test the BTDMatrix class -- a dynamic block-tridiagonal matrix
// a) the scalar case
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment