Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support new numpy complex types #458

Closed
tacaswell opened this issue Nov 20, 2023 · 5 comments
Closed

support new numpy complex types #458

tacaswell opened this issue Nov 20, 2023 · 5 comments

Comments

@tacaswell
Copy link

With numpy main compliing numexpr fails with (a lot) of errors that look like:

      numexpr/complex_functions.hpp: In function ‘void nc_assign(npy_cdouble*, npy_cdouble*)’:
      numexpr/complex_functions.hpp:36:6: error: request for member ‘real’ in ‘* r’, which is of non-class type ‘npy_cdouble’ {aka ‘__complex__ double’}
         36 |   r->real = x->real;
            |      ^~~~
      numexpr/complex_functions.hpp:36:16: error: request for member ‘real’ in ‘* x’, which is of non-class type ‘npy_cdouble’ {aka ‘__complex__ double’}
         36 |   r->real = x->real;
            |                ^~~~

I suspect the fix looks like scipy/scipy#18975 and is also a result of numpy/numpy#24085 / numpy/numpy#20880

@27rabbitlt
Copy link
Contributor

Can you please provide a snippet of code? I'm unfamiliar with this numpy's new feature T_T.

@tacaswell
Copy link
Author

numpexpr fails to compile with the numpy default branch.

I think this change won't go out in stable release until numpy 2

@seberg
Copy link
Contributor

seberg commented Nov 29, 2023

It's not a new feature, the NumPy main branch just tries to use the C99/C++11 definitions for complex. And those don't define ->real and ->imag so you need to replace it.

Since I bet you know that you have complex doubles, could probably just not use the NumPy types at all (so that you can use C++ .real() and .imag() no matter which NumPy it is) otherwise may need to cast or use some macro magic.

EDIT: But Thomas gave all the links to get an idea of how to best change it!

@27rabbitlt
Copy link
Contributor

27rabbitlt commented Nov 29, 2023 via email

@tacaswell
Copy link
Author

Closed by #461

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants