Skip to content

BandedBlockBandedMatrix function barrier #376

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

Merged
merged 2 commits into from
Jan 30, 2023
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
22 changes: 12 additions & 10 deletions src/Operators/SubOperator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,23 +263,25 @@ function BandedBlockBandedMatrix(::Type{Zeros}, S::SubOperator)
rows,cols, (l,u), (λ-jsh,μ+ksh))
end

function BandedBlockBandedMatrix(::Type{Zeros}, S::SubOperator{<:Any,<:Any,Tuple{BlockRange1,BlockRange1}})
KR,JR = parentindices(S)
KO = parent(S)
l,u = blockbandwidths(KO)::Tuple{Int,Int}
λ,μ = subblockbandwidths(KO)::Tuple{Int,Int}

rt = rangespace(KO)
dt = domainspace(KO)
function _BandedBlockBandedMatrixZeros(::Type{T}, KR, JR, (l,u), (λ,μ), rt, dt) where {T}
J = first(JR)
K = first(KR)
bl_sh = Int(J) - Int(K)

KBR = blocklengthrange(rt,KR)
KJR = blocklengthrange(dt,JR)

BandedBlockBandedMatrix(Zeros{eltype(KO)}(sum(KBR),sum(KJR)),
AbstractVector{Int}(KBR),AbstractVector{Int}(KJR), (l+bl_sh,u-bl_sh), (λ,μ))
BandedBlockBandedMatrix(Zeros{T}(sum(KBR),sum(KJR)),
convert(AbstractVector{Int}, KBR),
convert(AbstractVector{Int}, KJR),
(l+bl_sh,u-bl_sh), (λ,μ))
end
function BandedBlockBandedMatrix(::Type{Zeros}, S::SubOperator{<:Any,<:Any,Tuple{BlockRange1,BlockRange1}})
KR,JR = parentindices(S)
KO = parent(S)
l,u = blockbandwidths(KO)::Tuple{Int,Int}
λ,μ = subblockbandwidths(KO)::Tuple{Int,Int}
_BandedBlockBandedMatrixZeros(eltype(KO), KR, JR, (l,u), (λ,μ), rangespace(KO), domainspace(KO))
end


Expand Down
2 changes: 1 addition & 1 deletion src/Operators/general/InterlaceOperator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function colstop(M::InterlaceOperator, j::Integer)
for N = 1:size(M.ops,1)
cs = colstop(M.ops[N,J],jj)::Int
if cs > 0
K = max(K,findfirst(M.rangeinterlacer,(N,cs))::Int)
K = max(K,findfirst((N,cs), M.rangeinterlacer)::Int)
end
end
K
Expand Down
10 changes: 5 additions & 5 deletions src/Operators/general/algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,10 @@ for TYP in (:Matrix, :BandedMatrix, :RaggedMatrix)
return $TYP(BandedMatrix(V))
end
elseif isbandedblockbanded(P)
N = block(rangespace(P), last(parentindices(V)[1]))
M = block(domainspace(P), last(parentindices(V)[2]))
B = P[Block(1):N, Block(1):M]
return $TYP(view(B, parentindices(V)...), _colstops(V))
N = block(rangespace(P), last(parentindices(V)[1]))::Block{1,Int}
M = block(domainspace(P), last(parentindices(V)[2]))::Block{1,Int}
B = P[Block(1):N, Block(1):M]::AbstractMatrix{T}
return $TYP(view(B, parentindices(V)...), _colstops(V))::$TYP{T}
end

kr, jr = parentindices(V)
Expand Down Expand Up @@ -494,7 +494,7 @@ for TYP in (:Matrix, :BandedMatrix, :RaggedMatrix)
RT2 = _rettype(RT)
BA::RT2 = strictconvert(RT, P.ops[end][krl[end, 1]:krl[end, 2], jr])
for m = (length(P.ops)-1):-1:1
BA = strictconvert(RT, P.ops[m][krl[m, 1]:krl[m, 2], krl[m+1, 1]:krl[m+1, 2]]) * BA
BA = strictconvert(RT, P.ops[m][krl[m, 1]:krl[m, 2], krl[m+1, 1]:krl[m+1, 2]])::RT2 * BA
end

RT(BA)
Expand Down
4 changes: 2 additions & 2 deletions src/Operators/spacepromotion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ rangespace(S::SpaceOperator) = S.rangespace

##TODO: Do we need both max and min?
function findmindomainspace(ops)
mapreduce(domainspace, union, ops, init = UnsetSpace())
mapreduce(domainspace, union, ops)
end

function findmaxrangespace(ops)
mapreduce(rangespace, maxspace, ops, init = UnsetSpace())
mapreduce(rangespace, maxspace, ops)
end


Expand Down