From: young Date: Fri, 18 Oct 2013 15:05:52 +0000 (+0000) Subject: Add std conforming real() and imag() [no more casting on vector elements]. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=235d7df8e14e2b576a24054ea8ffc38b7e1bd6bb;p=dealii-svn.git Add std conforming real() and imag() [no more casting on vector elements]. git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@31304 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 daff61845a..01490b52d2 100644 --- a/deal.II/include/deal.II/lac/petsc_vector_base.h +++ b/deal.II/include/deal.II/lac/petsc_vector_base.h @@ -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(*this)); + } + + + + inline + const PetscReal + VectorReference::imag () const + { + return PetscImaginaryPart (static_cast(*this)); + } + + } // namespace internal + inline bool VectorBase::in_local_range (const size_type index) const