Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "InfiniteArrays"
uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
version = "0.15.10"
version = "0.15.11"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down Expand Up @@ -33,7 +33,7 @@ BlockBandedMatrices = "0.13"
DSP = "0.7, 0.8"
FillArrays = "1.0"
Infinities = "0.1.1"
LazyArrays = "2.2.3"
LazyArrays = "2.9.3"
LinearAlgebra = "1.6"
SparseArrays = "1.0"
Statistics = "1.0"
Expand Down
9 changes: 6 additions & 3 deletions ext/InfiniteArraysBandedMatricesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ using InfiniteArrays, BandedMatrices, LinearAlgebra
using InfiniteArrays.LazyArrays, InfiniteArrays.ArrayLayouts, InfiniteArrays.FillArrays

import Base: BroadcastStyle, size, getindex, similar, copy, *, +, -, /, \, materialize!, copyto!, OneTo
import Base.Broadcast: Broadcasted
import Base.Broadcast: Broadcasted, result_style
import InfiniteArrays: InfIndexRanges, Infinity, PosInfinity, OneToInf, InfAxes, AbstractInfUnitRange, InfRanges, InfBaseToeplitzLayouts, ConstRowMatrix, PertConstRowMatrix, SymTriPertToeplitz, TriPertToeplitz, ConstRows, PertConstRows, PertTridiagonalToeplitzLayout
import ArrayLayouts: sub_materialize, MemoryLayout, sublayout, mulreduce, triangularlayout, MatLdivVec, subdiagonaldata, diagonaldata, supdiagonaldata, OnesLayout, _copy_oftype
import LazyArrays: applybroadcaststyle, applylayout, islazy, islazy_layout, simplifiable, AbstractLazyLayout, PaddedColumns, LazyArrayStyle, ApplyLayout, AbstractLazyBandedLayout, ApplyBandedLayout, BroadcastBandedLayout
import LazyArrays: applybroadcaststyle, applylayout, islazy, islazy_layout, simplifiable, AbstractLazyLayout, PaddedColumns, LazyArrayStyle, ApplyLayout, AbstractLazyBandedLayout, ApplyBandedLayout, BroadcastBandedLayout, CachedArrayStyle, AbstractLazyArrayStyle
import BandedMatrices: _BandedMatrix, AbstractBandedMatrix, banded_similar, BandedMatrix, bandedcolumns, BandedColumns, bandeddata, _default_banded_broadcast
import FillArrays: AbstractFillMatrix, AbstractFill, getindex_value

Expand All @@ -26,9 +26,11 @@ InfBandCartesianIndices(b::Band) = InfBandCartesianIndices(b.i)
size(::InfBandCartesianIndices) = (∞,)
getindex(B::InfBandCartesianIndices, k::Int) = B.b ≥ 0 ? CartesianIndex(k, k+B.b) : CartesianIndex(k-B.b, k)


Base.checkindex(::Type{Bool}, ::NTuple{2,OneToInf{Int}}, ::InfBandCartesianIndices) = true
BandedMatrices.band_to_indices(_, ::NTuple{2,OneToInf{Int}}, b) = (InfBandCartesianIndices(b),)
BroadcastStyle(::Type{<:SubArray{<:Any,1,<:Any,Tuple{InfBandCartesianIndices}}}) = LazyArrayStyle{1}()
_lower_style_dim(::Sty) where {Sty} = Sty(Val(1))
BroadcastStyle(::Type{<:SubArray{<:Any,1,P,Tuple{InfBandCartesianIndices}}}) where {P} = _lower_style_dim(result_style(LazyArrayStyle{1}(), BroadcastStyle(P)))

_inf_banded_sub_materialize(_, V) = V
function _inf_banded_sub_materialize(::BandedColumns, V)
Expand Down Expand Up @@ -296,6 +298,7 @@ for Typ in (:ConstRows, :PertConstRows)
@eval begin
sublayout(::$Typ, ::Type{<:Tuple{Any,AbstractInfUnitRange{Int}}}) = $Typ() # no way to lose const rows
applybroadcaststyle(::Type{<:AbstractMatrix}, ::$Typ) = LazyArrayStyle{2}()
applybroadcaststyle(::Type{<:ApplyMatrix{<:Any, <:Any, Args}}, ::$Typ) where {Args<:Tuple} = LazyArrayStyle{2}() # ambiguity
applylayout(::Type, ::$Typ, _...) = LazyLayout()
end
end
Expand Down
13 changes: 12 additions & 1 deletion test/test_infbanded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import InfiniteArrays: TridiagonalToeplitzLayout, BidiagonalToeplitzLayout, TriP
TriToeplitz, ConstRows, SymTriPertToeplitz, AdjTriPertToeplitz, subdiagonalconstant,
diagonalconstant, supdiagonalconstant, PertTridiagonalToeplitzLayout
using Base: oneto
using LazyArrays: simplifiable, ApplyLayout, BroadcastBandedLayout, islazy
using LazyArrays: simplifiable, ApplyLayout, CachedArrayStyle, LazyArrayStyle, BroadcastBandedLayout, islazy
import Base.Broadcast: BroadcastStyle

const InfiniteArraysBandedMatricesExt = Base.get_extension(InfiniteArrays, :InfiniteArraysBandedMatricesExt)
const InfToeplitz = InfiniteArraysBandedMatricesExt.InfToeplitz
Expand Down Expand Up @@ -40,6 +41,7 @@ const InfBandCartesianIndices = InfiniteArraysBandedMatricesExt.InfBandCartesian
@test (B*A*x)[1:10] == [0; 10; 14; 12; zeros(6)]

@test _BandedMatrix((1:∞)', ∞, -1, 1) isa BandedMatrix

end

@testset "∞-Toeplitz" begin
Expand Down Expand Up @@ -380,4 +382,13 @@ const InfBandCartesianIndices = InfiniteArraysBandedMatricesExt.InfBandCartesian
A = BandedMatrix(1 => Fill(2im,∞), 2 => Fill(-1,∞), 3 => Fill(2,∞), -2 => Fill(-4,∞), -3 => Fill(-2im,∞))
@test copy(Base.broadcasted(BandedMatrices.BandedStyle(), exp,A))[1:10,1:10] == exp.(A[1:10,1:10])
end

@testset "BroadcastStyle with InfBandCartesianIndices" begin
A = BandedMatrix(1 => Fill(2im,∞), 2 => Fill(-1,∞), 3 => Fill(2,∞), -2 => Fill(-4,∞), -3 => Fill(-2im,∞))
B = view(A, band(0))
@test BroadcastStyle(typeof(B)) == LazyArrayStyle{1}()
A = BandedMatrix(1 => Fill(2im,∞), 2 => cache(Fill(-1,∞)), 3 => Fill(2,∞), -2 => Fill(-4,∞), -3 => Fill(-2im,∞))
B = view(A, band(0))
@test BroadcastStyle(typeof(B)) == CachedArrayStyle{1}()
end
end
Loading