[petsc-users] sqrt for a PetscScalar

Matthew Knepley knepley at gmail.com
Wed Apr 7 05:54:31 CDT 2010


On Wed, Apr 7, 2010 at 12:47 PM, Umut Tabak <u.tabak at tudelft.nl> wrote:

> Dear all,
>
> I am getting a compilation error from the sqrt(cmath header) function with
> PETSc 3.1, I configured PETSc with complex scalar type so I am suspecting
> that this is the source of the problem.
>
> Is there a simple workaround for this? And Is there an sqrt function for a
> 'PetscScalar', I could not find that in the documentation?
>
> PetscScalar xTMx;
>

My guess is that you want

PetscReal xTMx;

   Matt


> ...
> VecScale(x, 1/sqrt(xTMx));
>
> /home/utabak/thesis/C++/c++Projects/workDirectory/trunk/src/evpSolver1.cc:502:
> error: no match for ‘operator/’ in ‘1 / std::sqrt [with _Tp =
> double](((const std::complex<double>&)((const std::complex<double>*)(&
> xTMx))))’
> /usr/include/c++/4.3/bits/stl_pair.h: In constructor ‘std::pair<_T1,
> _T2>::pair(const std::pair<_U1, _U2>&) [with _U1 = std::complex<double>, _U2
> = int, _T1 = const double, _T2 = int]’:
>
>
> Best regards,
> Umut
>



-- 
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100407/a00f8e73/attachment.htm>


More information about the petsc-users mailing list