From 8b43dbd9ad408fa4a17e02b6e5e1e400796b64d4 Mon Sep 17 00:00:00 2001 From: "denis.davydov" Date: Wed, 21 May 2014 19:04:18 +0000 Subject: [PATCH] updated operator * (VectorBase), its description and the corresponding test git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@32959 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/lac/petsc_vector_base.h | 3 +++ deal.II/source/lac/petsc_vector_base.cc | 6 +++++- tests/petsc_complex/20.cc | 2 +- tests/petsc_complex/20.output | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) 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 b8195d78ea..d19932da4e 100644 --- a/deal.II/include/deal.II/lac/petsc_vector_base.h +++ b/deal.II/include/deal.II/lac/petsc_vector_base.h @@ -544,6 +544,9 @@ namespace PETScWrappers * Return the scalar product of two * vectors. The vectors must have the * same size. + * + * For complex valued vector, this gives + * $\left(v^\ast,vec\right)$. */ PetscScalar operator * (const VectorBase &vec) const; diff --git a/deal.II/source/lac/petsc_vector_base.cc b/deal.II/source/lac/petsc_vector_base.cc index 3233797c69..e441b03e64 100644 --- a/deal.II/source/lac/petsc_vector_base.cc +++ b/deal.II/source/lac/petsc_vector_base.cc @@ -357,7 +357,11 @@ namespace PETScWrappers PetscScalar result; - const int ierr = VecDot (vector, vec.vector, &result); + //For complex vectors, VecDot() computes + // val = (x,y) = y^H x, + //where y^H denotes the conjugate transpose of y. + //Note that this corresponds to the usual "mathematicians" complex inner product where the SECOND argument gets the complex conjugate. + const int ierr = VecDot (vec.vector, vector, &result); AssertThrow (ierr == 0, ExcPETScError(ierr)); return result; diff --git a/tests/petsc_complex/20.cc b/tests/petsc_complex/20.cc index f983727ff4..0774b2cef2 100644 --- a/tests/petsc_complex/20.cc +++ b/tests/petsc_complex/20.cc @@ -41,7 +41,7 @@ void test (PETScWrappers::Vector &v, { const PetscScalar wi = std::complex (5.0-i,2.5*(i%6)); w(i) = wi; - product += vi*wi; + product += PetscConj(vi)*wi; } } diff --git a/tests/petsc_complex/20.output b/tests/petsc_complex/20.output index e69de29bb2..0fd8fc12f0 100644 --- a/tests/petsc_complex/20.output +++ b/tests/petsc_complex/20.output @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5