Skip to content

rowstart for PlusOp/TimesOp for InfiniteCardinal #500

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 1 commit into from
Jul 25, 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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ApproxFunBase"
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
version = "0.8.40"
version = "0.8.41"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
22 changes: 11 additions & 11 deletions src/Operators/general/algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ for (OP, mn) in ((:colstart, :min), (:colstop, :max), (:rowstart, :min), (:rowst
mapreduce(op -> $OP(op, k), $mn, P.ops)
end
end
@eval $OP(::PlusOperator, ::InfiniteCardinal{0}) = ℵ₀
end

# We assume that a Vector{Operator{T}} occurs when incompatible operators are added
Expand Down Expand Up @@ -340,10 +341,10 @@ else
promotetimes(args...) = _promotetimes(args...)
end
@inline function _promotetimes(opsin,
dsp=domainspace(last(opsin)),
anytimesop=true)
dsp=domainspace(last(opsin)),
anytimesop=true)

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

for k in reverse(eachindex(opsin))
op = opsin[k]
if !isa(op, Conversion)
op_dsp = promotedomainspace(op, dsp)
dsp = rangespace(op_dsp)
if anytimesop && isa(op_dsp, TimesOperator)
append!(ops, view(op_dsp.ops, reverse(axes(op_dsp.ops, 1))))
else
push!(ops, op_dsp)
end
op_dsp = promotedomainspace(op, dsp)
dsp = rangespace(op_dsp)
if anytimesop && isa(op_dsp, TimesOperator)
append!(ops, view(op_dsp.ops, reverse(axes(op_dsp.ops, 1))))
else
push!(ops, op_dsp)
end
end
reverse!(ops), bandwidthssum(bandwidths, ops), bandwidthssum(blockbandwidths, ops),
Expand Down Expand Up @@ -433,6 +432,7 @@ for OP in (:rowstart, :rowstop)
end
k
end
@eval $OP(::TimesOperator, ::InfiniteCardinal{0}) = ℵ₀
end

for OP in (:colstart, :colstop)
Expand Down
13 changes: 13 additions & 0 deletions test/PolynomialSpacesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,13 @@ Base.:(==)(a::UniqueInterval, b::UniqueInterval) = (@assert a.parentinterval ==
@testset for I in CartesianIndices(B)
@test B[I] ≈ P[Tuple(I)...] rtol=1e-8 atol=eps(eltype(B))
end

D1 = Derivative(Chebyshev())
P1 = PartialInverseOperator(Conversion(domainspace(D1), rangespace(D1)))
D2 = Derivative(Chebyshev(), 2)
P2 = PartialInverseOperator(Conversion(domainspace(D2), rangespace(D2)))
@test (P1 * D1)[1:10, 1:10] ≈ (P2 * D1)[1:10, 1:10]
@test ((P1 * D1)^2)[1:10, 1:10] ≈ (P2 * D2)[1:10, 1:10]
end

@testset "istriu/istril" begin
Expand Down Expand Up @@ -378,6 +385,12 @@ Base.:(==)(a::UniqueInterval, b::UniqueInterval) = (@assert a.parentinterval ==
x = Fun()
A = @inferred Derivative() * Multiplication(x, Chebyshev())
@test A * x ≈ 2x
@test ApproxFunBase.rowstart(A, ApproxFunBase.ℵ₀) == ApproxFunBase.ℵ₀
end

@testset "PlusOperator" begin
A = Derivative(Chebyshev()) + Derivative(Chebyshev())
@test ApproxFunBase.rowstart(A, ApproxFunBase.ℵ₀) == ApproxFunBase.ℵ₀
end

@testset "ConstantSpace" begin
Expand Down