From: young Date: Fri, 18 Oct 2013 15:21:59 +0000 (+0000) Subject: Define bahviour of real() and imag() where PetscScalar is real. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=353b7ad9431fca689f665be5bdbdc6dad1a894d6;p=dealii-svn.git Define bahviour of real() and imag() where PetscScalar is real. git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@31308 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/lac/petsc_vector_base.h b/deal.II/include/deal.II/lac/petsc_vector_base.h index 01490b52d2..2d0017be56 100644 --- a/deal.II/include/deal.II/lac/petsc_vector_base.h +++ b/deal.II/include/deal.II/lac/petsc_vector_base.h @@ -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(*this); +#else return PetscRealPart (static_cast(*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(*this)); +#endif } } // namespace internal