-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
MAINT: Implement lstsq
as a gufunc
#9980
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
341536c
to
110de75
Compare
110de75
to
65df2aa
Compare
lstsq
as a gufunc
lstsq
as a gufunc
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 very much like this! And it all looks great. Ideally, we allow lstsq
now to take single precision inputs, but that is probably better done in a follow-up PR as well (not sure how best to handle it; new argument to tell whether to allow single precision?)
Relatedly, since we expose the single-precision routines, we would ideally also test those, but I think that is also fine to leave to a next PR.
b_out = bstar.T | ||
gufunc = _umath_linalg.lstsq_n | ||
|
||
signature = 'DDd->Did' if isComplexType(t) else 'ddd->did' |
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.
Is this necessary given that the inputs are coerced already?
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.
The inputs don't look coerced already to me
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.
Ah, yes, above one just gets the types for later conversion. Should have noticed that.
I think we're stuck with not doing this, in the same way that |
An earlier version exposed twice as many ufuncs, |
Once this goes in, I have another commit that promotes |
I think in principle we could add a |
Of course, then we run into #9444. I'd be in favor of allowing single-precision via |
729e6eb
to
89bca66
Compare
Rebased, and slightly squashed. Good to go, @mhvk? |
This does not yet enable any broadcasting, but makes doing so in future far easier.
89bca66
to
3ef55be
Compare
Yes, this looks good, modulo that there should at least be new issues reminding us to introduce a |
Would you consider #9516 to be that issue? |
I think a new one is better (more focused); see #10888 . Will now merge this one. |
A summary of what this does
s
andc
varaiants ofgelsd
(not used by lstsq, but there if people need them) (the very large diffs are simply what happens when regeneratinglapack_lite
)lstsq
to fall back on one of two gufuncs (that share a loop)What this does not try to do yet, since there are decisions to be made for these:
0
core dimensionLike #9976 (merged), this needs lapack 3.2.2.
This was tested for exact equality by placing asserts within
lstsq
comparing old and new values, and rerunning the test suite.