From: wolf Date: Mon, 9 Aug 1999 13:16:13 +0000 (+0000) Subject: Let the matrix subscribe to the sparsity pattern. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=490b7599b80557fdfd8b8d59ee65867a938c2066;p=dealii-svn.git Let the matrix subscribe to the sparsity pattern. git-svn-id: https://svn.dealii.org/trunk@1632 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/Todo b/deal.II/lac/Todo index 6f772a7479..73e47b6b5d 100644 --- a/deal.II/lac/Todo +++ b/deal.II/lac/Todo @@ -17,10 +17,6 @@ Let dSMatrixStruct::compress free the memory of colnums which is no longer needed. -Let dSMatrixStruct be derived from Subscriptor and let the dSMatrix - subscribe to that. The present behaviour is just about to dangerous. - - Use memcpy in dSMatrix::copy_from instead of elementwise copying. This should yield a significant speed-up. diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h index 3ebf0eca2f..a8c60cc9de 100644 --- a/deal.II/lac/include/lac/sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix.templates.h @@ -37,6 +37,8 @@ SparseMatrix::SparseMatrix (const SparseMatrix &m) : Assert (m.max_len==0, ExcInvalidConstructorCall()); }; + + template SparseMatrix& SparseMatrix::operator = (const SparseMatrix &m) @@ -47,7 +49,8 @@ SparseMatrix::operator = (const SparseMatrix &m) return *this; }; - + + template SparseMatrix::SparseMatrix (const SparseMatrixStruct &c) : @@ -55,6 +58,7 @@ SparseMatrix::SparseMatrix (const SparseMatrixStruct &c) : val(0), max_len(0) { + cols->subscribe (); reinit(); }; @@ -63,7 +67,11 @@ SparseMatrix::SparseMatrix (const SparseMatrixStruct &c) : template SparseMatrix::~SparseMatrix () { - delete[] val; + if (cols != 0) + cols->unsubscribe(); + + if (val != 0) + delete[] val; }; @@ -100,7 +108,12 @@ template void SparseMatrix::reinit (const SparseMatrixStruct &sparsity) { + if (cols != 0) + cols->unsubscribe(); + cols = &sparsity; + cols->subscribe(); + reinit (); };