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
ENH: linalg: Add wrapper for ?tgsyl
#18571
Conversation
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.
Thanks @mainak33 please see my comments sorry again for not looking at it earlier about lwork
.
Looks almost done to me. However the test need a full PEP8 pass then this is getting ready for merge. |
Fixed PEP8 styling issues with new tests in latest checkin |
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.
Looks much better after the PEP8 changes. Thank you
dae87c4
to
dfd52fd
Compare
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.
7440d36
to
96af524
Compare
If you separate the spectrum a bit further then float32 should also get ~1e-4 level precision. So something like this should make it fly. Nevermind the atol = 1e-4 if dtype == np.float32 else 1e-10
m, n = 10, 15
a, _ = schur(generate_random_dtype_array([m, m], dtype=dtype))
d = np.triu(generate_random_dtype_array([m, m], dtype=dtype))
b, _ = schur(generate_random_dtype_array([n, n], dtype=dtype))
e = np.triu(generate_random_dtype_array([n, n], dtype=dtype))
c = generate_random_dtype_array([m, n], dtype=dtype)
f = generate_random_dtype_array([m, n], dtype=dtype)
# Adjust the spectrum of the matrices to get a more precise solution
adjustment = np.eye(m, dtype=dtype)
a += adjustment
d -= 5 * adjustment
b += adjustment
e -= 5 * adjustment |
96af524
to
cf046c6
Compare
I had to make a few minor changes to your suggested code due to matrix sizes but it worked on my local machine. I pushed it. Let's see if it passes all CI tests. |
Tests are failing on some platforms for atol=1e-4 for single precision. Trying with atol =1e-3 |
Well these are tricky problems anyways so if it works with 1e-3 it is what it is, no need to dwell on it. If things pass, let's get it in instead of wasting your time. |
Ah OK, the transposed problem is a different one to separate, hence the artificial push is making the |
Thanks for looking into it. I'm afraid I don't really know the specifics of this algorithm, so won't be much help figuring out the tolerances beyond trial and error. I'll leave it upto you to fine tune the test and tolerances. Let me know if I can help otherwise or if I need to take any action once we are ready to merge the PR. |
The one failing test on macOS tests (meson) / Meson build (3.11) (https://github.com/scipy/scipy/actions/runs/5162854702/jobs/9300833616?pr=18571) looks like its related to #18601 ? |
Ah dammit. I'm stupid. That's why indeed. Anyways let's wait for that one. This one is indeed ready with smaller tolerances |
No worries. I agree. This one looks ready pending the build fix for macOS. Thanks for all the help! |
b654f4a
to
fea44bd
Compare
@ilayn @Kai-Striega I just rebased and pushed and it is now passing all tests with tighter tolerances that Ilayn worked on (Looks like the BLAS package updates for #18601 must have worked to fix the OSX tests for this as well). I think this is now ready for merge. |
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.
I'm happy with this. Waiting on @ilayn for a final review and merge.
Looks good, thank you very much @mainak33 for your patience and @Kai-Striega for the reviews. Let's click it |
Reference issue
Closes #18404
What does this implement/fix?
This adds a low-level wrapper for Lapack functions <s/d>tgsyl
Additional information: