diff --git a/ext/LazyArraysBandedMatricesExt.jl b/ext/LazyArraysBandedMatricesExt.jl index e596b2c6..2ac44f35 100644 --- a/ext/LazyArraysBandedMatricesExt.jl +++ b/ext/LazyArraysBandedMatricesExt.jl @@ -7,10 +7,11 @@ import ArrayLayouts: colsupport, rowsupport, materialize!, MatMulVecAdd, MatMulM layout_getindex, transtype import LazyArrays: sublayout, symmetriclayout, hermitianlayout, applylayout, cachedlayout, transposelayout, LazyArrayStyle, ApplyArrayBroadcastStyle, AbstractInvLayout, AbstractLazyLayout, LazyLayouts, - AbstractPaddedLayout, PaddedLayout, PaddedRows, PaddedColumns, CachedArray, CachedMatrix, LazyLayout, BroadcastLayout, ApplyLayout, + AbstractPaddedLayout, PaddedLayout, AbstractLazyBandedLayout, LazyBandedLayout, PaddedRows, + PaddedColumns, CachedArray, CachedMatrix, LazyLayout, BroadcastLayout, ApplyLayout, paddeddata, resizedata!, broadcastlayout, _broadcastarray2broadcasted, _broadcast_sub_arguments, arguments, call, applybroadcaststyle, simplify, simplifiable, islazy_layout, lazymaterialize, _broadcast_mul_mul, - triangularlayout, AbstractCachedMatrix + triangularlayout, AbstractCachedMatrix, _mulbanded_copyto! import Base: BroadcastStyle, similar, copy, broadcasted, getindex, OneTo, oneto, tail, sign, abs import BandedMatrices: bandedbroadcaststyle, bandwidths, isbanded, bandedcolumns, bandeddata, BandedStyle, AbstractBandedLayout, AbstractBandedMatrix, BandedColumns, BandedRows, BandedSubBandedMatrix, @@ -18,9 +19,6 @@ import BandedMatrices: bandedbroadcaststyle, bandwidths, isbanded, bandedcolumns resize import LinearAlgebra: AdjOrTrans, UpperOrLowerTriangular, kron -abstract type AbstractLazyBandedLayout <: AbstractBandedLayout end -struct LazyBandedLayout <: AbstractLazyBandedLayout end - symmetriclayout(::AbstractLazyBandedLayout) = SymmetricLayout{LazyBandedLayout}() hermitianlayout(::Type{<:Real}, ::AbstractLazyBandedLayout) = SymmetricLayout{LazyBandedLayout}() hermitianlayout(::Type{<:Complex}, ::AbstractLazyBandedLayout) = HermitianLayout{LazyBandedLayout}() @@ -257,10 +255,7 @@ BroadcastLayout(::BroadcastBandedLayout{F}) where F = BroadcastLayout{F}() # functions that satisfy f(0,0) == 0 - -const _ZERO_OPS = (:*, :-, :+, :sign, :abs) - -for op in _ZERO_OPS +for op in (:*, :-, :+, :sign, :abs) @eval broadcastlayout(::Type{typeof($op)}, ::BandedLayouts) = BroadcastBandedLayout{typeof($op)}() end diff --git a/ext/LazyArraysBlockBandedMatricesExt.jl b/ext/LazyArraysBlockBandedMatricesExt.jl index 659ac100..39bf01c0 100644 --- a/ext/LazyArraysBlockBandedMatricesExt.jl +++ b/ext/LazyArraysBlockBandedMatricesExt.jl @@ -11,8 +11,8 @@ import LazyArrays: sublayout, symmetriclayout, hermitianlayout, transposelayout, islazy_layout, arguments, call, applylayout, broadcastlayout, applybroadcaststyle, BroadcastMatrix, _broadcastarray2broadcasted, _cache, resizedata!, simplifiable, AbstractLazyLayout, LazyArrayStyle, LazyLayout, ApplyLayout, BroadcastLayout, AbstractInvLayout, - _mul_args_colsupport, _mul_args_rowsupport, _mat_mul_arguments, - CachedArray, _broadcast_sub_arguments, simplify, lazymaterialize + _mul_args_colsupport, _mul_args_rowsupport, _mat_mul_arguments, LazyBandedLayout, + CachedArray, _broadcast_sub_arguments, simplify, lazymaterialize, _mulbanded_copyto! import BlockBandedMatrices: AbstractBlockBandedLayout, AbstractBandedBlockBandedLayout, blockbandwidths, subblockbandwidths, bandedblockbandedbroadcaststyle, bandedblockbandedcolumns, BandedBlockBandedColumns, BandedBlockBandedRows, BlockRange1, Block1, BlockIndexRange1, BlockBandedColumns, BlockBandedRows, BandedBlockBandedLayout @@ -22,11 +22,6 @@ import Base: similar, copy, broadcasted import ArrayLayouts: materialize!, MatMulVecAdd, sublayout, colsupport, rowsupport, copyto!_layout, mulreduce, inv_layout, OnesLayout, AbstractFillLayout -const LazyArraysBandedMatricesExt = Base.get_extension(LazyArrays, :LazyArraysBandedMatricesExt) -const LazyBandedLayout = LazyArraysBandedMatricesExt.LazyBandedLayout -const _mulbanded_copyto! = LazyArraysBandedMatricesExt._mulbanded_copyto! - - abstract type AbstractLazyBlockBandedLayout <: AbstractBlockBandedLayout end abstract type AbstractLazyBandedBlockBandedLayout <: AbstractBandedBlockBandedLayout end @@ -157,7 +152,8 @@ const BroadcastBlockBandedLayouts{F} = Union{BroadcastBlockBandedLayout{F},Broad blockbandwidths(B::BroadcastMatrix) = blockbandwidths(broadcasted(B)) subblockbandwidths(B::BroadcastMatrix) = subblockbandwidths(broadcasted(B)) -for op in LazyArraysBandedMatricesExt._ZERO_OPS +# functions that satisfy f(0,0) == 0 +for op in (:*, :-, :+, :sign, :abs) @eval begin broadcastlayout(::Type{typeof($op)}, ::BlockBandedLayouts) = BroadcastBlockBandedLayout{typeof($op)}() broadcastlayout(::Type{typeof($op)}, ::BandedBlockBandedLayouts) = BroadcastBandedBlockBandedLayout{typeof($op)}() diff --git a/src/LazyArrays.jl b/src/LazyArrays.jl index 008a627e..47c23a18 100644 --- a/src/LazyArrays.jl +++ b/src/LazyArrays.jl @@ -71,6 +71,12 @@ map(::typeof(length), A::BroadcastVector{<:Vcat,Type{Vcat}}) = broadcast(+,map.( broadcasted(::LazyArrayStyle{1}, ::typeof(length), A::BroadcastVector{OneTo{Int},Type{OneTo}}) = A.args[1] broadcasted(::LazyArrayStyle{1}, ::typeof(length), A::BroadcastVector{<:Fill,Type{Fill},<:NTuple{2,Any}}) = A.args[2] +# types for use by extensions +function _mulbanded_copyto! end + +abstract type AbstractLazyBandedLayout <: AbstractBandedLayout end +struct LazyBandedLayout <: AbstractLazyBandedLayout end + if !isdefined(Base, :get_extension) include("../ext/LazyArraysStaticArraysExt.jl") include("../ext/LazyArraysBandedMatricesExt.jl")