Skip to content
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

Canonical way to find the type of a polynomial? #308

Open
dlfivefifty opened this issue Dec 20, 2024 · 3 comments
Open

Canonical way to find the type of a polynomial? #308

dlfivefifty opened this issue Dec 20, 2024 · 3 comments

Comments

@dlfivefifty
Copy link

To support DynamicPolynomials.jl in RecurrenceRelationships.jl I had to be careful to use the type of a polynomial (which is different than a variable). A quick-and-dirty fix was this:

https://github.com/JuliaApproximation/RecurrenceRelationships.jl/blob/82125b04d75df222024abaf7a10670fa6a99e9bc/src/RecurrenceRelationships.jl#L5

Though now I'm also support matrices and so this doesn't work.

I'm wondering if there's a canonical function for determining the type of a polynomial given the type of the coefficients and the type of the variable.

@blegat
Copy link
Member

blegat commented Dec 23, 2024

@dlfivefifty
Copy link
Author

I meant also for standard types like Float64 and something accessible in packages not dependent on this…

@blegat
Copy link
Member

blegat commented Dec 30, 2024

Good question. I also need to do this frequently, and also for JuMP when you want to obtain the type JuMP.AffExpr from the type JuMP.VariableRef in a generic way, e.g., when preallocating the result of matrix multiplication.
This is one of the reason of the creation of MutableArithmetics.promote_operation.
You can even directly call MutableArithmetics.promote_sum_mul(V, T) where V is the variable type and T is the number type and you'll get the polynomial type if V is a polynomial variable or you'll get JuMP.AffExpr if V is a JuMP variable.

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

No branches or pull requests

2 participants