-
-
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
make similar(A, [T,] shape...) for structured A yield a sparse rather than dense array #24170
Conversation
base/linalg/lu.jl
Outdated
@@ -416,6 +416,14 @@ function lufact!(A::Tridiagonal{T,V}, pivot::Union{Val{false}, Val{true}} = Val( | |||
LU{T,Tridiagonal{T,V}}(B, ipiv, convert(BlasInt, info)) | |||
end | |||
|
|||
# Absent the following methods, if A::Tridiagonal{T} where !(T<:AbstractFloat), then the | |||
# method lufact(A) hits sends copy!(similar(A, afloattype, size(A)), A) (which is not a | |||
# Tridagonal given the (unnecessary?) shape argument to similar) to lufact! rather than |
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 think it is unnecessary so probably better to remove the size
argument instead of introducing this method
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.
Nixing the shape argument sounds good. That removing the shape argument might break other consumers of the general lufact
method motivated the present conservative solution. Let's see whether CI complains :). Best!
…er than dense array.
…ther than dense array.
For some reason, this triggers a test error in |
Should be fixed. Absent objections or requests for time and assuming CI clears, I plan to merge these changes this evening. (If someone beats me to it, not squashing the commits might be best for future bug sleuthing.) Best! |
965b884
to
b3d12fd
Compare
…er than dense array. Also fix a minor bug where lufact(A::Tridiagonal{T}) for !(T<:AbstractFloat) would dispatch to lufact!(B, ...) for non-tridiagonal rather than tridiagonal B downstream.
Thanks all! |
This pull request makes
similar(A<:Union{Diagonal,Bidiagonal,Tridiagonal,SymTridiagonal}, [neweltype,] shape...)
yield a sparse rather than dense array, consistent with e.g.broadcast
. For example, this pull request makessimilar(Diagonal(rand(4)), Float32, (3, 3))
yield aSparseMatrixCSC{Float32}
rather than the presentMatrix{Float32}
.This pull request also fixes a minor bug where
lufact(A<:Tridiagonal{T})
where!(T<:AbstractFloat)
would hitlufact!(B, ...)
for non-Tridiagonal
rather thanTridiagonal
B
downstream.Ref. JuliaLang/LinearAlgebra.jl#271. Best!