-
-
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
LinAlg.fillslots! -> LinAlg.fillstored! #25030
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bc28fbf
rename LinAlg.fillslots! LinAlg.fillstored!
fredrikekre 197ada2
rewrite fillstored!(::SpecialMatrix, x) without generated function
fredrikekre 893281d
implement fillband! and call it from fillstored!(::AbstractTriangular)
fredrikekre 69369a7
review fixes
fredrikekre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,58 +310,53 @@ end | |
@test promote(C,A) isa Tuple{Tridiagonal, Tridiagonal} | ||
end | ||
|
||
import Base.LinAlg: fillslots!, UnitLowerTriangular | ||
@testset "fill! and fillslots!" begin | ||
let #fill! | ||
let # fillslots! | ||
A = Tridiagonal(randn(2), randn(3), randn(2)) | ||
@test fillslots!(A, 3) == Tridiagonal([3, 3.], [3, 3, 3.], [3, 3.]) | ||
B = Bidiagonal(randn(3), randn(2), :U) | ||
@test fillslots!(B, 2) == Bidiagonal([2.,2,2], [2,2.], :U) | ||
S = SymTridiagonal(randn(3), randn(2)) | ||
@test fillslots!(S, 1) == SymTridiagonal([1,1,1.], [1,1.]) | ||
Ult = UnitLowerTriangular(randn(3,3)) | ||
@test fillslots!(Ult, 3) == UnitLowerTriangular([1 0 0; 3 1 0; 3 3 1]) | ||
using Base.LinAlg: fillstored!, UnitLowerTriangular | ||
@testset "fill! and fillstored!" begin | ||
let # fillstored! | ||
A = Tridiagonal(randn(2), randn(3), randn(2)) | ||
@test fillstored!(A, 3) == Tridiagonal([3, 3], [3, 3, 3], [3, 3]) | ||
B = Bidiagonal(randn(3), randn(2), :U) | ||
@test fillstored!(B, 2) == Bidiagonal([2,2,2], [2,2], :U) | ||
S = SymTridiagonal(randn(3), randn(2)) | ||
@test fillstored!(S, 1) == SymTridiagonal([1,1,1], [1,1]) | ||
Ult = UnitLowerTriangular(randn(3,3)) | ||
@test fillstored!(Ult, 3) == UnitLowerTriangular([1 0 0; 3 1 0; 3 3 1]) | ||
end | ||
let # fill!(exotic, 0) | ||
exotic_arrays = Any[Tridiagonal(randn(3), randn(4), randn(3)), | ||
Bidiagonal(randn(3), randn(2), rand([:U,:L])), | ||
SymTridiagonal(randn(3), randn(2)), | ||
sparse(randn(3,4)), | ||
# Diagonal(randn(5)), # Diagonal fill! deprecated, see below | ||
sparse(rand(3)), | ||
# LowerTriangular(randn(3,3)), # AbstractTriangular fill! deprecated, see below | ||
# UpperTriangular(randn(3,3)) # AbstractTriangular fill! deprecated, see below | ||
] | ||
for A in exotic_arrays | ||
@test iszero(fill!(A, 0)) | ||
end | ||
let # fill!(exotic, 0) | ||
exotic_arrays = Any[Tridiagonal(randn(3), randn(4), randn(3)), | ||
Bidiagonal(randn(3), randn(2), rand([:U,:L])), | ||
SymTridiagonal(randn(3), randn(2)), | ||
sparse(randn(3,4)), | ||
# Diagonal(randn(5)), # Diagonal fill! deprecated, see below | ||
sparse(rand(3)), | ||
# LowerTriangular(randn(3,3)), # AbstractTriangular fill! deprecated, see below | ||
# UpperTriangular(randn(3,3)) # AbstractTriangular fill! deprecated, see below | ||
] | ||
for A in exotic_arrays | ||
fill!(A, 0) | ||
for a in A | ||
@test a == 0 | ||
end | ||
end | ||
# Diagonal and AbstractTriangular fill! were defined as fillslots!, | ||
# not matching the general behavior of fill!, and so have been deprecated. | ||
# In a future dev cycle, these fill! methods should probably be reintroduced | ||
# with behavior matching that of fill! for other structured matrix types. | ||
# In the interm, equivalently test fillslots! below | ||
@test iszero(fillslots!(Diagonal(fill(1, 3)), 0)) | ||
@test iszero(fillslots!(LowerTriangular(fill(1, 3, 3)), 0)) | ||
@test iszero(fillslots!(UpperTriangular(fill(1, 3, 3)), 0)) | ||
# Diagonal and AbstractTriangular fill! were defined as fillstored!, | ||
# not matching the general behavior of fill!, and so have been deprecated. | ||
# In a future dev cycle, these fill! methods should probably be reintroduced | ||
# with behavior matching that of fill! for other structured matrix types. | ||
# In the interm, equivalently test fillstored! below | ||
@test iszero(fillstored!(Diagonal(fill(1, 3)), 0)) | ||
@test iszero(fillstored!(LowerTriangular(fill(1, 3, 3)), 0)) | ||
@test iszero(fillstored!(UpperTriangular(fill(1, 3, 3)), 0)) | ||
end | ||
let # fill!(small, x) | ||
val = randn() | ||
b = Bidiagonal(randn(1,1), :U) | ||
st = SymTridiagonal(randn(1,1)) | ||
for x in (b, st) | ||
@test Array(fill!(x, val)) == fill!(Array(x), val) | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps simplify to the following? @test fill!(Bidiagonal(fill(0, 1, 1), :U), 2) == fill(2, 1, 1)
@test fill!(SymTridiagonal(fill(0, 1, 1)), 2) == fill(2, 1, 1) |
||
let # fill!(small, x) | ||
val = randn() | ||
b = Bidiagonal(randn(1,1), :U) | ||
st = SymTridiagonal(randn(1,1)) | ||
for x in (b, st) | ||
@test Array(fill!(x, val)) == fill!(Array(x), val) | ||
end | ||
b = Bidiagonal(randn(2,2), :U) | ||
st = SymTridiagonal(randn(3), randn(2)) | ||
t = Tridiagonal(randn(3,3)) | ||
for x in (b, t, st) | ||
@test_throws ArgumentError fill!(x, val) | ||
@test Array(fill!(x, 0)) == fill!(Array(x), 0) | ||
end | ||
b = Bidiagonal(randn(2,2), :U) | ||
st = SymTridiagonal(randn(3), randn(2)) | ||
t = Tridiagonal(randn(3,3)) | ||
for x in (b, t, st) | ||
@test_throws ArgumentError fill!(x, val) | ||
@test Array(fill!(x, 0)) == fill!(Array(x), 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps simplify to |
||
end | ||
end | ||
end | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Perhaps the other triangular types are worth testing as well?