[petsc-users] complex number issues

RenZhengYong renzhengyong at gmail.com
Thu May 20 07:33:19 CDT 2010


On Wed, May 19, 2010 at 8:56 PM, Satish Balay <balay at mcs.anl.gov> wrote:

> I don't understand the code change -
>
I do not understand either. In my codes, there are a lots of mathematically
complex number operators such exp, *, +, - etc.
I do not understand why c++ std::complex <> is so slow compared to C99
complex number even with "-O3" flag on.


but if you want to use c99
> complex - you can build petsc with:
>
> --with-scalar-type=complex --with-clanguage=c [which is the default for
> clanguage]
>
> And no code-change needed for PETSc. However if your code uses c++ -
> you might have to address that..
>
> Satish
>
> On Wed, 19 May 2010, RenZhengYong wrote:
>
> > Hi,  PETSc team,
> > I wrote a C++ code dealing with electromagnetic problems, which can
> smoothly
> > call PETSc complied by using " --with-scalar-type=complex
> > --with-clanguage=cxx" .
> > To improve the performances of the C++ code, I changed the complex number
> of
> > type from std::complex<double> to double _Complex (C99 standard, roughly
> > 30~50 times faster compared to std::complex<double>). But when I find
> that
> > the C99 complex number head file <complex.h> will lead to the following
> > kinds of errors"
> >
> > /usr/include/c++/4.3/complex:57: error: expected identifier before
> > ‘__complex__’
> > /usr/include/c++/4.3/complex:58: error: expected identifier before
> > ‘__complex__’
> > /usr/include/c++/4.3/complex:58: error: expected unqualified-id before
> ‘<’
> > token
> > /usr/include/c++/4.3/complex:59: error: expected identifier before
> > ‘__complex__’
> > /usr/include/c++/4.3/complex:59: error: expected unqualified-id before
> ‘<’
> > token
> > /usr/include/c++/4.3/complex:60: error: expected identifier before
> > ‘__complex__’
> > /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:157: error:
> > expected unqualified-id before ‘__complex__’
> > /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:306: error:
> > ‘PetscScalar’ does not name a type
> > /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:339: error:
> > ‘PetscScalar’ does not name a type
> > /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: warning:
> > ‘PetscGlobalSum’ initialized and declared ‘extern’
> > /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: error:
> > ‘PetscScalar’ was not declared in this scope
> > /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: error:
> > expected primary-expression before ‘,’ token
> > /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: error:
> > ‘PetscScalar’ was not declared in this scope
> > /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: error:
> > expected primary-expression before ‘,’ token
> > /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: error:
> > expected primary-expression before ‘)’ token
> > /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: error:
> > initializer expression list treated as compound expression
> >
> >
> > Could you please give me some idea to deal with these problems?
> >
> > Kind regards,
> > Zhengyong Ren
> >
> >
>



-- 
Zhengyong Ren
AUG Group, Institute of Geophysics
Department of Geosciences, ETH Zurich
NO H 47 Sonneggstrasse 5
CH-8092, Zürich, Switzerland
Tel: +41 44 633 37561
e-mail: zhengyong.ren at aug.ig.erdw.ethz.ch
Gmail: renzhengyong at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100520/6aaddb06/attachment.htm>


More information about the petsc-users mailing list