JuliaAlgebra / MultivariatePolynomials.jl

Multivariate polynomials interface
https://juliaalgebra.github.io/MultivariatePolynomials.jl/stable/
Other
135 stars 27 forks source link

unified interface for constructing variables #278

Closed nsajko closed 11 months ago

nsajko commented 11 months ago

TypedPolynomials.@polyvar x returns a single value, but DynamicPolynomials.@polyvar x returns a length-one tuple:

julia> import TypedPolynomials, DynamicPolynomials

julia> TypedPolynomials.@polyvar a
a

julia> DynamicPolynomials.@polyvar b
(b,)

To get around this inconsistency, I currently do @polyvar x dummy, which is awkward.

Is there a better way?

blegat commented 11 months ago

We have https://juliaalgebra.github.io/MultivariatePolynomials.jl/dev/types/#MultivariatePolynomials.similar_variable to programatically create a new variable

nsajko commented 11 months ago

But to use similar_variable I first need a polynomial value, and I thought I need a variable to construct a polynomial value? Seems like a chicken and egg problem?

blegat commented 11 months ago

Note sure what your use case is. Can't you use mod.@polyvar a and then use a and not care about the returned type ?

nsajko commented 11 months ago

Ah, you're right about that, I don't have to care about which type @polyvar returns, given that it also defines a variable with the same name.