]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Define bahviour of real() and imag() where PetscScalar is real.
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 18 Oct 2013 15:21:59 +0000 (15:21 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 18 Oct 2013 15:21:59 +0000 (15:21 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@31308 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 01490b52d2439fd2c8dcea0dad3d8ebe4a568fcb..2d0017be56805a14d6e538592ae067158db995b8 100644 (file)
@@ -169,6 +169,9 @@ namespace PETScWrappers
 
       /**
        * Return the imaginary part of the value of the referenced element.
+       *
+       * @note This operation is not defined for real numbers and an
+       * exception is thrown.
        */
       const PetscReal imag () const;
 
@@ -1178,7 +1181,11 @@ namespace PETScWrappers
       const PetscReal
       VectorReference::real () const
     {
+#ifndef PETSC_USE_COMPLEX
+      return static_cast<PetscScalar>(*this); 
+#else
       return PetscRealPart (static_cast<PetscScalar>(*this)); 
+#endif
     }
 
 
@@ -1187,7 +1194,12 @@ namespace PETScWrappers
       const PetscReal
       VectorReference::imag () const
     {
+#ifndef PETSC_USE_COMPLEX
+      // This is a no op if complex numbers are not defined.
+      AssertThrow (false, ExcNotImplemented ());
+#else
       return PetscImaginaryPart (static_cast<PetscScalar>(*this)); 
+#endif
     }
    
   } // namespace internal

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.