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

Enable evaluation of multiple inputs at once on a single polynomial #31

Open
KPJoshi opened this issue Oct 26, 2022 · 3 comments
Open
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@KPJoshi
Copy link

KPJoshi commented Oct 26, 2022

At the moment, I have to evaluate the polynomial one at a time through this library. It is not possible to give multiple inputs at once through a 2D numpy array, and get multiple outputs in return.

Could this perhaps be more easily possible through the numba backend?

@jannikmi
Copy link
Owner

Thanks for suggesting this. I believe one can use numpy.vectorize for this. Feel free reopen this issue if that does not solve your use case.

@KPJoshi
Copy link
Author

KPJoshi commented Oct 27, 2022

The documentation for the numpy.vectorize function says:

The vectorize function is provided primarily for convenience, not for performance. The implementation is essentially a for loop.

Which is what I'm already doing. Ideally, each operation within the polynomial evaluation code would be vectorized. Perhaps for this it would be good to output code for evaluating the horner polynomial in numpy.

@jannikmi
Copy link
Owner

Ok. Are you sure the evaluation on many points is really a bottleneck in your use case? On how many points are you evaluating a single polynomial at once?

Without thinking to much about it, I would say that there is not a lot of operations one can save by considering multiple query points at the same time. This means that there is probably not much more that an optimised for loop one can build.

If this would make a big difference in your case, please feel free to add the small extensions to the evaluation functions (C and Numba optimised) and raise a PR. Unfortunately I don't have the time at the moment to implement this, but I would definetly take some tome to help with documentation, tests, release, etc.

@jannikmi jannikmi reopened this Oct 27, 2022
@jannikmi jannikmi added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants