]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix a strange problem with v(i)=w(i), see the petsc_vector_assign_01 test.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 6 Apr 2004 02:33:35 +0000 (02:33 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 6 Apr 2004 02:33:35 +0000 (02:33 +0000)
git-svn-id: https://svn.dealii.org/trunk@8978 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/petsc_vector_base.h

index 7d26ec27155c73ee293ce9649aacd5790e605aa9..ff4c1a1a366db05de4350fcf96e7a4834a80d9df 100644 (file)
@@ -74,6 +74,28 @@ namespace PETScWrappers
                          const unsigned int index);
         
       public:
+                                         /**
+                                          * This looks like a copy operator,
+                                          * but does something different than
+                                          * usual. In particular, it does not
+                                          * copy the member variables of this
+                                          * reference. Rather, it handles the
+                                          * situation where we have two
+                                          * vectors @p v and @p w, and assign
+                                          * elements like in
+                                          * <tt>v(i)=w(i)</tt>. Here, both
+                                          * left and right hand side of the
+                                          * assignment have data type
+                                          * VectorReference, but what we
+                                          * really mean is to assign the
+                                          * vector elements represented by the
+                                          * two references. This operator
+                                          * implements this operation. Note
+                                          * also that this allows us to make
+                                          * the assignment operator const.
+                                          */
+        const VectorReference & operator = (const VectorReference &r) const;
+        
                                          /**
                                           * Set the referenced element of the
                                           * vector to <tt>s</tt>.
@@ -87,8 +109,8 @@ namespace PETScWrappers
         const VectorReference & operator += (const PetscScalar &s) const;
 
                                          /**
-                                          * Subtract <tt>s</tt> from the referenced
-                                          * element of the vector.
+                                          * Subtract <tt>s</tt> from the
+                                          * referenced element of the vector.
                                           */
         const VectorReference & operator -= (const PetscScalar &s) const;
 
@@ -255,7 +277,8 @@ namespace PETScWrappers
       bool operator != (const VectorBase &v) const;
 
                                        /**
-                                        * Return the global dimension of the vector.
+                                        * Return the global dimension of the
+                                        * vector.
                                         */
       unsigned int size () const;
 
@@ -631,6 +654,21 @@ namespace PETScWrappers
     {}
 
 
+    inline
+    const VectorReference &
+    VectorReference::operator = (const VectorReference &r) const
+    {
+                                       // as explained in the class
+                                       // documentation, this is not the copy
+                                       // operator. so simply pass on to the
+                                       // "correct" assignment operator
+      *this = static_cast<PetscScalar> (r);
+
+      return *this;
+    }
+
+
+    
     inline
     const VectorReference &
     VectorReference::operator = (const PetscScalar &value) const

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.