AbstractAlgebra.jl icon indicating copy to clipboard operation
AbstractAlgebra.jl copied to clipboard

Enhance Laurent polynomial ring code and API

Open fingolfin opened this issue 2 months ago • 5 comments

This concerns both LaurentPolyWrapRing and LaurentMPolyWrapRing and their elements

  • [ ] rename LaurentPolyWrap to LaurentPolyWrapRingElem (and add a type alias for backwards compatibility)
  • [ ] rename LaurentMPolyWrap to LaurentMPolyWrapRingElem (and add a type alias for backwards compatibility)
  • [ ] ensure change_coefficient_ring works correctly (in particular, add tests)
  • [ ] add laurent_poly_ring_type and laurent_mpoly_ring_type helpers (analog to dense_poly_ring_type and mpoly_ring_type)
  • [ ] likewise add laurent_poly_type and laurent_mpoly_type
  • [ ] document these helpers in docs/src/laurent_polynomial.md resp. docs/src/laurent_mpolynomial.md

fingolfin avatar Oct 28 '25 17:10 fingolfin

Is removing Wrap from the type names also on the table?

thofma avatar Oct 28 '25 18:10 thofma

Dropping Wrap would be fine by me, though then one needs to be extra careful to distinguish the concrete and the abstract types -- i.e. LaurentMPolyWrapRing would then be AbstractAlgebra.Generic.LaurentMPolyRing which is distinct from AbstractAlgebra.LaurentMPolyRing. In general I am not very happy about these types with identical names in different namespaces. In the past I've been bitten by this (when looking at at .jl file in isolation it can be difficult to tell which of the two types is being used. That's also why I greatly dislike that there is Singular.Ring which is a subtype of AbstractAlgebra.Ring. sigh)

Nevertheless, I am also for removing the Wrap.

fingolfin avatar Oct 28 '25 23:10 fingolfin

We also have

abstract type LaurentPolyRing{T} <: AbstractAlgebra.LaurentPolyRing{T} end

@attributes mutable struct LaurentPolyWrapRing{T  <: RingElement,
                                   PR <: AbstractAlgebra.PolyRing{T}
                                  } <: LaurentPolyRing{T}

inside Generic.. I wonder if we ever have two implementations of Laurent polynomials inside Generic.

P.S.: For polynomials we have

julia> typeof(t)
AbstractAlgebra.Generic.Poly{AbsSimpleNumFieldElem}

julia> supertype(ans)
PolyRingElem{AbsSimpleNumFieldElem}

If we did this on purpose, we could also have Generic.Laurent and LaurentRingElem, although I am not sure I like it.

thofma avatar Oct 29 '25 06:10 thofma

How about Generic.LaurentPoly then, would be OK with me (it's an internal type in the end).

And no, I don't foresee us having other implementations; but maybe best to not draw ourselves into a corner?

fingolfin avatar Nov 03 '25 14:11 fingolfin

Another wish (which however might be too breaking, dunno): I really wish base_ring and base_ring_type for these would return the underlying polynomial ring, not the coefficient ring... (sounds familiar? ;-) ). Alas, in this case at least we already do have coefficient_ring and coefficient_ring_type, so perhaps it'd be not too bad...

fingolfin avatar Nov 03 '25 14:11 fingolfin