Skip to content

Commit 9ae537f

Browse files
authored
ConstRows and PertConstRows should be lazy (#184)
* ConstRows and PertConstRows should be lazy * Any ∞-banded is lazy
1 parent 20304e2 commit 9ae537f

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
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.8.3"
3+
version = "0.8.4"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/InfiniteLinearAlgebra.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import LazyArrays: AbstractCachedMatrix, AbstractCachedVector, AbstractLazyLayou
4040
CachedArray, CachedLayout, CachedMatrix, CachedVector, LazyArrayStyle, LazyLayout,
4141
LazyLayouts, LazyMatrix, AbstractPaddedLayout, PaddedColumns, _broadcast_sub_arguments,
4242
applybroadcaststyle, applylayout, arguments, cacheddata, paddeddata, resizedata!, simplifiable,
43-
simplify
43+
simplify, islazy, islazy_layout
4444

4545
import LazyBandedMatrices: AbstractLazyBandedBlockBandedLayout, AbstractLazyBandedLayout, ApplyBandedLayout, BlockVec,
4646
BroadcastBandedLayout, KronTravBandedBlockBandedLayout, LazyBandedLayout,

src/banded/infbanded.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ ConstRowMatrix(A::AbstractMatrix{T}) where T = ApplyMatrix(*, A[:,1], Ones{T}(1,
323323
PertConstRowMatrix(A::AbstractMatrix{T}) where T =
324324
Hcat(_pertdata(A), ApplyMatrix(*, _constrows(A), Ones{T}(1,size(A,2))))
325325

326-
struct ConstRows <: MemoryLayout end
327-
struct PertConstRows <: MemoryLayout end
326+
struct ConstRows <: AbstractLazyLayout end
327+
struct PertConstRows <: AbstractLazyLayout end
328328
MemoryLayout(::Type{<:ConstRowMatrix}) = ConstRows()
329329
MemoryLayout(::Type{<:PertConstRowMatrix}) = PertConstRows()
330330
bandedcolumns(::ConstRows) = BandedToeplitzLayout()
@@ -361,6 +361,11 @@ diagonalconstant(A) = getindex_value(diagonaldata(A))
361361
supdiagonalconstant(A) = getindex_value(supdiagonaldata(A))
362362

363363

364+
islazy_layout(::InfToeplitzLayouts) = Val(true)
365+
islazy(::BandedMatrix{<:Any,<:Any,OneToInf{Int}}) = Val(true)
366+
367+
368+
364369
_BandedMatrix(::BandedToeplitzLayout, A::AbstractMatrix) =
365370
_BandedMatrix(ConstRowMatrix(bandeddata(A)), size(A,1), bandwidths(A)...)
366371
_BandedMatrix(::PertToeplitzLayout, A::AbstractMatrix) =

test/test_infbanded.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ using Base: oneto
3434
@testset "∞-Toeplitz" begin
3535
A = BandedMatrix(1 => Fill(2im,∞), 2 => Fill(-1,∞), 3 => Fill(2,∞), -2 => Fill(-4,∞), -3 => Fill(-2im,∞))
3636
@test A isa InfToeplitz
37-
@test MemoryLayout(typeof(A.data)) == ConstRows()
38-
@test MemoryLayout(typeof(A)) == BandedToeplitzLayout()
37+
@test MemoryLayout(A.data) == ConstRows()
38+
@test MemoryLayout(A) == BandedToeplitzLayout()
39+
@test LazyArrays.islazy(A) == Val(true)
40+
3941
V = view(A,:,3:∞)
4042
@test MemoryLayout(typeof(bandeddata(V))) == ConstRows()
4143
@test MemoryLayout(typeof(V)) == BandedToeplitzLayout()
@@ -166,6 +168,7 @@ using Base: oneto
166168

167169
@testset "Banded * PaddedMatrix" begin
168170
A = Eye(∞)[2:∞,:]
171+
@test LazyArrays.islazy(A) == Val(true)
169172
B = PaddedArray(randn(3,3),ℵ₀,ℵ₀)
170173
@test (A*B)[1:10,1:10] A[1:10,1:10] * B[1:10,1:10]
171174
end

0 commit comments

Comments
 (0)