-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement vcat(::AbstractBandedMatrix...) (#448)
* implement bandwidths for OneElement * make improvements * fix sparse(::SparseMatrixCSC) * fix bandwidths for SparseMatrixCSC, add for SparseVector * add bandwidths(::Zeros) behaviour for empty sparse structures * add unit tests * overload vcat(::AbstractBandedMatrix...) * style * include tests in runtests.jl * fix issue involving LazyBandedMatrices * fixed mistake * make improvements * add vcat between BandedMatrices and OneElements * fix issue involving calculation of bandwidths. Add unit tests for OneElement * fix issue involving bandwidths larger than dimensions * restore vcat * v1.7.4 --------- Co-authored-by: Sheehan Olver <[email protected]>
- Loading branch information
1 parent
57a70a5
commit 4ff8ff0
Showing
5 changed files
with
96 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module TestCat | ||
|
||
using BandedMatrices, LinearAlgebra, Test, Random, FillArrays, SparseArrays | ||
|
||
@testset "vcat" begin | ||
@testset "banded matrices" begin | ||
a = BandedMatrix(0 => 1:2) | ||
@test vcat(a) == a | ||
|
||
b = BandedMatrix(0 => 1:3,-1 => 1:2, -2 => 1:1) | ||
@test_throws DimensionMismatch vcat(a,b) | ||
|
||
c = BandedMatrix(0 => [1.0, 2.0, 3.0], 1 => [1.0, 2.0], 2 => [1.0]) | ||
@test eltype(vcat(b, c)) == Float64 | ||
@test vcat(b, c) == vcat(Matrix(b), Matrix(c)) | ||
|
||
for i in ((1,2), (-3,4), (0,-1)) | ||
a = BandedMatrix(ones(Float64, rand(1:10), 5), i) | ||
b = BandedMatrix(ones(Int64, rand(1:10), 5), i) | ||
c = BandedMatrix(ones(Int32, rand(1:10), 5), i) | ||
d = vcat(a, b, c) | ||
sd = vcat(sparse(a), sparse(b), sparse(c)) | ||
@test eltype(d) == Float64 | ||
@test d == sd | ||
@test bandwidths(d) == bandwidths(sd) | ||
end | ||
end | ||
|
||
@testset "one element" begin | ||
n = rand(3:20) | ||
x,y = OneElement(1, (1,1), (1,n)), OneElement(1, (1,n), (1,n)) | ||
b = BandedMatrix((0 => ones(n-2), 1 => -2ones(n - 2), 2 => ones(n - 2)), (n-2, n)) | ||
@test vcat(x,b,y) == Tridiagonal([ones(n - 2); 0], [1 ; -2ones(n - 2); 1], [0; ones(n - 2)]) | ||
end | ||
end | ||
|
||
end |