|
1 | | -const OneToInfCumsum = RangeCumsum{Int,OneToInf{Int}} |
2 | | - |
3 | | -BlockArrays.sortedunion(::AbstractVector{<:PosInfinity}, ::AbstractVector{<:PosInfinity}) = [∞] |
4 | | -function BlockArrays.sortedunion(::AbstractVector{<:PosInfinity}, b) |
5 | | - @assert isinf(length(b)) |
6 | | - b |
7 | | -end |
8 | | - |
9 | | -function BlockArrays.sortedunion(b, ::AbstractVector{<:PosInfinity}) |
10 | | - @assert isinf(length(b)) |
11 | | - b |
12 | | -end |
13 | | -BlockArrays.sortedunion(a::OneToInfCumsum, ::OneToInfCumsum) = a |
14 | 1 |
|
15 | 2 | BlockBandedMatrices.blockbanded_colstop(A, x::InfiniteCardinal{0}) = x |
16 | 3 | BlockBandedMatrices.blockbanded_rowstop(A, x::InfiniteCardinal{0}) = x |
17 | 4 |
|
18 | | -BlockArrays.blocklasts(a::InfRanges) = Fill(length(a),1) |
19 | | - |
20 | | -BlockArrays.findblock(::BlockedOneTo, ::RealInfinity) = Block(ℵ₀) |
21 | | - |
22 | | -function BlockArrays.sortedunion(a::Vcat{Int,1,<:Tuple{Union{Int,AbstractVector{Int}},<:AbstractRange}}, |
23 | | - b::Vcat{Int,1,<:Tuple{Union{Int,AbstractVector{Int}},<:AbstractRange}}) |
24 | | - @assert a == b # TODO: generailse? Not sure how to do so in a type stable fashion |
25 | | - a |
26 | | -end |
27 | | - |
28 | | -sizes_from_blocks(A::AbstractVector, ::Tuple{OneToInf{Int}}) = (map(length,A),) |
29 | | -length(::BlockedOneTo{Int,<:InfRanges}) = ℵ₀ |
30 | | - |
31 | | -const OneToInfBlocks = BlockedOneTo{Int,OneToInfCumsum} |
32 | | -const OneToBlocks = BlockedOneTo{Int,OneToCumsum} |
33 | | - |
34 | | -axes(a::OneToInfBlocks) = (a,) |
35 | | -axes(a::OneToBlocks) = (a,) |
36 | | - |
37 | | -LazyBandedMatrices.unitblocks(a::OneToInf) = blockedrange(Ones{Int}(length(a))) |
38 | | - |
39 | | -BlockArrays.dimlength(start, ::Infinity) = ℵ₀ |
40 | | - |
41 | | -function copy(bc::Broadcasted{<:BroadcastStyle,<:Any,typeof(*),<:Tuple{Ones{T,1,Tuple{OneToInfBlocks}},AbstractArray{V,N}}}) where {N,T,V} |
42 | | - a,b = bc.args |
43 | | - @assert bc.axes == axes(b) |
44 | | - convert(AbstractArray{promote_type(T,V),N}, b) |
45 | | -end |
46 | | - |
47 | | -function copy(bc::Broadcasted{<:BroadcastStyle,<:Any,typeof(*),<:Tuple{AbstractArray{T,N},Ones{V,1,Tuple{OneToInfBlocks}}}}) where {N,T,V} |
48 | | - a,b = bc.args |
49 | | - @assert bc.axes == axes(a) |
50 | | - convert(AbstractArray{promote_type(T,V),N}, a) |
51 | | -end |
52 | | - |
53 | | -_block_interlace_axes(::Int, ax::Tuple{BlockedOneTo{Int,OneToInf{Int}}}...) = (blockedrange(Fill(length(ax), ∞)),) |
54 | | - |
55 | | -_block_interlace_axes(nbc::Int, ax::NTuple{2,BlockedOneTo{Int,OneToInf{Int}}}...) = |
56 | | - (blockedrange(Fill(length(ax) ÷ nbc, ∞)),blockedrange(Fill(mod1(length(ax),nbc), ∞))) |
57 | 5 |
|
58 | 6 |
|
59 | 7 | include("infblocktridiagonal.jl") |
60 | 8 |
|
61 | 9 |
|
62 | | -####### |
63 | | -# block broadcasted |
64 | | -###### |
65 | | - |
66 | | - |
67 | | -BroadcastStyle(::Type{<:SubArray{T,N,Arr,<:NTuple{N,BlockSlice{BlockRange{1,Tuple{II}}}},false}}) where {T,N,Arr<:BlockArray,II<:InfRanges} = |
68 | | - LazyArrayStyle{N}() |
69 | | - |
70 | | -# TODO: generalise following |
71 | | -BroadcastStyle(::Type{<:BlockArray{T,N,<:AbstractArray{<:AbstractArray{T,N},N},<:NTuple{N,BlockedOneTo{Int,<:InfRanges}}}}) where {T,N} = LazyArrayStyle{N}() |
72 | | -# BroadcastStyle(::Type{<:BlockedArray{T,N,<:AbstractArray{T,N},<:NTuple{N,BlockedOneTo{Int,<:InfRanges}}}}) where {T,N} = LazyArrayStyle{N}() |
73 | | -BroadcastStyle(::Type{<:BlockArray{T,N,<:AbstractArray{<:AbstractArray{T,N},N},<:NTuple{N,BlockedOneTo{Int,<:RangeCumsum{Int,<:InfRanges}}}}}) where {T,N} = LazyArrayStyle{N}() |
74 | | -# BroadcastStyle(::Type{<:BlockedArray{T,N,<:AbstractArray{T,N},<:NTuple{N,BlockedOneTo{Int,<:RangeCumsum{Int,<:InfRanges}}}}}) where {T,N} = LazyArrayStyle{N}() |
75 | | - |
76 | | - |
77 | | -### |
78 | | -# KronTrav |
79 | | -### |
80 | | - |
81 | | -_krontrav_axes(A::OneToInf{Int}, B::OneToInf{Int}) = blockedrange(oneto(length(A))) |
82 | | - |
83 | | - |
84 | | -struct InfKronTravBandedBlockBandedLayout <: AbstractLazyBandedBlockBandedLayout end |
85 | | -MemoryLayout(::Type{<:KronTrav{<:Any,2,<:Any,NTuple{2,BlockedOneTo{Int,OneToInfCumsum}}}}) = InfKronTravBandedBlockBandedLayout() |
86 | | - |
87 | | -sublayout(::InfKronTravBandedBlockBandedLayout, ::Type{<:NTuple{2,BlockSlice1}}) = BroadcastBandedLayout{typeof(*)}() |
88 | | -sublayout(::InfKronTravBandedBlockBandedLayout, ::Type{<:NTuple{2,BlockSlice{BlockRange{1,Tuple{OneTo{Int}}}}}}) = KronTravBandedBlockBandedLayout() |
89 | | - |
90 | | -copy(M::Mul{InfKronTravBandedBlockBandedLayout, InfKronTravBandedBlockBandedLayout}) = KronTrav((krontravargs(M.A) .* krontravargs(M.B))...) |
91 | | - |
92 | | -_broadcast_sub_arguments(::InfKronTravBandedBlockBandedLayout, M, V) = _broadcast_sub_arguments(KronTravBandedBlockBandedLayout(), M, V) |
0 commit comments