From 310b1aa9b3ffccafcda3793b32bda47318d4da43 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 12 Jul 2023 12:12:14 +0530 Subject: [PATCH] Test for infinite matrices --- Project.toml | 4 +++- test/test_interface.jl | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 50693ef8..27e5110a 100644 --- a/Project.toml +++ b/Project.toml @@ -14,6 +14,7 @@ Aqua = "0.6" ArrayLayouts = "1" Documenter = "0.27" FillArrays = "1.3" +InfiniteArrays = "0.12" PrecompileTools = "1" julia = "1.6" @@ -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"] diff --git a/test/test_interface.jl b/test/test_interface.jl index 1f675f13..f9d25cde 100644 --- a/test/test_interface.jl +++ b/test/test_interface.jl @@ -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} @@ -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 @@ -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) @@ -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) @@ -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)