Skip to content

Commit 5d3b373

Browse files
authored
condense InterlaceOperator methods (#403)
1 parent 109592e commit 5d3b373

File tree

1 file changed

+12
-33
lines changed

1 file changed

+12
-33
lines changed

src/Operators/general/InterlaceOperator.jl

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -139,41 +139,20 @@ function InterlaceOperator(ops::VectorOrTupleOfOp, ds::Space, rs::Space)
139139
(l,u))
140140
end
141141

142-
function InterlaceOperator(opsin::AbstractMatrix{<:Operator})
142+
interlace_domainspace(ops::AbstractMatrix, ::Type{NoSpace}) = domainspace(ops)
143+
interlace_domainspace(ops::AbstractMatrix, ::Type{DS}) where {DS} = DS(components(domainspace(ops)))
144+
interlace_rangespace(ops::AbstractMatrix, ::Type{NoSpace}) = rangespace(@view ops[:,1])
145+
interlace_rangespace(ops::RowVector, ::Type{NoSpace}) = rangespace(ops[1])
146+
interlace_rangespace(ops::AbstractMatrix, ::Type{RS}) where {RS} = RS(rangespace(@view ops[:,1]).spaces)
147+
interlace_rangespace(ops::RowVector, ::Type{RS}) where {RS} = RS(rangespace(ops[1]))
148+
149+
function InterlaceOperator(opsin::AbstractMatrix{<:Operator},
150+
ds::Type{DS}=NoSpace,rs::Type{RS}=ds) where {DS<:Space,RS<:Space}
143151
isempty(opsin) && throw(ArgumentError("Cannot create InterlaceOperator from empty Matrix"))
144152
ops=promotespaces(opsin)
145-
InterlaceOperator(ops,domainspace(ops),rangespace(ops[:,1]))
153+
InterlaceOperator(ops, interlace_domainspace(ops, DS), interlace_rangespace(ops, RS))
146154
end
147155

148-
function InterlaceOperator(opsin::AbstractMatrix{<:Operator},::Type{DS},::Type{RS}) where {DS<:Space,RS<:Space}
149-
isempty(opsin) && throw(ArgumentError("Cannot create InterlaceOperator from empty Matrix"))
150-
ops=promotespaces(opsin)
151-
InterlaceOperator(ops,DS(components(domainspace(ops))),RS(rangespace(@view ops[:,1]).spaces))
152-
end
153-
154-
155-
function InterlaceOperator(opsin::RowVector{<:Operator})
156-
isempty(opsin) && throw(ArgumentError("Cannot create InterlaceOperator from empty Matrix"))
157-
158-
ops=promotespaces(opsin)
159-
InterlaceOperator(ops,domainspace(ops),rangespace(ops[1]))
160-
end
161-
162-
function InterlaceOperator(opsin::RowVector{<:Operator},::Type{DS},::Type{RS}) where {DS<:Space,RS<:Space}
163-
isempty(opsin) && throw(ArgumentError("Cannot create InterlaceOperator from empty Matrix"))
164-
ops=promotespaces(opsin)
165-
InterlaceOperator(ops,DS(components(domainspace(ops))),rangespace(ops[1]))
166-
end
167-
168-
169-
170-
171-
InterlaceOperator(opsin::AbstractMatrix{<:Operator},::Type{DS}) where {DS<:Space} =
172-
InterlaceOperator(opsin,DS,DS)
173-
174-
InterlaceOperator(opsin::AbstractMatrix,S...) =
175-
InterlaceOperator(Matrix{Operator{promote_eltypeof(opsin)}}(promotespaces(opsin)),S...)
176-
177156
function InterlaceOperator(opsin::AbstractVector{<:Operator})
178157
ops = convert_vector(promotedomainspace(opsin))
179158
InterlaceOperator(ops, domainspace(first(ops)), rangespace(ops))
@@ -192,8 +171,8 @@ else
192171
end
193172
end
194173

195-
InterlaceOperator(ops::AbstractArray) =
196-
InterlaceOperator(Array{Operator{promote_eltypeof(ops)}, ndims(ops)}(ops))
174+
InterlaceOperator(ops::AbstractArray, ds=NoSpace, rs=ds) =
175+
InterlaceOperator(Array{Operator{promote_eltypeof(ops)}, ndims(ops)}(ops), ds, rs)
197176

198177

199178
function convert(::Type{Operator{T}},S::InterlaceOperator) where T

0 commit comments

Comments
 (0)