<br><br><div class="gmail_quote">On Thu, May 20, 2010 at 8:54 PM, Barry Smith <span dir="ltr">&lt;<a href="mailto:bsmith@mcs.anl.gov">bsmith@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;">
<div style=""><br><div><div class="im"><div>On May 20, 2010, at 7:24 AM, RenZhengYong wrote:</div><br><blockquote type="cite"><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" target="_blank">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 - 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></blockquote><div>Badly, my code uses C++.  I compiled PETSc with  &quot;--with-scalar-type=complex --with-clanguage=c&quot; and I<br>added <br>include ${PETSC_DIR}/conf/variables<br>include ${PETSC_DIR}/conf/rules<br>

in my makefile. So, could it possible to specify g++ for my code and to link c-version petsc?<br><br></div></div></blockquote></div>   So long as you do not use any C++ feature of PETSc you can do this. BUT C&#39;s complex numbers are C&#39;s and may not work with a C++ compiler. With C++ code you may simply need to use the C++ complex type, this has nothing to do with PETSc.</div>
<div><br></div></div></blockquote><div>Several minutes ago, I successfully  linked the c-version petsc in my c++ code which uses C99 complex number.  I did not change anything, except for writing a proper makefile to call petsc as a library, :). Now, it works. <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;"><div style=""><div></div><div>  How do you know that C&#39;s complex is 50 times faster than C++&#39;s? That is not our experience.</div>
</div></blockquote><div>I wrote a small code which only has two loops. In the inner loop, there are several complex-value based vector&#39;s operations such as  vector&#39;s product and cross.  with &quot;-O3&quot; flag on, the code using C99 complex number is much faster than C++&#39;s complex class.  I do not know the reason either. <br>
<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;"><div style=""><div><br></div><font color="#888888"><div>    Barry</div></font><div>
<div></div><div class="h5"><div><br></div><div><br><blockquote type="cite"><div class="gmail_quote"><div>kind regards,<br>Zhengyong <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


<font color="#888888"><br>
Satish<br>
</font><div><div></div><div><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" target="_blank">zhengyong.ren@aug.ig.erdw.ethz.ch</a><br>Gmail: <a href="mailto:renzhengyong@gmail.com" target="_blank">renzhengyong@gmail.com</a><br>
</blockquote></div><br></div></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>