From: young Date: Fri, 18 Oct 2013 15:06:54 +0000 (+0000) Subject: Test real() and imag() work correctly on complex vectors. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f7f6f34862034df1de58e17fa0e9b3121864189;p=dealii-svn.git Test real() and imag() work correctly on complex vectors. git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@31305 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/petsc_scalar_complex/element_access.cc b/tests/petsc_scalar_complex/element_access.cc new file mode 100644 index 0000000000..aa64a6d06c --- /dev/null +++ b/tests/petsc_scalar_complex/element_access.cc @@ -0,0 +1,145 @@ + +// --------------------------------------------------------------------- +// $Id: +// +// Copyright (C) 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +// deal.II includes +#include "../tests.h" +#include +#include + +#include +#include +#include + +#include + +// test dealii::internal::VectorReference::real() +// test dealii::internal::VectorReference::imag() +// on vector and matrix + +// vector elements +void test_vector (PETScWrappers::Vector &v) +{ + deallog << "Check vector access" << std::endl; + + // fill up a vector with some numbers + for (unsigned int k=0; k (k,v.size()-k); + + v.compress (VectorOperation::add); + + // check that is what we get by casting PetscScalar to std::real() + // and std::imag() + for (unsigned int k=0; k > (v(k)).real ()==k) && + (static_cast > (v(k)).imag ()==v.size()-k), + ExcInternalError()); + + // check that is what we get by + // dealii::internal::VectorReference::real() and + // dealii::internal::VectorReference::imag() + for (unsigned int k=0; k (k+l,-k-l)); + + m.compress (VectorOperation::add); + + for (unsigned int k=0; k > (m(k,l)).real ()==k+l) && + (static_cast > (m(k,l)).imag ()==-k-l), + ExcInternalError()); + + for (unsigned int k=0; k