On Tue, Mar 11, 2014 at 7:29 AM, Nick Foti <
nfo...@gmail.com> wrote:
> It turns out that sizeof(double complex) works. From some preliminary
> searches it looks like double complex and std::complex<double> have the same
> representations now, however, I'm not sure it's a good idea to make people
> mix the C and C++ versions.
When compiling as C++, double complex is a std::complex<double>.
There are three implementations of complex numbers, Cython's internal
implementation (used if you don't include complex.h, e.g. for non c99
compilers), C99 _Complex (if you include complex.h) and std::complex
(used if you're compiling in C++).
> In C, `complex` is not a keyword unless complex.h is included (it's not
> actually a keyword, it's a macro for _Complex). To be consistent with C and
> how Cython handles C++ complex numbers, shouldn't Cython wrap complex.h in
> libc and the user can then say something like `from libc cimport complex`
> (or `from libc cimport "double complex"`)? This way you only get complex
> numbers when you want them (like in C), and C++ users don't have to work
> around C complex numbers.
Cython is not necessarily trying to be like C. If anything, it's
trying to be like Python. Python has a builtin complex type, so we
wanted to support this in Cython efficiently as well. In particular,
for numpy/scientific users, we want to make it really easy to use
complex numbers in a portable way.
If you want to use std::complex<double> numbers in C++, just use
"double complex." I'm not sure how this gets in the way.
> On Thursday, March 6, 2014 7:24:21 PM UTC-5, Sturla Molden wrote:
>>
>> Nick Foti <
nfo...@gmail.com> wrote:
>> > The code `sizeof(complex[double])` does not seem to work and causes a
>> > CompilerCrash. I instead need to instantiate a variable of type
>> > `complex[double]` on the stack, call it `z` and use `sizeof(z)`. The
>> > resulting code works, but `sizeof(complex[double])` should probably work
>> > too.
>>
>> Did you try sizeof(complex double) ?
>>
>>
>> Sturla
>>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "cython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
cython-users...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.