Skip to content

Commit faef035

Browse files
committed
tests pass
1 parent a189f2f commit faef035

File tree

4 files changed

+97
-24
lines changed

4 files changed

+97
-24
lines changed

Project.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version = "0.15.0-dev"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
7-
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
87
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
98
Infinities = "e1ba4f0e-776d-440f-acd9-e1d2e9742647"
109
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
@@ -13,12 +12,14 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1312
[weakdeps]
1413
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
1514
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
15+
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
1616
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
1717
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1818

1919
[extensions]
2020
InfiniteArraysBandedMatricesExt = "BandedMatrices"
2121
InfiniteArraysBlockArraysExt = "BlockArrays"
22+
InfiniteArraysBlockBandedMatricesExt = "BlockBandedMatrices"
2223
InfiniteArraysDSPExt = "DSP"
2324
InfiniteArraysStatisticsExt = "Statistics"
2425

@@ -28,25 +29,27 @@ ArrayLayouts = "1.8"
2829
BandedMatrices = "1.7.6"
2930
Base64 = "1"
3031
BlockArrays = "1.0"
32+
BlockBandedMatrices = "0.13"
3133
DSP = "0.7"
3234
FillArrays = "1.0"
3335
Infinities = "0.1.1"
3436
LazyArrays = "2.2.3"
3537
LinearAlgebra = "1.6"
36-
SparseArrays = "1"
37-
Statistics = "1"
38-
Test = "1"
38+
SparseArrays = "1.0"
39+
Statistics = "1.0"
40+
Test = "1.0"
3941
julia = "1.10"
4042

4143
[extras]
4244
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
4345
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
4446
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
4547
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
48+
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
4649
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
4750
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
4851
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
4952
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5053

5154
[targets]
52-
test = ["Aqua", "Test", "BandedMatrices", "BlockArrays", "Statistics", "SparseArrays", "Base64", "DSP"]
55+
test = ["Aqua", "Test", "BandedMatrices", "BlockArrays", "BlockBandedMatrices", "Statistics", "SparseArrays", "Base64", "DSP"]
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
module InfiniteArraysBlockBandedMatricesExt
2+
3+
using InfiniteArrays, BlockBandedMatrices
4+
5+
using InfiniteArrays.LinearAlgebra, BlockBandedMatrices.BlockArrays, BlockBandedMatrices.BandedMatrices
6+
7+
import BlockBandedMatrices: BlockSkylineSizes, BlockBandedMatrix, _BlockSkylineMatrix
8+
import InfiniteArrays: InfiniteCardinal, OneToInf, InfStepRange
9+
import BlockBandedMatrices.BandedMatrices: _BandedMatrix
10+
11+
const BlockTriPertToeplitz{T} = BlockMatrix{T,Tridiagonal{Matrix{T},Vcat{Matrix{T},1,Tuple{Vector{Matrix{T}},Fill{Matrix{T},1,Tuple{OneToInf{Int}}}}}},
12+
NTuple{2,BlockedOneTo{Int,Vcat{Int,1,Tuple{Vector{Int},InfStepRange{Int,Int}}}}}}
13+
14+
15+
BlockBandedMatrices.blockbanded_colstop(A, x::InfiniteCardinal{0}) = x
16+
BlockBandedMatrices.blockbanded_rowstop(A, x::InfiniteCardinal{0}) = x
17+
18+
function BlockSkylineSizes(A::BlockTriPertToeplitz, (l,u)::NTuple{2,Int})
19+
N = max(length(A.blocks.du.args[1])+1,length(A.blocks.d.args[1]),length(A.blocks.dl.args[1]))
20+
block_sizes = Vector{Int}(undef, N) # assume square
21+
block_starts = BandedMatrix{Int}(undef, (N+l,N), (l,u))
22+
block_strides = Vector{Int}(undef, N)
23+
for J=1:N
24+
block_starts[max(1,J-u),J] = J == 1 ? 1 :
25+
block_starts[max(1,J-1-u),J-1]+block_sizes[J-1]*block_strides[J-1]
26+
27+
for K=max(1,J-u)+1:J+l
28+
block_starts[K,J] = block_starts[K-1,J]+size(A[Block(K-1,J)],1)
29+
end
30+
block_strides[J] = block_starts[J+l,J] + size(A[Block(J+l,J)],1) - block_starts[max(1,J-u),J]
31+
block_sizes[J] = size(A[Block(J,J)],2)
32+
end
33+
34+
block_stride∞ = 0
35+
for K=max(1,N+1-u):N+1+l
36+
block_stride∞ += size(A[Block(K,N+1)],1)
37+
end
38+
block_size∞ = size(A[Block(N+1,N+1)],2)
39+
40+
bs∞ = fill(block_starts[max(1,N-u),N]+block_strides[N]*size(A[Block(N,N)],2):block_stride∞*block_size∞:∞, l+u+1)
41+
for k=2:l+u+1
42+
bs∞[k] = bs∞[k-1] .+ size(A[Block(N+1-u+k-1,N+1)],1)
43+
end
44+
45+
BlockSkylineSizes(axes(A),
46+
_BandedMatrix(Hcat(block_starts.data, Vcat(adjoint.(bs∞)...)), ℵ₀, l, u),
47+
Vcat(block_strides, Fill(block_stride∞,∞)),
48+
Fill(l,∞),Fill(u,∞))
49+
end
50+
51+
function BlockBandedMatrix(A::BlockTriPertToeplitz{T}, (l,u)::NTuple{2,Int}) where T
52+
data = T[]
53+
append!(data,vec(A[Block.(1:1+l),Block(1)]))
54+
N = max(length(A.blocks.du.args[1])+1,length(A.blocks.d.args[1]),length(A.blocks.dl.args[1]))
55+
for J=2:N
56+
append!(data, vec(A[Block.(max(1,J-u):J+l),Block(J)]))
57+
end
58+
tl = mortar(Fill(vec(A[Block.(max(1,N+1-u):N+1+l),Block(N+1)]),∞))
59+
60+
B = _BlockSkylineMatrix(Vcat(data,tl), BlockSkylineSizes(A, (l,u)))
61+
end
62+
63+
BlockBandedMatrix(A::BlockTriPertToeplitz) = BlockBandedMatrix(A, blockbandwidths(A))
64+
65+
end #module

test/runtests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,4 +1264,5 @@ end
12641264

12651265
include("test_infconv.jl")
12661266
include("test_infblock.jl")
1267-
include("test_infbanded.jl")
1267+
include("test_infbanded.jl")
1268+
include("test_infblockbanded.jl")

test/test_infblockbanded.jl

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1+
using InfiniteArrays, BlockBandedMatrices, ArrayLayouts, FillArrays, BlockArrays, Test
2+
using Base: oneto
13

24
@testset "BlockBanded" begin
3-
a = b = c = 0.0
4-
n = mortar(Fill.(oneto(∞), oneto(∞)))
5-
k = mortar(Base.OneTo.(oneto(∞)))
6-
Dy = BlockBandedMatrices._BandedBlockBandedMatrix((k .+ (b + c))', axes(k, 1), (-1, 1), (-1, 1))
7-
N = 100
8-
@test Dy[Block.(1:N), Block.(1:N)] == BlockBandedMatrices._BandedBlockBandedMatrix((k.+(b+c))[Block.(1:N)]', axes(k, 1)[Block.(1:N)], (-1, 1), (-1, 1))
9-
@test colsupport(Dy, axes(Dy,2)) == 1:
10-
@test rowsupport(Dy, axes(Dy,1)) == 2:
11-
end
5+
@testset "Triangle Recurrence" begin
6+
a = b = c = 0.0
7+
n = mortar(Fill.(oneto(∞), oneto(∞)))
8+
k = mortar(Base.OneTo.(oneto(∞)))
9+
Dy = BlockBandedMatrices._BandedBlockBandedMatrix((k .+ (b + c))', axes(k, 1), (-1, 1), (-1, 1))
10+
N = 100
11+
@test Dy[Block.(1:N), Block.(1:N)] == BlockBandedMatrices._BandedBlockBandedMatrix((k.+(b+c))[Block.(1:N)]', axes(k, 1)[Block.(1:N)], (-1, 1), (-1, 1))
12+
@test colsupport(Dy, axes(Dy,2)) == 1:
13+
@test rowsupport(Dy, axes(Dy,1)) == 2:
14+
end
1215

13-
14-
15-
@testset "BlockTridiagonal" begin
16-
A = BlockTridiagonal(Vcat([fill(1.0, 2, 1), Matrix(1.0I, 2, 2), Matrix(1.0I, 2, 2), Matrix(1.0I, 2, 2)], Fill(Matrix(1.0I, 2, 2), ∞)),
17-
Vcat([zeros(1, 1)], Fill(zeros(2, 2), ∞)),
18-
Vcat([fill(1.0, 1, 2), Matrix(1.0I, 2, 2)], Fill(Matrix(1.0I, 2, 2), ∞)))
1916

20-
@test isblockbanded(A)
21-
@test BlockBandedMatrix(A)[1:100, 1:100] == BlockBandedMatrix(A, (2, 1))[1:100, 1:100] == BlockBandedMatrix(A, (1, 1))[1:100, 1:100] == A[1:100, 1:100]
22-
end
17+
18+
@testset "BlockTridiagonal" begin
19+
A = BlockTridiagonal(Vcat([fill(1.0, 2, 1), Matrix(1.0I, 2, 2), Matrix(1.0I, 2, 2), Matrix(1.0I, 2, 2)], Fill(Matrix(1.0I, 2, 2), ∞)),
20+
Vcat([zeros(1, 1)], Fill(zeros(2, 2), ∞)),
21+
Vcat([fill(1.0, 1, 2), Matrix(1.0I, 2, 2)], Fill(Matrix(1.0I, 2, 2), ∞)))
22+
23+
@test isblockbanded(A)
24+
@test BlockBandedMatrix(A)[1:100, 1:100] == BlockBandedMatrix(A, (2, 1))[1:100, 1:100] == BlockBandedMatrix(A, (1, 1))[1:100, 1:100] == A[1:100, 1:100]
25+
end
26+
end

0 commit comments

Comments
 (0)