]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add std conforming real() and imag() [no more casting on vector elements].
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 18 Oct 2013 15:05:52 +0000 (15:05 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 18 Oct 2013 15:05:52 +0000 (15:05 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@31304 0785d39b-7218-0410-832d-ea1e28bc413d

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

index daff61845a0e5ea5f57d26e407ff9294de54ab99..01490b52d2439fd2c8dcea0dad3d8ebe4a568fcb 100644 (file)
@@ -162,6 +162,16 @@ namespace PETScWrappers
        */
       const VectorReference &operator /= (const PetscScalar &s) const;
 
+      /**
+       * Return the real part of the value of the referenced element.
+       */
+      const PetscReal real () const;
+
+      /**
+       * Return the imaginary part of the value of the referenced element.
+       */
+      const PetscReal imag () const;
+
       /**
        * Convert the reference to an actual
        * value, i.e. return the value of
@@ -961,6 +971,7 @@ namespace PETScWrappers
     {}
 
 
+
     inline
     const VectorReference &
     VectorReference::operator = (const VectorReference &r) const
@@ -1160,10 +1171,27 @@ namespace PETScWrappers
 
       return *this;
     }
-  }
 
 
 
+    inline
+      const PetscReal
+      VectorReference::real () const
+    {
+      return PetscRealPart (static_cast<PetscScalar>(*this)); 
+    }
+
+
+
+    inline
+      const PetscReal
+      VectorReference::imag () const
+    {
+      return PetscImaginaryPart (static_cast<PetscScalar>(*this)); 
+    }
+   
+  } // namespace internal
+
   inline
   bool
   VectorBase::in_local_range (const size_type index) 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.