From ef5a0285d9bb097e120d52e8affb68b8a37048c9 Mon Sep 17 00:00:00 2001 From: brian Date: Mon, 2 Jun 2003 15:57:02 +0000 Subject: [PATCH] modified /= function. git-svn-id: https://svn.dealii.org/trunk@7723 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/block_sparse_matrix.h | 11 ++++++++++- deal.II/lac/include/lac/sparse_matrix.h | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/deal.II/lac/include/lac/block_sparse_matrix.h b/deal.II/lac/include/lac/block_sparse_matrix.h index 7bb1230478..7163f8c622 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix.h +++ b/deal.II/lac/include/lac/block_sparse_matrix.h @@ -689,11 +689,17 @@ class BlockSparseMatrix : public Subscriptor * Exception */ DeclException0 (ExcMatrixNotBlockSquare); + /** * Exception */ DeclException0 (ExcMatrixNotInitialized); + /** + * Exception + */ + DeclException0 (ExcDivideByZero); + private: /** @@ -1073,10 +1079,13 @@ BlockSparseMatrix::operator /= (const number factor) { Assert (columns != 0, ExcMatrixNotInitialized()); Assert (rows != 0, ExcMatrixNotInitialized()); + Assert (factor !=0, ExcDivideByZero()); + + const number factor_inv = 1. / factor; for (unsigned int r=0; r::operator /= (const number factor) { Assert (cols != 0, ExcMatrixNotInitialized()); Assert (val != 0, ExcMatrixNotInitialized()); + Assert (factor !=0, ExcDivideByZero()); + + const number factor_inv = 1. / factor; number *val_ptr = &val[0]; const number *const end_ptr = &val[cols->n_nonzero_elements()]; while (val_ptr != end_ptr) - *val_ptr++ /= factor; + *val_ptr++ *= factor_inv; return *this; } -- 2.39.5