Skip to content

Commit be01617

Browse files
authored
Dl/newblockarrays (#12)
* update for new block arrays * tests pass! * Block memory layouts * CumsumBlockRange -> BlockedUnitRange * some fixes for tests * Update InfiniteLinearAlgebra.jl * sortedunion for block arrays * LazyBandedMatrices v0.2 * Update Project.toml * Update .travis.yml * updates for new LazyArrays * Increase coverage
1 parent f9755c1 commit be01617

File tree

10 files changed

+164
-67
lines changed

10 files changed

+164
-67
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.jl.mem
44
deps/deps.jl
55
.DS_Store
6+
Manifest.toml

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ os:
55
- osx
66
- windows
77
julia:
8-
- 1.2
98
- 1.3
109
- nightly
1110
matrix:

Project.toml

Lines changed: 8 additions & 8 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.1.2"
3+
version = "0.2.0"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -17,14 +17,14 @@ MatrixFactorizations = "a3b82374-2e81-5b9e-98ce-41277c0e4c87"
1717
[compat]
1818
ArrayLayouts = "0.1"
1919
BandedMatrices = "0.14"
20-
BlockArrays = "0.10"
21-
BlockBandedMatrices = "0.6"
22-
FillArrays = "0.8"
23-
InfiniteArrays = "0.4, 0.5"
24-
LazyArrays = "0.14.4, 0.15"
25-
LazyBandedMatrices = "0.0.1, 0.0.2, 0.0.3, 0.1"
20+
BlockArrays = "0.11"
21+
BlockBandedMatrices = "0.7.1"
22+
FillArrays = "0.8.4"
23+
InfiniteArrays = "0.6.1"
24+
LazyArrays = "0.15"
25+
LazyBandedMatrices = "0.2"
2626
MatrixFactorizations = "0.2"
27-
julia = "1.2"
27+
julia = "1.3"
2828

2929
[extras]
3030
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

src/InfiniteLinearAlgebra.jl

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
module InfiniteLinearAlgebra
22
using BlockArrays, BlockBandedMatrices, BandedMatrices, LazyArrays, LazyBandedMatrices,
3-
FillArrays, InfiniteArrays, MatrixFactorizations, LinearAlgebra
3+
FillArrays, InfiniteArrays, MatrixFactorizations, ArrayLayouts, LinearAlgebra
44

55
import Base: +, -, *, /, \, ^, OneTo, getindex, promote_op, _unsafe_getindex, print_matrix_row, size, axes,
66
AbstractMatrix, AbstractArray, Matrix, Array, Vector, AbstractVector, Slice,
7-
show, getproperty
8-
import Base.Broadcast: BroadcastStyle, Broadcasted
7+
show, getproperty, copy, map
8+
import Base.Broadcast: BroadcastStyle, Broadcasted, broadcasted
99

1010
import ArrayLayouts: colsupport, rowsupport, triangularlayout, MatLdivVec, triangulardata, TriangularLayout, sublayout
1111
import BandedMatrices: BandedMatrix, _BandedMatrix, AbstractBandedMatrix, bandeddata, bandwidths, BandedColumns, bandedcolumns,
1212
_default_banded_broadcast
1313
import FillArrays: AbstractFill, getindex_value
14-
import InfiniteArrays: OneToInf, InfUnitRange, Infinity, InfStepRange, AbstractInfUnitRange
14+
import InfiniteArrays: OneToInf, InfUnitRange, Infinity, InfStepRange, AbstractInfUnitRange, InfAxes
1515
import LinearAlgebra: lmul!, ldiv!, matprod, qr, AbstractTriangular, AbstractQ, adjoint, transpose
1616
import LazyArrays: applybroadcaststyle, CachedArray, CachedMatrix, CachedVector, DenseColumnMajor, FillLayout, ApplyMatrix, check_mul_axes, ApplyStyle, LazyArrayApplyStyle, LazyArrayStyle,
17-
CachedMatrix, CachedArray, resizedata!, MemoryLayout, mulapplystyle, LmulStyle, RmulStyle,
18-
factorize, sub_materialize, LazyLayout, LazyArrayStyle,
19-
@lazymul, applylayout, ApplyLayout, PaddedLayout, materialize!, zero!
17+
resizedata!, MemoryLayout, mulapplystyle, LmulStyle, RmulStyle,
18+
factorize, sub_materialize, LazyLayout, LazyArrayStyle, lazy_getindex,
19+
@lazymul, applylayout, ApplyLayout, PaddedLayout, materialize!, zero!, MulAddStyle,
20+
LazyArray, LazyMatrix, LazyVector
2021
import MatrixFactorizations: ql, ql!, QLPackedQ, getL, getR, reflector!, reflectorApply!, QL, QR, QRPackedQ
2122

22-
import BlockArrays: BlockSizes, cumulsizes, _find_block, AbstractBlockVecOrMat, sizes_from_blocks
23+
import BlockArrays: AbstractBlockVecOrMat, sizes_from_blocks, _length, BlockedUnitRange
2324

2425
import BandedMatrices: BandedMatrix, bandwidths, AbstractBandedLayout, _banded_qr!, _banded_qr, _BandedMatrix
2526

26-
import BlockBandedMatrices: _BlockSkylineMatrix, _BandedMatrix, AbstractBlockSizes, cumulsizes, _BlockSkylineMatrix, BlockSizes, blockstart, blockstride,
27+
import LazyBandedMatrices: MulBandedLayout, BroadcastBandedLayout
28+
29+
import BlockBandedMatrices: _BlockSkylineMatrix, _BandedMatrix, _BlockSkylineMatrix, blockstart, blockstride,
2730
BlockSkylineSizes, BlockSkylineMatrix, BlockBandedMatrix, _BlockBandedMatrix, BlockTridiagonal
2831

2932

3033
LazyArrays.@lazymul BandedMatrix{<:Any,<:Any,<:OneToInf}
34+
*(A::BandedMatrix{<:Any,<:Any,<:OneToInf}, b::CachedVector) = apply(*,A,b)
3135

3236

3337
# BroadcastStyle(::Type{<:BandedMatrix{<:Any,<:Any,<:OneToInf}}) = LazyArrayStyle{2}()
@@ -56,7 +60,7 @@ export Vcat, Fill, ql, ql!, ∞, ContinuousSpectrumError, BlockTridiagonal
5660
include("banded/hessenbergq.jl")
5761

5862
include("banded/infbanded.jl")
59-
include("blockbanded/infblocktridiagonal.jl")
63+
include("blockbanded/blockbanded.jl")
6064
include("banded/infqltoeplitz.jl")
6165
include("infql.jl")
6266
include("infqr.jl")
@@ -80,4 +84,28 @@ ApplyStyle(::typeof(*), ::Type{<:Adjoint{<:Any,<:BandedMatrix{<:Any,<:Any,<:OneT
8084
LazyArrayApplyStyle()
8185
ApplyStyle(::typeof(*), ::Type{<:Transpose{<:Any,<:BandedMatrix{<:Any,<:Any,<:OneToInf}}}, ::Type{<:AbstractArray}) =
8286
LazyArrayApplyStyle()
87+
88+
ApplyStyle(::typeof(*), ::Type{<:BandedMatrix{<:Any,<:AbstractFill,<:OneToInf}}, ::Type{<:BandedMatrix{<:Any,<:AbstractFill,<:OneToInf}}) =
89+
MulAddStyle()
90+
91+
#######
92+
# block broadcasted
93+
######
94+
95+
const CumsumOneToInf2 = BroadcastArray{Int64,1,typeof(div),Tuple{BroadcastArray{Int64,1,typeof(*),Tuple{InfiniteArrays.OneToInf{Int64},InfiniteArrays.InfUnitRange{Int64}}},Int64}}
96+
BlockArrays.sortedunion(a::CumsumOneToInf2, ::CumsumOneToInf2) = a
97+
98+
99+
map(::typeof(length), A::BroadcastArray{OneTo{Int},1,Type{OneTo}}) = A.args[1]
100+
map(::typeof(length), A::BroadcastArray{<:Fill,1,Type{Fill}}) = A.args[2]
101+
map(::typeof(length), A::BroadcastArray{<:Zeros,1,Type{Zeros}}) = A.args[1]
102+
map(::typeof(length), A::BroadcastArray{<:Vcat,1,Type{Vcat}}) = broadcast(+,map.(length,A.args)...)
103+
broadcasted(::LazyArrayStyle{1}, ::typeof(length), A::BroadcastArray{OneTo{Int},1,Type{OneTo}}) =
104+
A.args[1]
105+
broadcasted(::LazyArrayStyle{1}, ::typeof(length), A::BroadcastArray{<:Fill,1,Type{Fill}}) =
106+
A.args[2]
107+
108+
BlockArrays._length(::BlockedUnitRange, ::OneToInf) =
109+
BlockArrays._last(::BlockedUnitRange, ::OneToInf) =
110+
83111
end # module

src/banded/infbanded.jl

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
###
2+
# Diagonal
3+
###
4+
5+
getindex(D::Diagonal, k::InfAxes, j::InfAxes) = lazy_getindex(D, k, j)
6+
17
const TriToeplitz{T} = Tridiagonal{T,Fill{T,1,Tuple{OneToInf{Int}}}}
28
const ConstRowMatrix{T} = ApplyMatrix{T,typeof(*),<:Tuple{<:AbstractVector,<:AbstractFill{<:Any,2,Tuple{OneTo{Int},OneToInf{Int}}}}}
39
const PertConstRowMatrix{T} = Hcat{T,<:Tuple{Array{T},<:ConstRowMatrix{T}}}
@@ -322,6 +328,12 @@ _BandedMatrix(::PertToeplitzLayout, A::AbstractMatrix) =
322328
# end
323329

324330

331+
@inline sub_materialize(::MulBandedLayout, V, ::Tuple{InfAxes,InfAxes}) = V
332+
@inline sub_materialize(::BroadcastBandedLayout, V, ::Tuple{InfAxes,InfAxes}) = V
333+
@inline sub_materialize(::AbstractBandedLayout, V, ::Tuple{InfAxes,InfAxes}) = BandedMatrix(V)
334+
@inline sub_materialize(::BandedColumns, V, ::Tuple{InfAxes,InfAxes}) = BandedMatrix(V)
335+
336+
325337
##
326338
# UniformScaling
327339
##
@@ -335,4 +347,25 @@ for op in (:+, :-), Typ in (:(BandedMatrix{<:Any,<:Any,OneToInf{Int}}),
335347
end
336348
end
337349

338-
_default_banded_broadcast(bc::Broadcasted, ::Tuple{<:OneToInf,<:Any}) = copy(Broadcasted{LazyArrayStyle{2}}(bc.f, bc.args))
350+
_default_banded_broadcast(bc::Broadcasted, ::Tuple{<:OneToInf,<:Any}) = copy(Broadcasted{LazyArrayStyle{2}}(bc.f, bc.args))
351+
352+
353+
###
354+
# BandedFill * BandedFill
355+
###
356+
357+
copy(M::MulAdd{BandedMatrices.BandedColumns{FillLayout},BandedMatrices.BandedColumns{FillLayout},ZerosLayout}) =
358+
_bandedfill_mul(M, axes(M.A), axes(M.B))
359+
360+
_bandedfill_mul(M, _, _) = copyto!(similar(M), M)
361+
function _bandedfill_mul(M::MulAdd, ::Tuple{InfAxes,InfAxes}, ::Tuple{InfAxes,InfAxes})
362+
A, B = M.A, M.B
363+
Al,Au = bandwidths(A)
364+
Bl,Bu = bandwidths(B)
365+
l,u = Al+Bl,Au+Bu
366+
m = min(Au+Al,Bl+Bu)+1
367+
λ = getindex_value(bandeddata(A))*getindex_value(bandeddata(B))
368+
ret = _BandedMatrix(Hcat(Array{typeof(λ)}(undef, l+u+1,u), [1:m-1; Fill(m,l+u-2m+3); m-1:-1:1]*Fill(λ,1,∞)), ∞, l, u)
369+
mul!(view(ret, 1:l+u,1:u), view(A,1:l+u,1:u+Bl), view(B,1:u+Bl,1:u))
370+
ret
371+
end

src/blockbanded/blockbanded.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
sizes_from_blocks(A::AbstractVector, ::Tuple{OneToInf{Int}}) = (map(length,A),)
2+
3+
4+
5+
MemoryLayout(::Type{<:PseudoBlockArray{<:Any,N,<:Arr}}) where {N,Arr} =
6+
MemoryLayout(Arr)
7+
8+
struct BlockLayout{LAY} <: MemoryLayout end
9+
10+
MemoryLayout(::Type{<:BlockArray{<:Any,N,<:Arr}}) where {N,Arr} =
11+
blocklayout(MemoryLayout(Arr))
12+
13+
blocklayout(_) = BlockLayout{UnknownLayout}()
14+
blocklayout(::LazyLayout) = BlockLayout{LazyLayout}()
15+
16+
# for LazyLay in (:(BlockLayout{LazyLayout}), :(TriangularLayout{UPLO,UNIT,BlockLayout{LazyLayout}} where {UPLO,UNIT}))
17+
# @eval begin
18+
# combine_mul_styles(::$LazyLay) = LazyArrayApplyStyle()
19+
# mulapplystyle(::QLayout, ::$LazyLay) = LazyArrayApplyStyle()
20+
# end
21+
# end
22+
23+
# BlockArrays.blockbroadcaststyle(::LazyArrayStyle{N}) where N = LazyArrayStyle{N}()
24+
25+
26+
include("infblocktridiagonal.jl")
27+

src/blockbanded/infblocktridiagonal.jl

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const BlockTriPertToeplitz{T} = BlockMatrix{T,Tridiagonal{Matrix{T},Vcat{Matrix{T},1,Tuple{Vector{Matrix{T}},Fill{Matrix{T},1,Tuple{OneToInf{Int}}}}}},
2-
BlockSizes{2,NTuple{2,Vcat{Int,1,Tuple{Int,Vcat{Int,1,Tuple{Vector{Int},InfStepRange{Int,Int}}}}}}}}
2+
NTuple{2,BlockedUnitRange{Vcat{Int,1,Tuple{Vector{Int},InfStepRange{Int,Int}}}}}}
33

44

55
function BlockTridiagonal(adjA::Adjoint{T,BlockTriPertToeplitz{T}}) where T
@@ -30,36 +30,9 @@ end
3030

3131
*(a::AbstractVector, b::AbstractFill{<:Any,2,Tuple{OneTo{Int},OneToInf{Int}}}) = ApplyArray(*,a,b)
3232

33+
sizes_from_blocks(A::Diagonal, ::NTuple{2,OneToInf{Int}}) = size.(A.diag, 1), size.(A.diag,2)
3334

34-
sizes_from_blocks(A::AbstractVector, ::Tuple{OneToInf{Int}}) = BlockSizes((Vcat(1, 1 .+ cumsum(length.(A))),))
35-
function sizes_from_blocks(A::AbstractMatrix, ::Tuple{OneTo{Int}, OneToInf{Int}})
36-
@assert size(A,1) == 1
37-
R,C = vec(size.(A,1)[:,1]), vec(size.(A,2))
38-
BlockSizes((vcat(1, 1 .+ cumsum(R)), Vcat(1, 1 .+ cumsum(C))))
39-
end
40-
41-
function sizes_from_blocks(A::Diagonal, ::NTuple{2,OneToInf{Int}})
42-
sz = size.(A.diag, 1), size.(A.diag,2)
43-
BlockSizes(Vcat.(1,(c -> 1 .+ c).(cumsum.(sz))))
44-
end
45-
46-
function sizes_from_blocks(A::Tridiagonal, ::NTuple{2,OneToInf{Int}})
47-
sz = size.(A.d, 1), size.(A.d,2)
48-
BlockSizes(Vcat.(1,(c -> 1 .+ c).(cumsum.(sz))))
49-
end
50-
51-
_find_block(cs::Number, i::Integer) = i  cs ? 1 : 0
52-
function _find_block(cs::Vcat, i::Integer)
53-
n = 0
54-
for a in cs.args
55-
i < first(a) && return n
56-
if i  last(a)
57-
return _find_block(a, i) + n
58-
end
59-
n += length(a)
60-
end
61-
return 0
62-
end
35+
sizes_from_blocks(A::Tridiagonal, ::NTuple{2,OneToInf{Int}}) = size.(A.d, 1), size.(A.d,2)
6336

6437
print_matrix_row(io::IO,
6538
X::AbstractBlockVecOrMat, A::Vector,
@@ -98,7 +71,7 @@ function BlockSkylineSizes(A::BlockTriPertToeplitz, (l,u)::NTuple{2,Int})
9871
bs∞[k] = bs∞[k-1] .+ size(A[Block(N+1-u+k-1,N+1)],1)
9972
end
10073

101-
BlockSkylineSizes(blocksizes(A),
74+
BlockSkylineSizes(axes(A),
10275
_BandedMatrix(Hcat(block_starts.data, Vcat(adjoint.(bs∞)...)), ∞, l, u),
10376
Vcat(block_strides, Fill(block_stride∞,∞)),
10477
Fill(l,∞),Fill(u,∞))

src/infql.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,15 @@ function lmul!(adjA::Adjoint{<:Any,<:QLPackedQ{<:Any,<:InfBandedMatrix}}, B::Abs
175175
B
176176
end
177177

178-
function (*)(A::QLPackedQ{T,<:InfBandedMatrix}, x::AbstractVector{S}) where {T,S}
178+
function _lmul_cache(A::AbstractMatrix{T}, x::AbstractVector{S}) where {T,S}
179179
TS = promote_op(matprod, T, S)
180180
lmul!(A, cache(convert(AbstractVector{TS},x)))
181-
end
182-
183-
function (*)(A::Adjoint{T,<:QLPackedQ{T,<:InfBandedMatrix}}, x::AbstractVector{S}) where {T,S}
184-
TS = promote_op(matprod, T, S)
185-
lmul!(A, cache(convert(AbstractVector{TS},x)))
186-
end
181+
end
187182

183+
(*)(A::QLPackedQ{T,<:InfBandedMatrix}, x::AbstractVector) where {T} = _lmul_cache(A, x)
184+
(*)(A::Adjoint{T,<:QLPackedQ{T,<:InfBandedMatrix}}, x::AbstractVector) where {T} = _lmul_cache(A, x)
185+
(*)(A::QLPackedQ{T,<:InfBandedMatrix}, x::LazyVector) where {T} = _lmul_cache(A, x)
186+
(*)(A::Adjoint{T,<:QLPackedQ{T,<:InfBandedMatrix}}, x::LazyVector) where {T} = _lmul_cache(A, x)
188187

189188

190189
function blocktailiterate(c,a,b, d=c, e=a)

src/infqr.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,16 @@ function lmul!(adjA::Adjoint{<:Any,<:QRPackedQ{<:Any,<:AdaptiveQRFactors}}, B::C
158158
B
159159
end
160160

161-
function (*)(A::QRPackedQ{T,<:AdaptiveQRFactors}, x::AbstractVector{S}) where {T,S}
161+
function _lmul_copymutable(A::AbstractMatrix{T}, x::AbstractVector{S}) where {T,S}
162162
TS = promote_op(matprod, T, S)
163163
lmul!(A, Base.copymutable(convert(AbstractVector{TS},x)))
164164
end
165165

166-
function (*)(A::Adjoint{T,<:QRPackedQ{T,<:AdaptiveQRFactors}}, x::AbstractVector{S}) where {T,S}
167-
TS = promote_op(matprod, T, S)
168-
lmul!(A, Base.copymutable(convert(AbstractVector{TS},x)))
169-
end
166+
(*)(A::QRPackedQ{T,<:AdaptiveQRFactors}, x::AbstractVector) where {T} = _lmul_copymutable(A, x)
167+
(*)(A::Adjoint{T,<:QRPackedQ{T,<:AdaptiveQRFactors}}, x::AbstractVector) where {T} = _lmul_copymutable(A, x)
168+
(*)(A::QRPackedQ{T,<:AdaptiveQRFactors}, x::LazyVector) where {T} = _lmul_copymutable(A, x)
169+
(*)(A::Adjoint{T,<:QRPackedQ{T,<:AdaptiveQRFactors}}, x::LazyVector) where {T} = _lmul_copymutable(A, x)
170+
170171

171172
function ldiv!(R::UpperTriangular{<:Any,<:AdaptiveQRFactors}, B::CachedVector{<:Any,<:Any,<:Zeros{<:Any,1}})
172173
n = B.datasize[1]

test/runtests.jl

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using InfiniteLinearAlgebra, BlockBandedMatrices, BlockArrays, BandedMatrices, InfiniteArrays, FillArrays, LazyArrays, Test, MatrixFactorizations, LinearAlgebra, Random
1+
using InfiniteLinearAlgebra, BlockBandedMatrices, BlockArrays, BandedMatrices, InfiniteArrays, FillArrays, LazyArrays, Test, MatrixFactorizations, ArrayLayouts, LinearAlgebra, Random
22
import InfiniteLinearAlgebra: qltail, toeptail, tailiterate , tailiterate!, tail_de, ql_X!,
33
InfToeplitz, PertToeplitz, TriToeplitz, InfBandedMatrix,
44
rightasymptotics, QLHessenberg, ConstRows, PertConstRows, BandedToeplitzLayout, PertToeplitzLayout
@@ -8,6 +8,26 @@ import BlockBandedMatrices: isblockbanded, _BlockBandedMatrix
88
import MatrixFactorizations: QLPackedQ
99
import BandedMatrices: bandeddata, _BandedMatrix, BandedStyle
1010
import LazyArrays: colsupport, ApplyStyle, MemoryLayout, ApplyLayout, LazyArrayStyle
11+
import InfiniteArrays: OneToInf
12+
13+
@testset "∞-banded" begin
14+
D = Diagonal(Fill(2,∞))
15+
B = D[1:∞,2:∞]
16+
@test B isa BandedMatrix
17+
@test B[1:10,1:10] == diagm(-1 => Fill(2,9))
18+
@test B[1:∞,2:∞] isa BandedMatrix
19+
end
20+
21+
@testset "∞-block arrays" begin
22+
k = Base.OneTo.(Base.OneTo(∞))
23+
n = Fill.(Base.OneTo(∞),Base.OneTo(∞))
24+
@test broadcast(length,k) == map(length,k) == OneToInf()
25+
@test broadcast(length,n) == map(length,n) == OneToInf()
26+
b = mortar(Fill([1,2],∞))
27+
@test blockaxes(b,1) === Block.(OneToInf())
28+
@test b[Block(5)] == [1,2]
29+
@test length(axes(b,1)) == last(axes(b,1)) ==
30+
end
1131

1232
@testset "∞-Toeplitz and Pert-Toeplitz" begin
1333
A = BandedMatrix(1 => Fill(2im,∞), 2 => Fill(-1,∞), 3 => Fill(2,∞), -2 => Fill(-4,∞), -3 => Fill(-2im,∞))
@@ -28,6 +48,15 @@ import LazyArrays: colsupport, ApplyStyle, MemoryLayout, ApplyLayout, LazyArrayS
2848
@test MemoryLayout(typeof(V)) == PertToeplitzLayout()
2949
@test BandedMatrix(V) isa PertToeplitz
3050
@test A[2:∞,2:∞] isa PertToeplitz
51+
52+
@testset "InfBanded" begin
53+
A = _BandedMatrix(Fill(2,4,∞),∞,2,1)
54+
B = _BandedMatrix(Fill(3,2,∞),∞,-1,2)
55+
@test mul(A,A) isa PertToeplitz
56+
@test A*A isa PertToeplitz
57+
@test (A*A)[1:20,1:20] == A[1:20,1:23]*A[1:23,1:20]
58+
@test (A*B)[1:20,1:20] == A[1:20,1:23]*B[1:23,1:20]
59+
end
3160
end
3261

3362

@@ -60,7 +89,7 @@ end
6089
@test At[1:10,1:10] transpose(A)[1:10,1:10] transpose(A[1:10,1:10])
6190

6291
A = _BandedMatrix(Fill(1,4,∞),∞,1,2)
63-
@test A*A isa ApplyArray
92+
@test A*A isa BandedMatrix
6493
@test (A^2)[1:10,1:10] == (A*A)[1:10,1:10] == (A[1:100,1:100]^2)[1:10,1:10]
6594
@test (A^3)[1:10,1:10] == (A*A*A)[1:10,1:10] == (A[1:100,1:100]^3)[1:10,1:10]
6695
end
@@ -82,7 +111,6 @@ end
82111
@test (I + A)[1:100,1:100] == I+A[1:100,1:100]
83112
@test (I - A)[1:100,1:100] == I-A[1:100,1:100]
84113
end
85-
86114

87115
@testset "Fill" begin
88116
A = _BandedMatrix(Ones(1,∞),∞,-1,1)
@@ -127,7 +155,15 @@ end
127155
end
128156

129157
@testset "Triangle OP recurrences" begin
130-
# mortar((n -> 1:n).(1:∞))
158+
k = mortar(Base.OneTo.(1:∞))
159+
n = mortar(Fill.(1:∞, 1:∞))
160+
@test k[Block.(2:3)] isa BlockArray
161+
@test n[Block.(2:3)] isa BlockArray
162+
@test k[Block.(2:3)] == [1,2,1,2,3]
163+
@test n[Block.(2:3)] == [2,2,3,3,3]
164+
@test blocksize(BroadcastVector(exp,k)) == (∞,)
165+
@test BroadcastVector(exp,k)[Block.(2:3)] == exp.([1,2,1,2,3])
166+
# BroadcastVector(+,k,n)
131167
end
132168
# Multivariate OPs Corollary (3)
133169
# n = 5

0 commit comments

Comments
 (0)