Add SVD algorithm kwarg to nullspace#1576
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1576 +/- ##
=======================================
Coverage 94.37% 94.38%
=======================================
Files 35 35
Lines 16064 16069 +5
=======================================
+ Hits 15161 15166 +5
Misses 903 903 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| The desired algorithm, `alg` is passed through to `svd`. The available algorithms will | ||
| be the same as that of ['svd'](@ref). | ||
|
|
There was a problem hiding this comment.
I think we need a compat entry here, saying something like "the keyword argument alg requires Julia version 1.14" or something like that. There are examples in this or other files.
|
Wouldn't a cleaner and more powerful API be to just talk an existing That way, the caller could construct the SVD however they wanted, and it would also enable an existing SVD to be re-used. Code-wise, it would just require a bit of refactoring of the existing method. |
I was actually thinking the same thing. It seems a bit inefficient to compute the whole SVD here if the user may already have one. I will try my hand at making two methods: one for taking in an actual matrix (at way something like a pivoted QR can be used rather than an SVD), and one taking in an SVD object. |
…not that the vector is exactly equal to the vector that it should be
|
Ok, I've fixed the test that seemed to be giving a problem. The test was to find the nullspace of A1 = [1.0 1.0; 2.0 0.0; -1.0 1.0] * [1.0 1.0 1.0; 1.0 -1.0 1.0]and compare it to |
The nullspace basis is only defined up to an arbitrary rotation. In this case, for a 1d nullspace, the sign is arbitrary, and on MacOS it flips the sign, and returns a vector |
stevengj
left a comment
There was a problem hiding this comment.
Instead of passing through an alg parameter, just refactor to add a method where you can pass an SVD object directly.
Fixes #1571
Now you can call
nullspacewith analgargument, which is passed through tosvd.