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

Update 7542, ENH: Add polyrootval to numpy.polynomial #7734

Merged
merged 2 commits into from
Jun 12, 2016

Conversation

charris
Copy link
Member

@charris charris commented Jun 12, 2016

Small fixups for #7542.

As one can easily encounter when working with high-order signal processing
filters, converting a high-order polynomial from its roots to its polynomial
coefficients can be quite lossy, leading to inaccuracies in the filter's
properties.

I'm proposing a new function, polyrootval - based on polyval - that
evaluates a polynomial given a list of its roots. The benefit of calculating it
this way can be seen at scipy Issue #6059. Some tests are included, as well.

There are a few things where I'm not 100% sure what the best choice is, though

  • The return value for an empty list of roots is zeros_like(x); maybe there's another value that makes more sense, or even an error?
  • How can one specify -x**n? roots=[0]*n can only give you x**n.

e-q and others added 2 commits June 12, 2016 12:08
As one can easily encounter when working with high-order signal processing
filters, converting a high-order polynomial from its roots to its polynomial
coefficients can be quite lossy, leading to inaccuracies in the filter's
properties.

This PR adds a new function, `polyrootval` - based on `polyval` -  that
evaluates a polynomial given a list of its roots. The benefit of calculating it
this way can be seen at scipy/scipy:6059. Some tests are included, as well.
Simplify the logic a bit and make behavior consistent with polyval.

Note that this adds a check that the number of dimensions of the
array of the evaluation points is less than the number of dimensions of
the array of roots when tensor=False. That check is missing from polyval
and needs to be added.
@charris
Copy link
Member Author

charris commented Jun 12, 2016

Thanks @e-q .

@e-q
Copy link
Contributor

e-q commented Jun 13, 2016

Thank you for your help and patience!

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

Successfully merging this pull request may close these issues.

None yet

2 participants