[petsc-users] cusp complex and std complex

Matthew Knepley knepley at gmail.com
Thu Sep 5 12:38:04 CDT 2013


On Thu, Sep 5, 2013 at 12:31 PM, Harshad Sahasrabudhe
<hsahasra at purdue.edu>wrote:

> Sorry the last line of the error should read like this:
>
>     test.cpp:9:8: note:   no known conversion for argument 3 from
> 'cusp::complex<double>' to 'std::complex<double>&'
>
> Didn't copy it properly the last time.
>
> Harshad
>
> ----- Original Message -----
> From: "Harshad Sahasrabudhe" <hsahasra at purdue.edu>
> To: "Matthew Knepley" <knepley at gmail.com>
> Cc: petsc-users at mcs.anl.gov
> Sent: Thursday, September 5, 2013 1:29:38 PM
> Subject: Re: [petsc-users] cusp complex and std complex
>
> Hi Matt,
>
> I have attached a small test case which reproduces the problem. Here is
> the compilation command with the error:
>
>
>     gcc -c test.cpp -I/u/sciteam/sahasrab/NEMO5/libs/petsc/include
> -I/u/sciteam/sahasrab/NEMO5/libs/petsc/arch-linux2-cxx-opt-cplx/include/
> -I/opt/cray/mpt/6.0.1/gni/mpich2-
>     cray/81/include/
> -I/u/sciteam/sahasrab/NEMO5/libs/petsc/cusplibrary-master/
> -I/opt/nvidia/cudatoolkit/5.0.35/include/
>
>     test.cpp: In function 'int main()':
>     test.cpp:24:27: error: no matching function for call to
> 'VectorP<std::complex<double> >::dot_product(VectorP<std::complex<double>
> >&, VectorP<std::complex<double> >&,
>     cusp::complex<double>&)'
>        a.dot_product(a, b, p[1]);
>                            ^
>     test.cpp:24:27: note: candidate is:
>     test.cpp:9:8: note: void VectorP<T>::dot_product(VectorP<T>&,
> VectorP<T>&, T&) [with T = std::complex<double>]
>        void dot_product(VectorP<T>& vecA, VectorP<T>& vecB, T& prod)
>             ^
>     test.cpp:9:8: note:   no known conversion for argument 3 from
> 'cusp::complex<double>' to 'std::complex<double
>
> My question is, is there no alternative to using VectorP<PetscScalar>?
>

I am not sure what you want. This is a problem with your own type
definitions. If you want a dot_product that returns PetscScalar,
define the overloaded function. If that is a pain, consider using C++.
Personally, I would counsel anyone writing a new code to
abandon C++.

    Matt


> NOTE: PETSc is compiled with CUSP.
>
> Thanks,
> Harshad
>
>
>
>
>     >Are we supposed to guess where this happens? Please send the entire
> compile error, and if its in your code, send
>     >a simple code that demonstrates the problem.
>
>
>     >Matt
>
>     >--
>     >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
>



-- 
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/20130905/93d40433/attachment.html>


More information about the petsc-users mailing list