Skip to content

Accept Number orders in calculus operators #154

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
Dec 2, 2022

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented Dec 2, 2022

This would help with constant propagation in certain cases, using static integers as orders. Currently, StaticInts are not Integers, although SciML/Static.jl#92 would mean that this change in unnecessary, in which case this may be reverted.

julia> @code_typed rangespace(Derivative(Chebyshev(), 1))
CodeInfo(
1%1 = Base.getfield(D, :order)::Int64%2 = (%1 === 0)::Bool%3 = Base.not_int(%2)::Bool
└──      goto #3 if not %3
2%5 = %new(Ultraspherical{Int64, ChebyshevInterval{Float64}, Float64}, %1, $(QuoteNode(-1.0..1.0 (Chebyshev))))::Ultraspherical{Int64, ChebyshevInterval{Float64}, Float64}
└──      goto #4
3%7 = %new(Core.AssertionError, "m ≠ 0")::AssertionError
│        Base.throw(%7)::Union{}
└──      unreachable
4 ─      goto #5
5return %5
) => Ultraspherical{Int64, ChebyshevInterval{Float64}, Float64}

julia> using Static

julia> @code_typed rangespace(Derivative(Chebyshev(), StaticInt(1)))
CodeInfo(
1return $(QuoteNode(Ultraspherical(static(1))))
) => Ultraspherical{StaticInt{1}, ChebyshevInterval{Float64}, Float64}

Another example:

julia> @code_typed ApproxFunBase.promoterangespace(Derivative(Chebyshev(), 1), Ultraspherical(1, ChebyshevInterval()))
CodeInfo(
1%1  = Base.getfield(P, :order)::Int64%2  = (%1 === 0)::Bool%3  = Base.not_int(%2)::Bool
└──       goto #3 if not %3
2%5  = %new(Ultraspherical{Int64, ChebyshevInterval{Float64}, Float64}, %1, $(QuoteNode(-1.0..1.0 (Chebyshev))))::Ultraspherical{Int64, ChebyshevInterval{Float64}, Float64}
└──       goto #4
3%7  = %new(Core.AssertionError, "m ≠ 0")::AssertionError
│         Base.throw(%7)::Union{}
└──       unreachable
4 ─       goto #5
5 ─       goto #6
6%12 = invoke ApproxFunBase.promoterangespace(P::ApproxFunBase.ConcreteDerivative{Chebyshev{ChebyshevInterval{Float64}, Float64}, Int64, Float64}, sp::Ultraspherical{Int64, ChebyshevInterval{Float64}, Float64}, %5::Ultraspherical{Int64, ChebyshevInterval{Float64}, Float64})::Union{ApproxFunBase.ConcreteDerivative{Chebyshev{ChebyshevInterval{Float64}, Float64}, Int64, Float64}, TimesOperator{Float64, _A, _B, Operator{Float64}} where {_A, _B}}
└──       return %12
) => Union{ApproxFunBase.ConcreteDerivative{Chebyshev{ChebyshevInterval{Float64}, Float64}, Int64, Float64}, TimesOperator{Float64, _A, _B, Operator{Float64}} where {_A, _B}}

julia> @code_typed ApproxFunBase.promoterangespace(Derivative(Chebyshev(), StaticInt(1)), Ultraspherical(StaticInt(1), ChebyshevInterval()))
CodeInfo(
1return $(QuoteNode(ConcreteDerivative : Chebyshev()  Ultraspherical(static(1))))
) => ApproxFunBase.ConcreteDerivative{Chebyshev{ChebyshevInterval{Float64}, Float64}, StaticInt{1}, Float64}

@codecov
Copy link

codecov bot commented Dec 2, 2022

Codecov Report

Base: 68.59% // Head: 68.65% // Increases project coverage by +0.06% 🎉

Coverage data is based on head (bd1df9b) compared to base (50185a5).
Patch coverage: 76.92% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #154      +/-   ##
==========================================
+ Coverage   68.59%   68.65%   +0.06%     
==========================================
  Files          28       28              
  Lines        2458     2466       +8     
==========================================
+ Hits         1686     1693       +7     
- Misses        772      773       +1     
Impacted Files Coverage Δ
src/Spaces/Hermite/Hermite.jl 70.51% <0.00%> (-0.92%) ⬇️
src/Spaces/Chebyshev/ChebyshevOperators.jl 86.23% <100.00%> (+0.20%) ⬆️
src/Spaces/Jacobi/JacobiOperators.jl 77.69% <100.00%> (+0.17%) ⬆️
...c/Spaces/Ultraspherical/UltrasphericalOperators.jl 79.77% <100.00%> (+0.34%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jishnub jishnub merged commit 6e65adb into JuliaApproximation:master Dec 2, 2022
@jishnub jishnub deleted the ordernumber branch December 2, 2022 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant