You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This bug is closely related to ticket http://trac.cython.org/ticket/386, however it is slightly different in that it reports a realistic use case that in my opinion would qualify it as a bug rather than an enhancement request. Hence I've raised a new ticket, but I'm new round here - maybe it should be merged.
whereas the same code produces error free C code with only order of multiplicands reversed. (i.e. substitute varc128 = varf64 * varc128 for varc128 = varc128 * varf64. This appears to be because there are different routes for achieving the multiplication depending on the order of operands, in the first (failing) example it is done via __pyx_t_npy_float64_complex types, whereas in the latter __pyx_t_npy_double_complex
I haven't got a full, generalisable fix / patch as I'm totally new to the codebase, but ''possibly'' the code here should check whether it's valid to append the _Complex and, if not, search to see whether the type can be resolved to an allowable base type.
This bug is still around in Cython version 0.29.11 (July 2019)
It makes development combining complex functions from complex.h with complex numbered numpy arrays completely ill-defined.
PLS fix.
This bug is closely related to ticket http://trac.cython.org/ticket/386, however it is slightly different in that it reports a realistic use case that in my opinion would qualify it as a bug rather than an enhancement request. Hence I've raised a new ticket, but I'm new round here - maybe it should be merged.
The discovery of the bug stems from answering a question on Stack Overflow : http://stackoverflow.com/questions/30054019/complex-numbers-in-cython. It affects numpy multiplication of complex numbers by real valued floats
In its most concise form - this code produces C that will not compile:
whereas the same code produces error free C code with only order of multiplicands reversed. (i.e. substitute
varc128 = varf64 * varc128
forvarc128 = varc128 * varf64
. This appears to be because there are different routes for achieving the multiplication depending on the order of operands, in the first (failing) example it is done via__pyx_t_npy_float64_complex
types, whereas in the latter__pyx_t_npy_double_complex
As far as I could investigate - the offending line of generated C code fails to compile because only
float
,double
orlong double
are allowed before_Complex
(http://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Standard-Complex-Number-Types).The offending line of C code seems to be generated by the code here:
cython/Cython/Compiler/PyrexTypes.py
Line 1949 in bb4d9c2
We can see here that the offending type is basically an alias for
double
cython/Cython/Includes/numpy/__init__.pxd
Line 331 in e3f5343
I haven't got a full, generalisable fix / patch as I'm totally new to the codebase, but ''possibly'' the code here should check whether it's valid to append the _Complex and, if not, search to see whether the type can be resolved to an allowable base type.
cython/Cython/Compiler/Nodes.py
Line 1011 in bb4d9c2
Migrated from http://trac.cython.org/ticket/850
The text was updated successfully, but these errors were encountered: