From 353b7ad9431fca689f665be5bdbdc6dad1a894d6 Mon Sep 17 00:00:00 2001 From: young Date: Fri, 18 Oct 2013 15:21:59 +0000 Subject: [PATCH] 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 --- deal.II/include/deal.II/lac/petsc_vector_base.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 -- 2.39.5