Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid depending on LazyArraysBandedMatricesExt from within LazyArraysBlockBandedMatricesExt #345

Merged
Merged
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
13 changes: 4 additions & 9 deletions ext/LazyArraysBandedMatricesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ 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,
_bnds, prodbandwidths, banded_rowsupport, banded_colsupport, _BandedMatrix, _banded_broadcast!,
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}()
Expand Down Expand Up @@ -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

Expand Down
12 changes: 4 additions & 8 deletions ext/LazyArraysBlockBandedMatricesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)}()
Expand Down
6 changes: 6 additions & 0 deletions src/LazyArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading