no operator "*" for cuDoubleComplex

Hello,

I have an expression like:

A = MS11 * txs + MS12 * tys + MS13 * tzs;

where all the variables are defined previously as cuDoubleComplex.

When I try to compile it using nvcc, I get the following error:
error: no operator “*” matches these operands
operand types are: cuDoubleComplex * cuDoubleComplex

Why does it not recognize multiplication between two complex numbers? Must I use cuCmul() ? Why is “+” not flagged as an error then?

Please clarify.

Thank you,

F

To my knowledge, neither an operator “+” nor an operator “*” is defined, so I am puzzled by your observation.

The minimal implementation of complex arithmetic in cuComplex.h was designed for the needs of CUBLAS and CUFFT, at a time when there was no C++ support in CUDA. Thus the C-style interface.

You might want to file an enhancement request for full-fledged complex support along the lines of C99 or C++, via the bug reporting form linked from the registered developer website.

Hello,

OK thanks for the info.

When you say “Thus the C-style interface” do you mean that there is another way of dealing with complex numbers in CUDA? In C, I use a complex.h header…

Are there any home-brew implementations to ease the use of complex arithmetic you can suggest?

Thank you.

F

By “C-style interface” I meant one based on function calls rather than operator overloading for user-defined types. Early CUDA was based on a C, rather than C++, frontend so operator overloading was not available.

Starting with C99, C offers complex as a built-in type, and operators for it are thus defined without the need to support operator overloading for user-defined types (which is a C++ feature).

There is no built-in support for complex types in CUDA at this point, and the user-defined types and operations in cuComplex.h implement only minimal functionality for the internal needs of CUBLAS and CUFFT. As I stated, you might want to file an enhancement request for more extensive support of complex data types.

I am not aware of third-party packages for complex arithmetic in CUDA, which does not mean they don’t exist.

I understand.

Thank you! :)

Have a look at

Perhaps it is useful to your purposes.