From 3b3a205fb67dd4bb94da6ee8a3be2ba8f689d940 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 18 Mar 1998 14:41:31 +0000 Subject: [PATCH] Perform bounds checking in dSMatrix git-svn-id: https://svn.dealii.org/trunk@76 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/dsmatrix.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/deal.II/lac/include/lac/dsmatrix.h b/deal.II/lac/include/lac/dsmatrix.h index 1c880274af..621f13044b 100644 --- a/deal.II/lac/include/lac/dsmatrix.h +++ b/deal.II/lac/include/lac/dsmatrix.h @@ -150,9 +150,17 @@ class dSMatrix int n() const { return cols->cols; } // - void set(int i,int j,double value) { val[cols->operator()(i,j)] = value; } + void set(int i,int j,double value) { + Assert (cols->operator()(i,j) != -1, + ExcInvalidIndex(i,j)); + val[cols->operator()(i,j)] = value; + } // - void add(int i,int j,double value) { val[cols->operator()(i,j)]+= value; } + void add(int i,int j,double value) { + Assert (cols->operator()(i,j) != -1, + ExcInvalidIndex(i,j)); + val[cols->operator()(i,j)]+= value; + } // void vmult (dVector& dst,const dVector& src) const; @@ -193,6 +201,14 @@ class dSMatrix int, int, << "The dimensions " << arg1 << " and " << arg2 << " do not match properly."); - friend class ConstraintMatrix; + /** + * Exception + */ + DeclException2 (ExcInvalidIndex, + int, int, + << "The entry with index <" << arg1 << ',' << arg2 + << "> does not exist."); + + friend class ConstraintMatrix; }; #endif -- 2.39.5