Skip to content

Commit 5164ed0

Browse files
authored
Move LazyArrays (#8)
* Update Project.toml * Update Project.toml * Tests pass! * Update Project.toml
1 parent bf95be4 commit 5164ed0

File tree

6 files changed

+36
-22
lines changed

6 files changed

+36
-22
lines changed

Project.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,27 @@ uuid = "cde9dba0-b1de-11e9-2c62-0bab9446c55c"
33
version = "0.0.2"
44

55
[deps]
6+
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
67
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
78
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
89
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
910
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
1011
InfiniteArrays = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
1112
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
13+
LazyBandedMatrices = "d7e5e226-e90b-4449-9968-0f923699bf6f"
1214
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1315
MatrixFactorizations = "a3b82374-2e81-5b9e-98ce-41277c0e4c87"
1416

1517

1618
[compat]
17-
BandedMatrices = "0.13"
19+
ArrayLayouts = "0.1"
20+
BandedMatrices = "0.14"
1821
BlockArrays = "0.10"
19-
BlockBandedMatrices = "0.5.1"
22+
BlockBandedMatrices = "0.6"
2023
FillArrays = "0.8"
2124
InfiniteArrays = "0.4"
22-
LazyArrays = "0.13"
25+
LazyArrays = "0.14.4"
26+
LazyBandedMatrices = "0.0.1"
2327
MatrixFactorizations = "0.2"
2428
julia = "1.2"
2529

src/InfiniteLinearAlgebra.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
module InfiniteLinearAlgebra
2-
using BlockArrays, BlockBandedMatrices, BandedMatrices, LazyArrays, FillArrays, InfiniteArrays, MatrixFactorizations, LinearAlgebra
2+
using BlockArrays, BlockBandedMatrices, BandedMatrices, LazyArrays, LazyBandedMatrices,
3+
FillArrays, InfiniteArrays, MatrixFactorizations, LinearAlgebra
34

45
import Base: +, -, *, /, \, ^, OneTo, getindex, promote_op, _unsafe_getindex, print_matrix_row, size, axes,
56
AbstractMatrix, AbstractArray, Matrix, Array, Vector, AbstractVector, Slice,
67
show, getproperty
78
import Base.Broadcast: BroadcastStyle, Broadcasted
89

9-
import InfiniteArrays: OneToInf, InfUnitRange, Infinity, InfStepRange, AbstractInfUnitRange
10-
import FillArrays: AbstractFill, getindex_value
10+
import ArrayLayouts: colsupport, rowsupport, triangularlayout, MatLdivVec, triangulardata, TriangularLayout, sublayout
1111
import BandedMatrices: BandedMatrix, _BandedMatrix, AbstractBandedMatrix, bandeddata, bandwidths, BandedColumns, bandedcolumns,
1212
_default_banded_broadcast
13+
import FillArrays: AbstractFill, getindex_value
14+
import InfiniteArrays: OneToInf, InfUnitRange, Infinity, InfStepRange, AbstractInfUnitRange
1315
import LinearAlgebra: lmul!, ldiv!, matprod, qr, AbstractTriangular, AbstractQ, adjoint, transpose
1416
import LazyArrays: applybroadcaststyle, CachedArray, CachedMatrix, CachedVector, DenseColumnMajor, FillLayout, ApplyMatrix, check_mul_axes, ApplyStyle, LazyArrayApplyStyle, LazyArrayStyle,
1517
CachedMatrix, CachedArray, resizedata!, MemoryLayout, mulapplystyle, LmulStyle, RmulStyle,
16-
colsupport, rowsupport, triangularlayout, factorize, subarraylayout, sub_materialize, LazyLayout, LazyArrayStyle,
17-
@lazymul, applylayout, ApplyLayout, TriangularLayout, PaddedLayout, materialize!, MatLdivVec, triangulardata
18+
factorize, sub_materialize, LazyLayout, LazyArrayStyle,
19+
@lazymul, applylayout, ApplyLayout, PaddedLayout, materialize!
1820
import MatrixFactorizations: ql, ql!, QLPackedQ, getL, getR, reflector!, reflectorApply!, QL, QR, QRPackedQ
1921

2022
import BlockArrays: BlockSizes, cumulsizes, _find_block, AbstractBlockVecOrMat, sizes_from_blocks
@@ -25,11 +27,12 @@ import BlockBandedMatrices: _BlockSkylineMatrix, _BandedMatrix, AbstractBlockSiz
2527
BlockSkylineSizes, BlockSkylineMatrix, BlockBandedMatrix, _BlockBandedMatrix, BlockTridiagonal
2628

2729

30+
LazyArrays.@lazymul BandedMatrix{<:Any,<:Any,<:OneToInf}
2831

2932

3033
# BroadcastStyle(::Type{<:BandedMatrix{<:Any,<:Any,<:OneToInf}}) = LazyArrayStyle{2}()
3134

32-
^(A::BandedMatrix{T,<:Any,<:OneToInf}, p::Integer) where T =
35+
function ^(A::BandedMatrix{T,<:Any,<:OneToInf}, p::Integer) where T
3336
if p < 0
3437
inv(A)^(-p)
3538
elseif p == 0
@@ -39,7 +42,7 @@ import BlockBandedMatrices: _BlockSkylineMatrix, _BandedMatrix, AbstractBlockSiz
3942
else
4043
A*A^(p-1)
4144
end
42-
45+
end
4346

4447
if VERSION < v"1.2-"
4548
import Base: has_offset_axes

src/banded/hessenbergq.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ check_mul_axes(A::AbstractHessenbergQ, B, C...) =
9393
@lazymul AbstractHessenbergQ
9494

9595
# ambiguities
96-
for Arr in (:AbstractBandedMatrix, :StridedVector, :StridedMatrix)
96+
for Arr in (:AbstractBandedMatrix, :StridedVector, :StridedMatrix, :(BandedMatrix{<:Any,<:Any,<:OneToInf}))
9797
@eval begin
9898
*(A::AbstractHessenbergQ, B::$Arr) = apply(*, A, B)
9999
*(A::$Arr, B::AbstractHessenbergQ) = apply(*, A, B)

src/banded/infbanded.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,11 @@ MemoryLayout(::Type{<:ConstRowMatrix}) = ConstRows()
290290
MemoryLayout(::Type{<:PertConstRowMatrix}) = PertConstRows()
291291
bandedcolumns(::ConstRows) = BandedToeplitzLayout()
292292
bandedcolumns(::PertConstRows) = PertToeplitzLayout()
293-
subarraylayout(::ConstRows, inds...) = subarraylayout(ApplyLayout{typeof(*)}(), inds...)
294-
subarraylayout(::PertConstRows, inds...) = subarraylayout(ApplyLayout{typeof(hcat)}(), inds...)
293+
sublayout(::ConstRows, inds...) = sublayout(ApplyLayout{typeof(*)}(), inds...)
294+
sublayout(::PertConstRows, inds...) = sublayout(ApplyLayout{typeof(hcat)}(), inds...)
295295
for Typ in (:ConstRows, :PertConstRows)
296296
@eval begin
297-
subarraylayout(::$Typ, ::Type{<:Tuple{Any,AbstractInfUnitRange{Int}}}) = $Typ() # no way to lose const rows
297+
sublayout(::$Typ, ::Type{<:Tuple{Any,AbstractInfUnitRange{Int}}}) = $Typ() # no way to lose const rows
298298
applybroadcaststyle(::Type{<:AbstractMatrix}, ::$Typ) = LazyArrayStyle{2}()
299299
applylayout(::Type, ::$Typ, _...) = LazyLayout()
300300
end
@@ -312,10 +312,10 @@ _BandedMatrix(::PertToeplitzLayout, A::AbstractMatrix) =
312312

313313
# for Lay in (:BandedToeplitzLayout, :PertToeplitzLayout)
314314
# @eval begin
315-
# subarraylayout(::$Lay, ::Type{<:Tuple{AbstractInfUnitRange{Int},AbstractInfUnitRange{Int}}}) = $Lay()
316-
# subarraylayout(::$Lay, ::Type{<:Tuple{Slice,AbstractInfUnitRange{Int}}}) = $Lay()
317-
# subarraylayout(::$Lay, ::Type{<:Tuple{AbstractInfUnitRange{Int},Slice}}) = $Lay()
318-
# subarraylayout(::$Lay, ::Type{<:Tuple{Slice,Slice}}) = $Lay()
315+
# sublayout(::$Lay, ::Type{<:Tuple{AbstractInfUnitRange{Int},AbstractInfUnitRange{Int}}}) = $Lay()
316+
# sublayout(::$Lay, ::Type{<:Tuple{Slice,AbstractInfUnitRange{Int}}}) = $Lay()
317+
# sublayout(::$Lay, ::Type{<:Tuple{AbstractInfUnitRange{Int},Slice}}) = $Lay()
318+
# sublayout(::$Lay, ::Type{<:Tuple{Slice,Slice}}) = $Lay()
319319

320320
# sub_materialize(::$Lay, V) = BandedMatrix(V)
321321
# end

test/runtests.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ using InfiniteLinearAlgebra, BlockBandedMatrices, BlockArrays, BandedMatrices, I
22
import InfiniteLinearAlgebra: qltail, toeptail, tailiterate , tailiterate!, tail_de, ql_X!,
33
InfToeplitz, PertToeplitz, TriToeplitz, InfBandedMatrix,
44
rightasymptotics, QLHessenberg, ConstRows, PertConstRows, BandedToeplitzLayout, PertToeplitzLayout
5-
5+
import Base: BroadcastStyle
66
import BlockArrays: _BlockArray
77
import BlockBandedMatrices: isblockbanded, _BlockBandedMatrix
88
import MatrixFactorizations: QLPackedQ
9-
import BandedMatrices: bandeddata, _BandedMatrix
10-
import LazyArrays: colsupport, ApplyStyle, MemoryLayout, ApplyLayout
9+
import BandedMatrices: bandeddata, _BandedMatrix, BandedStyle
10+
import LazyArrays: colsupport, ApplyStyle, MemoryLayout, ApplyLayout, LazyArrayStyle
1111

1212
@testset "∞-Toeplitz and Pert-Toeplitz" begin
1313
A = BandedMatrix(1 => Fill(2im,∞), 2 => Fill(-1,∞), 3 => Fill(2,∞), -2 => Fill(-4,∞), -3 => Fill(-2im,∞))
@@ -106,6 +106,10 @@ end
106106
@test Eye(∞) * A isa BandedMatrix
107107
@test A * Eye(∞) isa BandedMatrix
108108
b = 1:
109+
@test BroadcastStyle(typeof(b)) isa LazyArrayStyle{1}
110+
@test BroadcastStyle(typeof(A)) isa BandedStyle
111+
@test BroadcastStyle(LazyArrayStyle{1}(), BandedStyle()) isa LazyArrayStyle{2}
112+
@test BroadcastStyle(LazyArrayStyle{2}(), BandedStyle()) isa LazyArrayStyle{2}
109113
@test bandwidths(b .* A) == (0,1)
110114

111115
@test colsupport(b.*A, 1) == 1:1

test/test_infqr.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using InfiniteLinearAlgebra, LinearAlgebra, BandedMatrices, InfiniteArrays, MatrixFactorizations, LazyArrays, FillArrays, SpecialFunctions
1+
using InfiniteLinearAlgebra, LinearAlgebra, BandedMatrices, InfiniteArrays, MatrixFactorizations, LazyArrays, FillArrays, SpecialFunctions, Test
22
import LazyArrays: colsupport, rowsupport, MemoryLayout, DenseColumnMajor, TriangularLayout, resizedata!
3+
import LazyBandedMatrices: BroadcastBandedLayout
34
import BandedMatrices: _BandedMatrix, _banded_qr!, BandedColumns
45
import InfiniteLinearAlgebra: partialqr!, AdaptiveQRData, AdaptiveLayout
56

@@ -109,6 +110,8 @@ import InfiniteLinearAlgebra: partialqr!, AdaptiveQRData, AdaptiveLayout
109110
B = BandedMatrix(-2 => Ones(∞), -1 => Vcat(1, Zeros(∞)), 0 => Vcat([1,2,3],Zeros(∞)).+3, 1 => Vcat(1, Zeros(∞)), 2 => Ones(∞))
110111

111112
AB = BroadcastArray(+,A,B)
113+
@test MemoryLayout(typeof(AB)) isa BroadcastBandedLayout{typeof(+)}
114+
112115
C = cache(AB);
113116
resizedata!(C,103,100); resizedata!(C,203,200);
114117
@test C[103,104] 1.0

0 commit comments

Comments
 (0)