- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 35
restrict inv(::Factorization) to square matrices #1397
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
| We could add a deprecation warning instead for the non-square case, but as far as I can tell it was undocumented. | 
| Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@           Coverage Diff           @@
##           master    #1397   +/-   ##
=======================================
  Coverage   93.83%   93.84%           
=======================================
  Files          34       34           
  Lines       15823    15826    +3     
=======================================
+ Hits        14848    14852    +4     
+ Misses        975      974    -1     ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
 | 
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 checked all existing inv(<:Union{AbstractMatrix,Factorization}) methods, and all of them check (sooner or later; in the LU case, it is implicit in the *Triangular constructors) for squareness. So, I agree, this is to be considered a bug, which we should backport to the LTS?
| 
 The docstring for  
 which (if anything) implies a right inverse for the non-square case. So it all seems rather inconsistent to me. It really seems like non-square factorization inverses should require  | 
| I don't think it's a good idea to backport.  On the latest version, if you actually want the old behavior, you could just switch to calling  | 
| cc @carstenbauer and @andreasnoack from JuliaLang/julia#32126. | 
| 
 Ha, so I missed this... | 
| There is a general fallback method  This was added by @andreasnoack way back in JuliaLang/julia#5381, so maybe he can comment on this. The behavior of  | 
| It has been a long time but after reading the PR text again, my best guess is that it wasn't intentional to allow non-square matrices in the fallback  | 
| Should we add a  On the one hand, non-square  | 
| I think this was just oversight, or unintended generality. | 
| Okay, I've updated the PR to add a  
 | 
| Okay to squash and merge? | 
This adds a missing
checksquaretoinv(::SVD), which I would argue is a bug from JuliaLang/julia#32126. If you want the pseudo-inverse, you should callpinv(::SVD)explicitly (via the method introduced in #1387) , not rely on magic undocumented behavior ofinv.Similarly for
inv(::Factorization)(see below), which previously computed a left inverse for non-square ("tall") QR factorizations (see below).(Hoisted from #1387.)