]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Perform bounds checking in dSMatrix
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 18 Mar 1998 14:41:31 +0000 (14:41 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 18 Mar 1998 14:41:31 +0000 (14:41 +0000)
git-svn-id: https://svn.dealii.org/trunk@76 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/dsmatrix.h

index 1c880274af0d46f963c7fdad93ffd89d8c2c3417..621f13044b77153a95b33bad9f698574eb3b0204 100644 (file)
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.