-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
use in-place inv, since lufact already made a copy #22767
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.
Nice catch! :)
2ef10cb
to
d5a0699
Compare
Failure because |
I don't think that fallback is right, since
won't have the desired effect for some types |
You mean because you expected the matrix wrapped in the factorization to be the inverse? That's true... |
d5a0699
to
4283cc8
Compare
Pushed an updated version. |
Timeout on Travis i686 |
base/linalg/lu.jl
Outdated
inv!(LU(copy(A.factors), copy(A.ipiv), copy(A.info))) | ||
inv!(A::LU{T,<:StridedMatrix}) where {T} = | ||
@assertnonsingular A_ldiv_B!(A.factors, copy(A), eye(T, size(A,1))) A.info | ||
inv(A::LU{<:Any,<:StridedMatrix}) = inv!(copy(A)) |
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.
so does this copy twice?
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.
Yea, for the non BlasFloat case..
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.
there's a copy(A)
on this line, then another copy(A)
in the inv!(A::LU{T,<:StridedMatrix})
that it calls, right?
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 guess we can not use the inv(A) = inv!(copy(A))
pattern for the non BlasFloat case then. Instead
inv(A::LU) = A_ldiv_B!(A, eye(size(A)))
then. But we do still need to make the copy in the fallback inv!
such that we can overwrite the stored matrix and use it as the left hand side in the solve at the same time.
4283cc8
to
cad74f6
Compare
cad74f6
to
301933b
Compare
Rebased, good to go? |
Yes indeed. I'll let you do the honors. 😄 |
Thanks! It was scary, but I managed :) |
Basically cuts allocated memory in half for generic
inv
calls.