-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
MAINT: Rework residue and residuez #10997
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
Conversation
Textbook method of finding partial fraction expansion was replaced with "deflation through subtraction" algorithm which is more streamlined and suitable for numerical implementation
This all sounds good to me. Thanks for looking into the algorithm. I'm willing to trust the tests to ensure that it's working properly. And having looked just briefly at the code, it looks like overall it's a simplification, which is great. Failures appear real: https://travis-ci.org/scipy/scipy/jobs/605488928 Let me know once CIs are happy (ignoring if necessary what #10993 fixes) and I'll take a deeper look. |
The algorithm is any complicated only for repeated roots. In this case iterations are not very difficult to understand or implement either.
There is sort of a bug in I worked around it by casting
Will change to that.
I'd keep #4564 for a similar cleanup of |
Okay let me know when you push a commit for this and any other remaining comments and I'll look again. |
I think I fixed everything what necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM +1 for merge. Let's leave it open for a couple of days in case someone else wants to look.
Feel free to ping me for a merge on Tuesday if nobody else comments.
It has been a few days, so I'll go ahead and get this in. Thanks @nmayorov ! |
What does this implement/fix?
Implementation of partial fraction expansion relied on a textbook "residue method" with fraction differentiation and all that. I decided to investigate whether there are established numerical methods for doing PFE.
I have found a rather old paper called "Partial fractions expansion: a review of computational methodology and efficiency" with nine methods described there. And the "textbook method" was only mentioned as the one which is not recommended for computer implementation.
So I picked another method which is relatively easy to understand and implement, doesn't have special cases and quite efficient in terms of number of required operations. Number 6 in the paper.
I've extended the documentation and included tests for
residuez
. The new implementation passes all tests from #4562, #4464 and #4561Overall it looks like a more solid proper implementation now. The previous one was more of a literal translation of a theoretical method and not very clean or efficiently written.
@ilayn @larsoner It's not super obvious changes, but someone needs to review this. I'm happy to clarify any specifics of the code.
Closes #4562, #4561, #10929