Skip to content

Commit d1fcd94

Browse files
committed
Store domainspace in TimesOperator
1 parent ea0113e commit d1fcd94

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunBase"
22
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
3-
version = "0.9.15"
3+
version = "0.10.0"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/Operators/general/algebra.jl

+16-10
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ function splice_times(ops)
240240
newops
241241
end
242242

243-
struct TimesOperator{T,BW,SZ,O<:Operator{T},BBW,SBBW} <: Operator{T}
243+
struct TimesOperator{T,BW,SZ,O<:Operator{T},BBW,SBBW,D} <: Operator{T}
244244
ops::Vector{O}
245245
bandwidths::BW
246246
sz::SZ
@@ -249,19 +249,21 @@ struct TimesOperator{T,BW,SZ,O<:Operator{T},BBW,SBBW} <: Operator{T}
249249
isbandedblockbanded::Bool
250250
israggedbelow::Bool
251251
isafunctional::Bool
252+
domainspace::D
252253

253254
Base.@constprop :aggressive function TimesOperator{T,BW,SZ,O,BBW,SBBW}(ops::Vector{O}, bw::BW,
254255
sz::SZ, bbw::BBW, sbbw::SBBW,
255-
ibbb::Bool, irb::Bool, isaf::Bool;
256-
anytimesop = any(x -> x isa TimesOperator, ops)) where {T,O<:Operator{T},BW,SZ,BBW,SBBW}
256+
ibbb::Bool, irb::Bool, isaf::Bool, dsp::D;
257+
anytimesop = any(x -> x isa TimesOperator, ops)) where {T,O<:Operator{T},BW,SZ,BBW,SBBW,D}
257258

259+
dsp == domainspace(ops[end]) || throw(ArgumentError("incompatible domainspace"))
258260
# check compatible
259261
check_times(ops)
260262

261263
# remove TimesOperators buried inside ops
262264
newops = anytimesop ? splice_times(ops) : ops
263265

264-
new{T,BW,SZ,O,BBW,SBBW}(newops, bw, sz, bbw, sbbw, ibbb, irb, isaf)
266+
new{T,BW,SZ,O,BBW,SBBW,D}(newops, bw, sz, bbw, sbbw, ibbb, irb, isaf, dsp)
265267
end
266268
end
267269

@@ -280,11 +282,12 @@ function TimesOperator(ops::AbstractVector{O},
280282
sbbw::Tuple{Any,Any}=bandwidthssum(subblockbandwidths, ops),
281283
ibbb::Bool=all(isbandedblockbanded, ops),
282284
irb::Bool=all(israggedbelow, ops),
283-
isaf::Bool = sz[1] == 1 && isconstspace(rangespace(first(ops)));
285+
isaf::Bool = sz[1] == 1 && isconstspace(rangespace(first(ops))),
286+
dsp = domainspace(last(ops));
284287
anytimesop = any(x -> x isa TimesOperator, ops),
285288
) where {O<:Operator}
286289
TimesOperator{eltype(O),typeof(bw),typeof(sz),O,typeof(bbw),typeof(sbbw)}(
287-
convert_vector(ops), bw, sz, bbw, sbbw, ibbb, irb, isaf; anytimesop)
290+
convert_vector(ops), bw, sz, bbw, sbbw, ibbb, irb, isaf, dsp; anytimesop)
288291
end
289292

290293
_extractops(A::TimesOperator, ::typeof(*)) = A.ops
@@ -300,8 +303,9 @@ function TimesOperator(A::Operator, Bs::Operator...)
300303
bwsum = bandwidthssum(bandwidths, ops)
301304
bbwsum = bandwidthssum(blockbandwidths, ops)
302305
subbbwsum = bandwidthssum(subblockbandwidths, ops)
306+
dsp = domainspace(last(ops))
303307
TimesOperator(convert_vector(v), bwsum, sz,
304-
bbwsum, subbbwsum, ibbb, irb, isaf;
308+
bbwsum, subbbwsum, ibbb, irb, isaf, dsp;
305309
anytimesop)
306310
end
307311

@@ -317,7 +321,8 @@ function convert(::Type{Operator{T}}, P::TimesOperator) where {T}
317321
_convertops(Operator{T}, ops),
318322
bandwidths(P), size(P), blockbandwidths(P),
319323
subblockbandwidths(P), isbandedblockbanded(P),
320-
israggedbelow(P), P.isafunctional, anytimesop = false)::Operator{T}
324+
israggedbelow(P), P.isafunctional, domainspace(P),
325+
anytimesop = false)::Operator{T}
321326
end
322327
end
323328

@@ -330,7 +335,7 @@ Base.@constprop :aggressive function promotetimes(opsin,
330335
sz = _timessize(ops)
331336
isaf = sz[1] == 1 && isconstspace(rangespace(first(ops)))
332337
anytimesop = any(x -> x isa TimesOperator, ops)
333-
TimesOperator(convert_vector(ops), bw, sz, bbw, sbbw, ibbb, irb, isaf; anytimesop)
338+
TimesOperator(convert_vector(ops), bw, sz, bbw, sbbw, ibbb, irb, isaf, dsp; anytimesop)
334339
end
335340
maybenarroweltype(::AbstractVector{Operator{T}}) where {T} = Operator{T}
336341
maybenarroweltype(opsin) = mapreduce(operatortype, promote_type, opsin)
@@ -384,7 +389,8 @@ end
384389
end
385390
end
386391

387-
domainspace(P::PlusOrTimesOp) = domainspace(last(P.ops))
392+
domainspace(P::PlusOperator) = domainspace(last(P.ops))
393+
domainspace(T::TimesOperator) = T.domainspace
388394
rangespace(P::PlusOrTimesOp) = rangespace(first(P.ops))
389395

390396
domain(P::TimesOperator) = commondomain(P.ops)

test/runtests.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,10 @@ end
295295
f = Fun(sp, coeff)
296296
for sp2 in Any[(), (sp,)]
297297
M = Multiplication(f, sp2...)
298-
a = (M * M) * M
299-
b = M * (M * M)
298+
a = TimesOperator(M, M) * M
299+
b = M * TimesOperator(M, M)
300300
@test a == b
301+
@test (@inferred domainspace(a)) == domainspace(M)
301302
@test bandwidths(a) == bandwidths(b)
302303
end
303304
M = Multiplication(Fun(PointSpace(1:3)))

0 commit comments

Comments
 (0)