Skip to content

Commit

Permalink
Test for infinite matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Jul 12, 2023
1 parent 79109dd commit 310b1aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Aqua = "0.6"
ArrayLayouts = "1"
Documenter = "0.27"
FillArrays = "1.3"
InfiniteArrays = "0.12"
PrecompileTools = "1"
julia = "1.6"

Expand All @@ -22,8 +23,9 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GenericLinearAlgebra = "14197337-ba66-59df-a3e3-ca00e7dcff7a"
InfiniteArrays = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "Base64", "Documenter", "GenericLinearAlgebra", "Random", "Test"]
test = ["Aqua", "Base64", "Documenter", "GenericLinearAlgebra", "InfiniteArrays", "Random", "Test"]
13 changes: 13 additions & 0 deletions test/test_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ using BandedMatrices, LinearAlgebra, ArrayLayouts, FillArrays, Test, Base64
import BandedMatrices: banded_mul!, isbanded, AbstractBandedLayout, BandedStyle,
rowsupport, colsupport, _BandedMatrix, BandedColumns, bandeddata
import ArrayLayouts: OnesLayout, UnknownLayout
using InfiniteArrays

struct PseudoBandedMatrix{T} <: AbstractMatrix{T}
data::Array{T}
Expand Down Expand Up @@ -87,6 +88,9 @@ LinearAlgebra.fill!(A::PseudoBandedMatrix, v) = fill!(A.data,v)
@test @inferred(B[band(0)]) Fill(1.0,5)
@test B[band(1)] B[band(-1)] Fill(0.0,4)
@test B[band(2)] B[band(-2)] Fill(0.0,3)

B = Diagonal(1:∞)
@test @inferred(B[Band(0)]) == 1:
end

@testset "SymTridiagonal" begin
Expand All @@ -101,6 +105,9 @@ LinearAlgebra.fill!(A::PseudoBandedMatrix, v) = fill!(A.data,v)
BandedMatrices.inbands_setindex!(A, 2, 1,1)
@test A[1,1] == 2

S = SymTridiagonal(1:∞, 1:∞)
@test @inferred(S[Band(0)]) == S[Band(1)] == S[Band(-1)] == 1:

B = SymTridiagonal(Fill(1,5), Fill(2,4))
@test @inferred(B[band(0)]) Fill(1,5)
@test B[band(1)] B[band(-1)] Fill(2,4)
Expand All @@ -119,6 +126,9 @@ LinearAlgebra.fill!(A::PseudoBandedMatrix, v) = fill!(A.data,v)
@test B[Band(2)] == B[Band(-2)] == [0,0]
@test B[Band(5)] == B[Band(-5)] == Int[]

T = Tridiagonal(1:∞, 1:∞, 1:∞)
@test @inferred(T[Band(0)]) == T[Band(1)] == T[Band(-1)] == 1:

B = Tridiagonal(Fill(1,4), Fill(2,5), Fill(3,4))
@test @inferred(B[band(0)]) Fill(2,5)
@test B[band(1)] Fill(3,4)
Expand All @@ -132,6 +142,9 @@ LinearAlgebra.fill!(A::PseudoBandedMatrix, v) = fill!(A.data,v)
@test L[Band(-1)] == 1:4
@test L[Band(1)] == zeros(Int,4)

L = Bidiagonal(1:∞, 1:∞, :L)
@test @inferred(L[Band(0)]) == L[Band(-1)] == 1:

L = Bidiagonal(Fill(2,5), Fill(1,4), :L)
@test @inferred(L[band(0)]) Fill(2,5)
@test L[band(1)] Fill(0,4)
Expand Down

0 comments on commit 310b1aa

Please sign in to comment.