Skip to content

conversion issue with TypedPolynomials.Polynomial #47

Description

@hofmannmartin

Great package. I am currently using the TypedPolynomials package for the construction of polynomials, as it is the most performant in my use case. However, a straight froward conversion to a StaticPolynomials.Polynomial fails.

using TypedPolynomials
import StaticPolynomials

@polyvar x y z
p = 3*z^2 + 2*y*x
ps = StaticPolynomials.Polynomial(p)

yields

MethodError: no method matching StaticPolynomials.Polynomial(::Vector{Float64}, ::Matrix{Int64}, ::Tuple{Symbol, Symbol, Symbol}, ::Nothing, ::Nothing)

Closest candidates are:
StaticPolynomials.Polynomial(::Vector, ::Matrix{<:Integer}, !Matched::Vector{Symbol}, ::Union{Nothing, Matrix{<:Integer}}, ::Any) at ~/.julia/packages/StaticPolynomials/TgQjK/src/polynomial.jl:63
StaticPolynomials.Polynomial(::Vector{T}, !Matched::StaticPolynomials.SExponents, ::Any, ::Union{Nothing, StaticPolynomials.SExponents}, ::Any, !Matched::Vector{Int64}) where T at ~/.julia/packages/StaticPolynomials/TgQjK/src/polynomial.jl:26
StaticPolynomials.Polynomial(::Vector, ::Matrix{<:Integer}, !Matched::Vector{Symbol}, ::Union{Nothing, Matrix{<:Integer}}) at ~/.julia/packages/StaticPolynomials/TgQjK/src/polynomial.jl:63

The issue seems to be that the Polynomial constructor expects Vector{Symbol} as third argument, but MultivariatePolynomials.variables returns a tuple in this case. That said I found the following workaround:

using TypedPolynomials, MultivariatePolynomials
import StaticPolynomials

@polyvar x y z
p = 3*z^2 + 2*y*x
ps = StaticPolynomials.Polynomial(p, Variable[variables(p)...], nothing)

What could be a permanent solution, which does not require this workaround?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions