[petsc-users] sqrt for a PetscScalar

Umut Tabak u.tabak at tudelft.nl
Wed Apr 7 05:47:32 CDT 2010


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;
...
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


More information about the petsc-users mailing list