Skip to content

Commit 718ddbc

Browse files
authored
rowstart for PlusOp/TimesOp for InfiniteCardinal (#500)
1 parent b56935b commit 718ddbc

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
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.8.40"
3+
version = "0.8.41"
44

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

src/Operators/general/algebra.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ for (OP, mn) in ((:colstart, :min), (:colstop, :max), (:rowstart, :min), (:rowst
4848
mapreduce(op -> $OP(op, k), $mn, P.ops)
4949
end
5050
end
51+
@eval $OP(::PlusOperator, ::InfiniteCardinal{0}) = ℵ₀
5152
end
5253

5354
# We assume that a Vector{Operator{T}} occurs when incompatible operators are added
@@ -340,10 +341,10 @@ else
340341
promotetimes(args...) = _promotetimes(args...)
341342
end
342343
@inline function _promotetimes(opsin,
343-
dsp=domainspace(last(opsin)),
344-
anytimesop=true)
344+
dsp=domainspace(last(opsin)),
345+
anytimesop=true)
345346

346-
@assert length(opsin) > 1 "need at least 2 operators"
347+
length(opsin) > 1 || throw(ArgumentError("need at least 2 operators"))
347348
ops, bw, bbw, sbbw, ibbb, irb = __promotetimes(opsin, dsp, anytimesop)
348349
sz = _timessize(ops)
349350
isaf = sz[1] == 1 && isconstspace(rangespace(first(ops)))
@@ -356,14 +357,12 @@ function __promotetimes(opsin, dsp, anytimesop)
356357

357358
for k in reverse(eachindex(opsin))
358359
op = opsin[k]
359-
if !isa(op, Conversion)
360-
op_dsp = promotedomainspace(op, dsp)
361-
dsp = rangespace(op_dsp)
362-
if anytimesop && isa(op_dsp, TimesOperator)
363-
append!(ops, view(op_dsp.ops, reverse(axes(op_dsp.ops, 1))))
364-
else
365-
push!(ops, op_dsp)
366-
end
360+
op_dsp = promotedomainspace(op, dsp)
361+
dsp = rangespace(op_dsp)
362+
if anytimesop && isa(op_dsp, TimesOperator)
363+
append!(ops, view(op_dsp.ops, reverse(axes(op_dsp.ops, 1))))
364+
else
365+
push!(ops, op_dsp)
367366
end
368367
end
369368
reverse!(ops), bandwidthssum(bandwidths, ops), bandwidthssum(blockbandwidths, ops),
@@ -433,6 +432,7 @@ for OP in (:rowstart, :rowstop)
433432
end
434433
k
435434
end
435+
@eval $OP(::TimesOperator, ::InfiniteCardinal{0}) = ℵ₀
436436
end
437437

438438
for OP in (:colstart, :colstop)

test/PolynomialSpacesTests.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,13 @@ Base.:(==)(a::UniqueInterval, b::UniqueInterval) = (@assert a.parentinterval ==
305305
@testset for I in CartesianIndices(B)
306306
@test B[I] P[Tuple(I)...] rtol=1e-8 atol=eps(eltype(B))
307307
end
308+
309+
D1 = Derivative(Chebyshev())
310+
P1 = PartialInverseOperator(Conversion(domainspace(D1), rangespace(D1)))
311+
D2 = Derivative(Chebyshev(), 2)
312+
P2 = PartialInverseOperator(Conversion(domainspace(D2), rangespace(D2)))
313+
@test (P1 * D1)[1:10, 1:10] (P2 * D1)[1:10, 1:10]
314+
@test ((P1 * D1)^2)[1:10, 1:10] (P2 * D2)[1:10, 1:10]
308315
end
309316

310317
@testset "istriu/istril" begin
@@ -378,6 +385,12 @@ Base.:(==)(a::UniqueInterval, b::UniqueInterval) = (@assert a.parentinterval ==
378385
x = Fun()
379386
A = @inferred Derivative() * Multiplication(x, Chebyshev())
380387
@test A * x 2x
388+
@test ApproxFunBase.rowstart(A, ApproxFunBase.ℵ₀) == ApproxFunBase.ℵ₀
389+
end
390+
391+
@testset "PlusOperator" begin
392+
A = Derivative(Chebyshev()) + Derivative(Chebyshev())
393+
@test ApproxFunBase.rowstart(A, ApproxFunBase.ℵ₀) == ApproxFunBase.ℵ₀
381394
end
382395

383396
@testset "ConstantSpace" begin

0 commit comments

Comments
 (0)