]> https://gitweb.dealii.org/ - dealii.git/commitdiff
multiplications improved
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Wed, 27 Jun 2001 17:24:07 +0000 (17:24 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Wed, 27 Jun 2001 17:24:07 +0000 (17:24 +0000)
git-svn-id: https://svn.dealii.org/trunk@4767 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/shifted_matrix.h

index 57849269c9451c3d7ecea9eabd85c954f9d46c21..96c40372b56b4345b4cd107d58a6fe36b64121ac 100644 (file)
@@ -62,6 +62,10 @@ class ShiftedMatrix
                                      */
     SmartPointer<const MATRIX> A;
 
+                                    /**
+                                     * Auxiliary vector.
+                                     */
+    VECTOR aux;
                                     /**
                                      * Shift parameter.
                                      */
@@ -165,7 +169,8 @@ inline void
 ShiftedMatrix<MATRIX>::vmult (VECTOR& dst, const VECTOR& src) const
 {
   A.vmult(dst, src);
-  dst.add(sigma, src);
+  if (sigma != 0.)
+    dst.add(sigma, src);
 }
 
 
@@ -177,7 +182,8 @@ ShiftedMatrix<MATRIX>::residual (VECTOR& dst,
                                 const VECTOR& rhs) const
 {
   A.vmult(dst, src);
-  dst.add(sigma, src);
+  if (sigma != 0.)
+    dst.add(sigma, src);
   dst.sadd(-1.,1.,rhs);
   return dst.l2_norm ();
 }
@@ -221,7 +227,12 @@ ShiftedMatrixGeneralized<MATRIX, MASSMATRIX>::vmult (VECTOR& dst,
                                                     const VECTOR& src) const
 {
   A.vmult(dst, src);
-  dst.add(sigma, src);
+  if (sigma != 0.)
+    {
+      aux.reinit(dst);
+      M.vmult(aux, src);
+      dst.add(sigma, aux);
+    }
 }
 
 
@@ -233,7 +244,12 @@ ShiftedMatrixGeneralized<MATRIX, MASSMATRIX>::residual (VECTOR& dst,
                                                        const VECTOR& rhs) const
 {
   A.vmult(dst, src);
-  dst.add(sigma, src);
+  if (sigma != 0.)
+    {
+      aux.reinit(dst);
+      M.vmult(aux, src);
+      dst.add(sigma, aux);
+    }
   dst.sadd(-1.,1.,rhs);
   return dst.l2_norm ();
 }

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.