]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
modified /= function.
authorbrian <brian@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 2 Jun 2003 15:57:02 +0000 (15:57 +0000)
committerbrian <brian@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 2 Jun 2003 15:57:02 +0000 (15:57 +0000)
git-svn-id: https://svn.dealii.org/trunk@7723 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_sparse_matrix.h
deal.II/lac/include/lac/sparse_matrix.h

index 7bb1230478a27547925878ac0e8f3069236ba477..7163f8c6229a1701d0c6ae64671a1f925cfd5c3a 100644 (file)
@@ -689,11 +689,17 @@ class BlockSparseMatrix : public Subscriptor
                                      * Exception
                                      */
     DeclException0 (ExcMatrixNotBlockSquare);
+
                                     /**
                                      * Exception
                                      */
     DeclException0 (ExcMatrixNotInitialized);
 
+                                    /**
+                                     * Exception
+                                     */
+    DeclException0 (ExcDivideByZero);
+
     
   private:
                                     /**
@@ -1073,10 +1079,13 @@ BlockSparseMatrix<number>::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<rows; ++r)
     for (unsigned int c=0; c<columns; ++c)
-      block(r,c) /= factor;
+      block(r,c) *= factor_inv;
 
   return *this;
 }
index 8cfea37b486ffcd998e75a7ccc53916cc7fa96d8..29a393e5571fb981fcca705df87739e51646d88b 100644 (file)
@@ -1083,6 +1083,10 @@ class SparseMatrix : public virtual Subscriptor
                                     /**
                                      * Exception
                                      */
+    DeclException0 (ExcDivideByZero);
+                                    /**
+                                     * Exception
+                                     */
     DeclException2 (ExcIteratorRange,
                    int, int,
                    << "The iterators denote a range of " << arg1
@@ -1290,12 +1294,15 @@ SparseMatrix<number>::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;
 }

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.