-
Notifications
You must be signed in to change notification settings - Fork 7
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
Support DynamicPolynomials.jl #214
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #214 +/- ##
=======================================
Coverage 92.14% 92.15%
=======================================
Files 18 19 +1
Lines 1858 1860 +2
=======================================
+ Hits 1712 1714 +2
Misses 146 146 ☔ View full report in Codecov by Sentry. |
JuMP expressions are also using JuMP
model = Model()
@variable(model, x)
chebyshevt(5, x) I'm getting julia> chebyshevt(5, x)
ERROR: MethodError: Cannot `convert` an object of type QuadExpr to an object of type AffExpr
The function `convert` exists, but no method is defined for this combination of argument types.
Closest candidates are:
GenericAffExpr{V, K}(::Any, Pair...) where {K, V, N}
@ JuMP ~/.julia/packages/JuMP/i68GU/src/aff_expr.jl:205
GenericAffExpr{V, K}(::Any, ::AbstractArray{<:Pair}) where {K, V}
@ JuMP ~/.julia/packages/JuMP/i68GU/src/aff_expr.jl:198
(::Type{GenericAffExpr{CoefType, VarType}} where {CoefType, VarType})(::Any, ::Any)
@ JuMP ~/.julia/packages/JuMP/i68GU/src/aff_expr.jl:140
...
Stacktrace:
[1] initiateforwardrecurrence(N::Int64, A::LazyArrays.ApplyArray{…}, B::FillArrays.Zeros{…}, C::FillArrays.Ones{…}, x::VariableRef, μ::AffExpr)
@ RecurrenceRelationshipArrays ~/.julia/packages/RecurrenceRelationshipArrays/SCsob/src/recurrence.jl:30
[2] unsafe_getindex
@ ~/.julia/dev/ClassicalOrthogonalPolynomials/ext/ClassicalOrthogonalPolynomialsMutableArithmeticsExt.jl:5 [inlined]
[3] chebyshevt(n::Int64, z::VariableRef)
@ ClassicalOrthogonalPolynomials ~/.julia/dev/ClassicalOrthogonalPolynomials/src/classical/chebyshev.jl:64
[4] top-level scope
@ REPL[9]:1
Some type information was truncated. Use `show(err)` to see complete types. The issue is that the types are tricky to get right, you first have a |
The offending line is here: You can see it makes the mistake of assuming the output type is just the promotion of the input types. Probably a better design might be: p1 = muladd(A[1],x,B[1])*μ
T = typeof(p1)
p0 = convert(T, μ) Though some thought would be needed for the |
You probably don't want the type of the result to depend on |
This supports combining this package with symbolic computation. It's surprisingly fast! 3.5x faster than mathematica in fact: