<br><br><div class="gmail_quote">On Wed, May 19, 2010 at 8:56 PM, Satish Balay <span dir="ltr">&lt;<a href="mailto:balay@mcs.anl.gov">balay@mcs.anl.gov</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I don&#39;t understand the code change -<br></blockquote><div>I do not understand either. In my codes, there are a lots of mathematically complex number operators such exp, *, +, - etc.  <br>I do not understand why c++ std::complex &lt;&gt; is so slow compared to C99 complex number even with &quot;-O3&quot; flag on.<br>
<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">but if you want to use c99<br>
complex - you can build petsc with:<br>
<br>
--with-scalar-type=complex --with-clanguage=c [which is the default for clanguage]<br>
<br>
And no code-change needed for PETSc. However if your code uses c++ -<br>
you might have to address that..<br>
<font color="#888888"><br>
Satish<br>
</font><div><div></div><div class="h5"><br>
On Wed, 19 May 2010, RenZhengYong wrote:<br>
<br>
&gt; Hi,  PETSc team,<br>
&gt; I wrote a C++ code dealing with electromagnetic problems, which can smoothly<br>
&gt; call PETSc complied by using &quot; --with-scalar-type=complex<br>
&gt; --with-clanguage=cxx&quot; .<br>
&gt; To improve the performances of the C++ code, I changed the complex number of<br>
&gt; type from std::complex&lt;double&gt; to double _Complex (C99 standard, roughly<br>
&gt; 30~50 times faster compared to std::complex&lt;double&gt;). But when I find that<br>
&gt; the C99 complex number head file &lt;complex.h&gt; will lead to the following<br>
&gt; kinds of errors&quot;<br>
&gt;<br>
&gt; /usr/include/c++/4.3/complex:57: error: expected identifier before<br>
&gt; ‘__complex__’<br>
&gt; /usr/include/c++/4.3/complex:58: error: expected identifier before<br>
&gt; ‘__complex__’<br>
&gt; /usr/include/c++/4.3/complex:58: error: expected unqualified-id before ‘&lt;’<br>
&gt; token<br>
&gt; /usr/include/c++/4.3/complex:59: error: expected identifier before<br>
&gt; ‘__complex__’<br>
&gt; /usr/include/c++/4.3/complex:59: error: expected unqualified-id before ‘&lt;’<br>
&gt; token<br>
&gt; /usr/include/c++/4.3/complex:60: error: expected identifier before<br>
&gt; ‘__complex__’<br>
&gt; /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:157: error:<br>
&gt; expected unqualified-id before ‘__complex__’<br>
&gt; /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:306: error:<br>
&gt; ‘PetscScalar’ does not name a type<br>
&gt; /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:339: error:<br>
&gt; ‘PetscScalar’ does not name a type<br>
&gt; /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: warning:<br>
&gt; ‘PetscGlobalSum’ initialized and declared ‘extern’<br>
&gt; /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: error:<br>
&gt; ‘PetscScalar’ was not declared in this scope<br>
&gt; /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: error:<br>
&gt; expected primary-expression before ‘,’ token<br>
&gt; /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: error:<br>
&gt; ‘PetscScalar’ was not declared in this scope<br>
&gt; /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: error:<br>
&gt; expected primary-expression before ‘,’ token<br>
&gt; /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: error:<br>
&gt; expected primary-expression before ‘)’ token<br>
&gt; /home/Zhengyong/packages/petsc-3.1-p1/include/petscmath.h:469: error:<br>
&gt; initializer expression list treated as compound expression<br>
&gt;<br>
&gt;<br>
&gt; Could you please give me some idea to deal with these problems?<br>
&gt;<br>
&gt; Kind regards,<br>
&gt; Zhengyong Ren<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Zhengyong Ren<br>AUG Group, Institute of Geophysics<br>Department of Geosciences, ETH Zurich<br>NO H 47 Sonneggstrasse 5<br>CH-8092, Zürich, Switzerland<br>Tel: +41 44 633 37561<br>
e-mail: <a href="mailto:zhengyong.ren@aug.ig.erdw.ethz.ch">zhengyong.ren@aug.ig.erdw.ethz.ch</a><br>Gmail: <a href="mailto:renzhengyong@gmail.com">renzhengyong@gmail.com</a><br>