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

Mapping universal polynomials to multivariate polynomials and back #1969

Open
SoongNoonien opened this issue Jan 23, 2025 · 2 comments
Open

Comments

@SoongNoonien
Copy link
Contributor

Hi! Sometimes it seems to be necessary to work with the underlying multivariate polynomials of universal polynomials for performance reasons. Is there a way to switch back and forth between multivariate and universal polynomials? Currently, I think my only option is to directly access the p field of the universal polynomial struct directly. But there seems to be no option to map this back to the universal polynomial ring.

@SoongNoonien
Copy link
Contributor Author

Ok, apparently data(f) works as well for an universal polynomial f.

@fingolfin
Copy link
Member

Currently this works:

julia> S = universal_polynomial_ring(QQ)
Universal Polynomial Ring over Rational field

julia> x = gen(S, :x)
x

julia> y, z = gens(S, [:y, :z])
(y, z)

julia> f = y^3 + z^2
y^3 + z^2

julia> mf = data(f)
y^3 + z^2

julia> typeof(mf)
QQMPolyRingElem

julia> f2 = Nemo.AbstractAlgebra.Generic.UnivPoly(mf, S)
y^3 + z^2

julia> typeof(f2)
AbstractAlgebra.Generic.UnivPoly{QQFieldElem}

julia> f2 == f
true

We could consider allowing S(mf) as a shorthand -- not for arbitrary multivariate polynomials of course, but at least for the case that mf has as parent S.mpoly_ring, i.e., the "current" multivariate ring. That means in the example above, S(x) would not work, as it still has the old initial mpolyring as parent, but such is life. But I would reject all other mpolys because this is not meant to be a universal "coercion" of mpolys into univpolys (one could offer that, but then it should map based on variable names, which the current code does not).

But maybe for now you can just work with the code snippets above...

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