Skip to content

MAINT: improved polynomial evaluation interface - #243

Merged
fbourgey merged 2 commits into
scipy:mainfrom
j-bowhay:polyeval_interface
Aug 13, 2026
Merged

MAINT: improved polynomial evaluation interface#243
fbourgey merged 2 commits into
scipy:mainfrom
j-bowhay:polyeval_interface

Conversation

@j-bowhay

@j-bowhay j-bowhay commented Aug 6, 2026

Copy link
Copy Markdown
Member

Reference issue

What does this implement/fix?

While working on #239 it became quite annoying that there are two completely different functions for evaluating a polynomial with either a real or complex input. This PR introduces a unified xsf::evalpoly which has a double and std::complex<double> overload.

Additional information

AI Generation Disclosure

No ai

@github-actions github-actions Bot added the Maintenance Items related to regular maintenance tasks label Aug 6, 2026
@j-bowhay
j-bowhay force-pushed the polyeval_interface branch from ef79547 to 32e44f9 Compare August 6, 2026 18:43
@j-bowhay j-bowhay closed this Aug 7, 2026
@j-bowhay j-bowhay reopened this Aug 7, 2026
@j-bowhay

j-bowhay commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

@fbourgey would you mind taking a look :)

Comment thread include/xsf/evalpoly.h
namespace xsf {

XSF_HOST_DEVICE inline std::complex<double> cevalpoly(const double *coeffs, int degree, std::complex<double> z) {
XSF_HOST_DEVICE inline std::complex<double> evalpoly(const double *coeffs, int degree, std::complex<double> z) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about if degree=0? Should we add a guard

if (degree=0) {
   return coeffs[0];
}

as coeffs[1] might not exist. The same would apply for the float overload.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - there is quite a bit else that could be done such as checking degree is non-negative and adding standalone tests but I would rather not grow the scope of this PR

@fbourgey
fbourgey merged commit 3cd4366 into scipy:main Aug 13, 2026
9 checks passed
@fbourgey

Copy link
Copy Markdown
Member

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintenance Items related to regular maintenance tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants