[Numpy-discussion] Accessing real and imaginary parts of npy_complex(nbits)

2024-07-08 Thread Brendan Murphy via NumPy-Discussion
Hi, This is my first look at the numpy internals, so I'm trying to help update pytensor to be compatible with numpy 2.0, and we have some structs that inherit from npy_complex64 and npy_complex128, which currently use .real and .imag to access real and imaginary parts. Assuming a 64 bit syste

[Numpy-discussion] Re: Accessing real and imaginary parts of npy_complex(nbits)

2024-07-09 Thread Brendan Murphy via NumPy-Discussion
I can partially answer my own questions here: 1) To avoid figuring out the type underlying npy_complex64 etc, the following macro seems to work: #define set_real(X, Y) _Generic((X), \ npy_cfloat: npy_csetrealf, \ npy_cdouble: npy_csetreal, \ np