Skip to content

Commit 288d44e

Browse files
authored
Suppport Diagonal block times padded (#66)
* Support Diagonal block matrix * padded * v0.4.7 * Update Project.toml * Update Project.toml * Add tests * Update blockbanded.jl * increase coverage
1 parent 7a730b5 commit 288d44e

File tree

3 files changed

+39
-10
lines changed

3 files changed

+39
-10
lines changed

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "InfiniteLinearAlgebra"
22
uuid = "cde9dba0-b1de-11e9-2c62-0bab9446c55c"
3-
version = "0.4.6"
3+
version = "0.4.7"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -18,12 +18,12 @@ SemiseparableMatrices = "f8ebbe35-cbfb-4060-bf7f-b10e4670cf57"
1818
[compat]
1919
ArrayLayouts = "0.5.1"
2020
BandedMatrices = "0.16"
21-
BlockArrays = "0.14"
21+
BlockArrays = "0.14.2"
2222
BlockBandedMatrices = "0.10"
2323
FillArrays = "0.11"
24-
InfiniteArrays = "0.9"
24+
InfiniteArrays = "0.9.3"
2525
LazyArrays = "0.20.2"
26-
LazyBandedMatrices = "0.4.2"
26+
LazyBandedMatrices = "0.4.5"
2727
MatrixFactorizations = "0.7.1, 0.8"
2828
SemiseparableMatrices = "0.2.2"
2929
julia = "1.5"

src/blockbanded/blockbanded.jl

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
const OneToInfCumsum = InfiniteArrays.RangeCumsum{Int,OneToInf{Int}}
22
const OneToCumsum = InfiniteArrays.RangeCumsum{Int,OneTo{Int}}
33

4+
BlockArrays.sortedunion(::AbstractVector{Infinity}, ::AbstractVector{Infinity}) = [∞]
5+
function BlockArrays.sortedunion(::AbstractVector{Infinity}, b)
6+
@assert isinf(length(b))
7+
b
8+
end
9+
10+
function BlockArrays.sortedunion(b, ::AbstractVector{Infinity})
11+
@assert isinf(length(b))
12+
b
13+
end
414
BlockArrays.sortedunion(a::OneToInfCumsum, ::OneToInfCumsum) = a
515
BlockArrays.sortedunion(a::OneToCumsum, ::OneToCumsum) = a
16+
function BlockArrays.sortedunion(a::RangeCumsum{<:Any,<:InfStepRange}, b::RangeCumsum{<:Any,<:InfStepRange})
17+
@assert a == b
18+
a
19+
end
20+
621

722
function BlockArrays.sortedunion(a::Vcat{Int,1,<:Tuple{<:AbstractVector{Int},InfStepRange{Int,Int}}},
823
b::Vcat{Int,1,<:Tuple{<:AbstractVector{Int},InfStepRange{Int,Int}}})
@@ -49,12 +64,11 @@ BroadcastStyle(::Type{<:SubArray{T,N,Arr,<:NTuple{N,BlockSlice{BlockRange{1,Tupl
4964
LazyArrayStyle{N}()
5065

5166
# TODO: generalise following
52-
for Ax in (:(RangeCumsum{Int,OneToInf{Int}}), :(OneToInf{Int}))
53-
@eval begin
54-
BroadcastStyle(::Type{BlockArray{T,N,Arr,NTuple{N,BlockedUnitRange{$Ax}}}}) where {T,N,Arr} = LazyArrayStyle{N}()
55-
BroadcastStyle(::Type{PseudoBlockArray{T,N,Arr,NTuple{N,BlockedUnitRange{$Ax}}}}) where {T,N,Arr} = LazyArrayStyle{N}()
56-
end
57-
end
67+
BroadcastStyle(::Type{<:BlockArray{T,N,<:AbstractArray{<:AbstractArray{T,N},N},<:NTuple{N,BlockedUnitRange{<:InfRanges}}}}) where {T,N} = LazyArrayStyle{N}()
68+
BroadcastStyle(::Type{<:PseudoBlockArray{T,N,<:AbstractArray{T,N},<:NTuple{N,BlockedUnitRange{<:InfRanges}}}}) where {T,N} = LazyArrayStyle{N}()
69+
BroadcastStyle(::Type{<:BlockArray{T,N,<:AbstractArray{<:AbstractArray{T,N},N},<:NTuple{N,BlockedUnitRange{<:RangeCumsum{Int,<:InfRanges}}}}}) where {T,N} = LazyArrayStyle{N}()
70+
BroadcastStyle(::Type{<:PseudoBlockArray{T,N,<:AbstractArray{T,N},<:NTuple{N,BlockedUnitRange{<:RangeCumsum{Int,<:InfRanges}}}}}) where {T,N} = LazyArrayStyle{N}()
71+
5872

5973
BlockArrays._length(::BlockedUnitRange, ::OneToInf) =
6074
BlockArrays._last(::BlockedUnitRange, ::OneToInf) =

test/runtests.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ end
4848
@test blockaxes(b,1) Block.(OneToInf())
4949
@test b[Block(5)] == [1,2]
5050
@test length(axes(b,1)) last(axes(b,1))
51+
@test Base.BroadcastStyle(typeof(b)) isa LazyArrayStyle{1}
5152
end
5253

5354
@testset "1:∞ blocks" begin
@@ -166,6 +167,20 @@ end
166167
@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))
167168
end
168169
end
170+
171+
@testset "blockdiag" begin
172+
D = Diagonal(mortar(Fill.((-(0:∞)-(0:∞).^2), 1:2:∞)))
173+
x = [randn(5); zeros(∞)]
174+
= PseudoBlockArray(x, (axes(D,1),))
175+
@test (D * x)[1:10] == (D * x̃)[1:10]
176+
end
177+
178+
@testset "sortedunion" begin
179+
a = cumsum(1:2:∞)
180+
@test BlockArrays.sortedunion(a,a) a
181+
@test BlockArrays.sortedunion([∞],a) BlockArrays.sortedunion(a,[∞]) a
182+
@test BlockArrays.sortedunion([∞],[∞]) == [∞]
183+
end
169184
end
170185

171186
@testset "∞-Toeplitz and Pert-Toeplitz" begin

0 commit comments

Comments
 (0)