--
---
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/cython-users/860cd380-2a3a-40e6-aeeb-c6eae1abf7d8n%40googlegroups.com.
My guess was using fused types for the float precision and using C++'s templated complex type, but that doesn't seem to compile.
Fused types and `ufunc` should definitely work, but I'm not sure how easily they combine with C++ templates. It's probably easier just to use cython's native complex types if you can.
- In spite of using @cython.exceptval(check=False) it looks to be as there are still some error checks.
I can't see much error checking so I'm not sure
that's an issue?
- I don't find any way to calculate the real and imaginary part without falling back to Python. With libcpp.complex's real or libc.complex's creal I get the error 'no suitable method found'.
> If you're using Cython's native complex types then `val.real` and `val.imag` should work without needing to explicitly call C or C++.
You mean `cython.doublecomplex`? This produces code like50: re: cython.double = z.real __pyx_t_1 = __Pyx_CREAL(__pyx_v_z);
__pyx_v_re = __pyx_t_1;
I am not very good with the compiled code, but from the color scheme alone I would infer that `__Pyx_CREAL` is a Python call, or is this unproblematic?
The implementation of __Pyx_CREAL varies slightly depending on
your platform, but it's very cheap - basically the same as
accessing the fields of a C/C++ complex.
What's happening there is that `std::isfinite` is declared as
"could raise a C++ exception". I think that's probably wrong and
it will never really raise a C++ exception. I'm sure that code
costs something, but it should be pretty low - most C++ compilers
don't generate a lot of overhead for unused exception handling.