Skip to content

Commit

Permalink
Replace deprecated alias MPolyElem by MPolyRingElem (oscar-system#2932)
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin authored Oct 18, 2023
1 parent 65c9c93 commit 006f4c7
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ AbsAffineAlgebraicSet
## Constructors
One can create an algebraic set from an ideal or a multivariate polynomial.
```@docs
algebraic_set(I::MPolyIdeal{<:MPolyElem}; check::Bool=true)
algebraic_set(f::MPolyElem; check::Bool=true)
algebraic_set(I::MPolyIdeal{<:MPolyRingElem}; check::Bool=true)
algebraic_set(f::MPolyRingElem; check::Bool=true)
```
Convert an affine scheme to an affine algebraic set in order to ignore
its (non-reduced) scheme structure.
Expand Down
16 changes: 8 additions & 8 deletions experimental/Schemes/elliptic_surface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ function two_neighbor_step(X::EllipticSurface, F::Vector{QQFieldElem})
@assert scheme(parent(u)) === weierstrass_model(X)[1]

# Helper function
my_const(u::MPolyElem) = is_zero(u) ? zero(coefficient_ring(parent(u))) : first(coefficients(u))
my_const(u::MPolyRingElem) = is_zero(u) ? zero(coefficient_ring(parent(u))) : first(coefficients(u))

# transform to a quartic y'^2 = q(x)
if iszero(P[3]) # P = O
Expand Down Expand Up @@ -1456,13 +1456,13 @@ end


@doc raw"""
elliptic_surface(g::MPolyElem, x::MPolyElem, y::MPolyElem, P::Vector{<:RingElem})
elliptic_surface(g::MPolyRingElem, x::MPolyRingElem, y::MPolyRingElem, P::Vector{<:RingElem})
Transform a bivariate polynomial `g` of the form `y^2 - Q(x)` with `Q(x)` of
degree at most ``4`` to Weierstrass form and return the corresponding
elliptic surface as well as the coordinate transformation.
"""
function elliptic_surface(g::MPolyElem, P::Vector{<:RingElem})
function elliptic_surface(g::MPolyRingElem, P::Vector{<:RingElem})
R = parent(g)
(x, y) = gens(R)
P = base_ring(R).(P)
Expand All @@ -1480,14 +1480,14 @@ function elliptic_surface(g::MPolyElem, P::Vector{<:RingElem})
end

@doc raw"""
transform_to_weierstrass(g::MPolyElem, x::MPolyElem, y::MPolyElem, P::Vector{<:RingElem})
transform_to_weierstrass(g::MPolyRingElem, x::MPolyRingElem, y::MPolyRingElem, P::Vector{<:RingElem})
Transform a bivariate polynomial `g` of the form `y^2 - Q(x)` with `Q(x)` of degree ``≤ 4``
to Weierstrass form. This returns a pair `(f, trans)` where `trans` is an endomorphism of the
`fraction_field` of `parent(g)` and `f` is the transform. The input `P` must be a rational point
on the curve defined by `g`, i.e. `g(P) == 0`.
"""
function transform_to_weierstrass(g::MPolyElem, x::MPolyElem, y::MPolyElem, P::Vector{<:RingElem})
function transform_to_weierstrass(g::MPolyRingElem, x::MPolyRingElem, y::MPolyRingElem, P::Vector{<:RingElem})
R = parent(g)
@assert ngens(R) == 2 "input polynomial must be bivariate"
@assert x in gens(R) "second argument must be a variable of the parent of the first"
Expand Down Expand Up @@ -1568,11 +1568,11 @@ function transform_to_weierstrass(g::MPolyElem, x::MPolyElem, y::MPolyElem, P::V
return result, trans
end

function _is_in_weierstrass_form(f::MPolyElem)
function _is_in_weierstrass_form(f::MPolyRingElem)
R = parent(f)
@req ngens(R) == 2 "polynomial must be bivariate"
# Helper function
my_const(u::MPolyElem) = is_zero(u) ? zero(coefficient_ring(parent(u))) : first(coefficients(u))
my_const(u::MPolyRingElem) = is_zero(u) ? zero(coefficient_ring(parent(u))) : first(coefficients(u))

(x, y) = gens(R)
f = -inv(my_const(coeff(f, [x, y], [0, 2]))) * f
Expand Down Expand Up @@ -1645,7 +1645,7 @@ function _elliptic_parameter_conversion(X::EllipticSurface, u::VarietyFunctionFi
FS = fraction_field(S)

# Helper function
my_const(u::MPolyElem) = is_zero(u) ? zero(coefficient_ring(parent(u))) : first(coefficients(u))
my_const(u::MPolyRingElem) = is_zero(u) ? zero(coefficient_ring(parent(u))) : first(coefficients(u))

# We verify the assumptions made on p. 44 of
# A. Kumar: "Elliptic Fibrations on a generic Jacobian Kummer surface"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defined by ideal(x^3 + y^2 + y + 1, x)
```
"""
function algebraic_set(I::MPolyIdeal{<:MPolyElem}; is_radical::Bool=false, check::Bool=true)
function algebraic_set(I::MPolyIdeal{<:MPolyRingElem}; is_radical::Bool=false, check::Bool=true)
X = Spec(base_ring(I), I)
return algebraic_set(X, is_reduced=is_radical, check=check)
end
Expand Down
2 changes: 1 addition & 1 deletion src/Rings/MPolyQuo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ function vector_space(K::AbstractAlgebra.Field, Q::MPolyQuoRing)
# quotient; see Greuel/Pfister "A singular introduction to Commutative Algebra".
function prim(a::MPolyQuoRingElem)
@assert parent(a) === Q
b = lift(a)::MPolyElem
b = lift(a)::MPolyRingElem
o = default_ordering(R)
# TODO: Make sure the ordering is the same as the one used for the _kbase above
@assert is_global(o) "ordering must be global"
Expand Down
2 changes: 1 addition & 1 deletion src/Rings/mpoly-ideals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ julia> codim(I)
2
```
"""
codim(I::MPolyIdeal{T}) where {T<:MPolyElem{<:FieldElem}}= nvars(base_ring(I)) - dim(I)
codim(I::MPolyIdeal{T}) where {T<:MPolyRingElem{<:FieldElem}}= nvars(base_ring(I)) - dim(I)
codim(I::MPolyIdeal) = dim(base_ring(I)) - dim(I)

# Some fixes which were necessary for the above
Expand Down
8 changes: 4 additions & 4 deletions src/Rings/mpoly-localizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3095,7 +3095,7 @@ julia> minimal_generating_set(I)
"""
@attr Vector{<:MPolyLocRingElem} function minimal_generating_set(
I::MPolyLocalizedIdeal{<:MPolyLocRing{<:Field, <:FieldElem,
<:MPolyRing, <:MPolyElem,
<:MPolyRing, <:MPolyRingElem,
<:MPolyComplementOfKPointIdeal}
}
)
Expand Down Expand Up @@ -3171,17 +3171,17 @@ julia> small_generating_set(I)
```
"""
small_generating_set(I::MPolyLocalizedIdeal{<:MPolyLocRing{<:Field, <:FieldElem,
<:MPolyRing, <:MPolyElem,
<:MPolyRing, <:MPolyRingElem,
<:MPolyComplementOfKPointIdeal}}) = minimal_generating_set(I)

function small_generating_set(I::MPolyLocalizedIdeal{<:MPolyLocRing{<:Field, <:FieldElem,
<:MPolyRing, <:MPolyElem,
<:MPolyRing, <:MPolyRingElem,
<:MPolyPowersOfElement}})
L = base_ring(I)
R = base_ring(L)
I_min = L.(small_generating_set(saturated_ideal(I)))
return filter(!iszero, I_min)
end

dim(R::MPolyLocRing{<:Field, <:FieldElem, <:MPolyRing, <:MPolyElem, <:MPolyComplementOfPrimeIdeal}) = nvars(base_ring(R)) - dim(prime_ideal(inverted_set(R)))
dim(R::MPolyLocRing{<:Field, <:FieldElem, <:MPolyRing, <:MPolyRingElem, <:MPolyComplementOfPrimeIdeal}) = nvars(base_ring(R)) - dim(prime_ideal(inverted_set(R)))

4 changes: 2 additions & 2 deletions src/Rings/mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ end
lift(f::MPolyRingElem) = f

### Hessian matrix
function hessian_matrix(f::MPolyElem)
function hessian_matrix(f::MPolyRingElem)
R = parent(f)
n = nvars(R)
df = jacobi_matrix(f)
Expand All @@ -1309,5 +1309,5 @@ function hessian_matrix(f::MPolyElem)
return result
end

hessian(f::MPolyElem) = det(hessian_matrix(f))
hessian(f::MPolyRingElem) = det(hessian_matrix(f))

6 changes: 3 additions & 3 deletions src/Rings/mpolyquo-localizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,7 @@ If the localization is at a point, a minimal set of generators is returned.
"""
@attr Vector{<:MPolyQuoLocRingElem} function small_generating_set(
I::MPolyQuoLocalizedIdeal{<:MPolyQuoLocRing{<:Field, <:FieldElem,
<:MPolyRing, <:MPolyElem,
<:MPolyRing, <:MPolyRingElem,
<:MPolyComplementOfKPointIdeal},
<:Any,<:Any}
)
Expand All @@ -2234,7 +2234,7 @@ end

function small_generating_set(
I::MPolyQuoLocalizedIdeal{<:MPolyQuoLocRing{<:Field, <:FieldElem,
<:MPolyRing, <:MPolyElem,
<:MPolyRing, <:MPolyRingElem,
<:MPolyPowersOfElement}
}
)
Expand All @@ -2245,5 +2245,5 @@ function small_generating_set(
return filter(!iszero, Q.(small_generating_set(J)))
end

dim(R::MPolyQuoLocRing{<:Field, <:FieldElem, <:MPolyRing, <:MPolyElem, <:MPolyComplementOfPrimeIdeal}) = dim(saturated_ideal(modulus(R))) - dim(prime_ideal(inverted_set(R)))
dim(R::MPolyQuoLocRing{<:Field, <:FieldElem, <:MPolyRing, <:MPolyRingElem, <:MPolyComplementOfPrimeIdeal}) = dim(saturated_ideal(modulus(R))) - dim(prime_ideal(inverted_set(R)))

2 changes: 1 addition & 1 deletion src/Serialization/Fields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ end
function load_object(s::DeserializerState, ::Type{<: Union{NfAbsNSElem, Hecke.NfRelNSElem}}, terms::Vector, parents::Vector)
K = parents[end]
n = ngens(K)
# forces parent of MPolyElem
# forces parent of MPolyRingElem
poly_ring = polynomial_ring(base_field(K), n)
parents[end - 1], _ = poly_ring
poly_elem_type = elem_type
Expand Down
32 changes: 16 additions & 16 deletions src/TropicalGeometry/groebner_fan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# Computes the space of weight vectors w.r.t. which G is weighted homogeneous
@doc raw"""
homogeneity_space(G::Vector{<:MPolyElem})
homogeneity_space(G::Vector{<:MPolyRingElem})
Return a `Cone` that is the space of all weight vectors under which all elements of `G` are weighted homogeneous. The cone will be a linear subspace without any rays.
Expand Down Expand Up @@ -56,7 +56,7 @@ julia> rays_modulo_lineality(homogeneity_space(G3))
```
"""
function homogeneity_space(G::Vector{<:MPolyElem})
function homogeneity_space(G::Vector{<:MPolyRingElem})
inequalities = fmpq_mat(0,0)
equations = Vector{Vector{Int}}()
for g in G
Expand All @@ -71,7 +71,7 @@ end


@doc raw"""
homogeneity_vector(G::Vector{<:MPolyElem})
homogeneity_vector(G::Vector{<:MPolyRingElem})
Return a positive `Vector{fmpz}` under which every element of `G` is weighted
homogeneous. If no such vector exists, return `nothing`.
Expand Down Expand Up @@ -119,7 +119,7 @@ true
```
"""
function homogeneity_vector(G::Vector{<:MPolyElem})
function homogeneity_vector(G::Vector{<:MPolyRingElem})
homogeneitySpace = homogeneity_space(G)

# return nothing if homogeneitySpace is the origin
Expand Down Expand Up @@ -150,7 +150,7 @@ end


@doc raw"""
maximal_groebner_cone(G::Oscar.IdealGens{<:MPolyElem}; homogeneityWeight::Union{Nothing,Vector{fmpz}}=nothing)
maximal_groebner_cone(G::Oscar.IdealGens{<:MPolyRingElem}; homogeneityWeight::Union{Nothing,Vector{fmpz}}=nothing)
Returns the maximal Groebner cone of a Groebner basis `G`, i.e., the closure of all weight vectors with respect to whose weighted ordering `G` is a Groebner basis (independent of tie-breaker).
Expand Down Expand Up @@ -180,36 +180,36 @@ julia> rays_modulo_lineality(maximal_groebner_cone(G))
```
"""
function maximal_groebner_cone(G::Oscar.IdealGens{<:MPolyElem})
function maximal_groebner_cone(G::Oscar.IdealGens{<:MPolyRingElem})
@assert is_groebner_basis(G)
ord = ordering(G)
G = collect(G)
homogeneityWeight = homogeneity_vector(G)
return maximal_groebner_cone(G,ord,homogeneityWeight)
end

function maximal_groebner_cone(G::Oscar.IdealGens{<:MPolyElem}, homogeneityWeight::Union{Vector{fmpz},Nothing})
function maximal_groebner_cone(G::Oscar.IdealGens{<:MPolyRingElem}, homogeneityWeight::Union{Vector{fmpz},Nothing})
@assert is_groebner_basis(G)
ord = ordering(G)
G = collect(G)
return maximal_groebner_cone(G,ord,homogeneityWeight)
end

function maximal_groebner_cone(G::Vector{<:MPolyElem}, ord::MonomialOrdering, homogeneityWeight::Nothing)
function maximal_groebner_cone(G::Vector{<:MPolyRingElem}, ord::MonomialOrdering, homogeneityWeight::Nothing)
# calling with `nothing` as homogeneityWeight
# means that C needs to be restricted to the positive orthant
C = maximal_groebner_cone_extended(G,ord)
positiveOrthant = positive_hull(identity_matrix(ZZ,ambient_dim(C)))
return intersect(C,positiveOrthant)
end

function maximal_groebner_cone(G::Vector{<:MPolyElem}, ord::MonomialOrdering, homogeneityWeight::Vector{fmpz})
function maximal_groebner_cone(G::Vector{<:MPolyRingElem}, ord::MonomialOrdering, homogeneityWeight::Vector{fmpz})
# calling with a positive homogeneityWeight
# means that C does not be restricted to the positive orthant
return maximal_groebner_cone_extended(G,ord)
end

function maximal_groebner_cone_extended(G::Vector{<:MPolyElem}, ord::MonomialOrdering)
function maximal_groebner_cone_extended(G::Vector{<:MPolyRingElem}, ord::MonomialOrdering)
# iterate over all elements of G and construct the inequalities
inequalities = Vector{Vector{Int}}()
for g in G
Expand Down Expand Up @@ -268,7 +268,7 @@ end

# Returns the initial form of polynomial g with respect to weight vector u.
# Requires a monomial ordering that is compatible with respect to u, i.e., the leading monomial is of highest weighted degree.
function initial(g::MPolyElem, ordering::MonomialOrdering, u::Vector{fmpz})
function initial(g::MPolyRingElem, ordering::MonomialOrdering, u::Vector{fmpz})
lt,tail = Iterators.peel(terms(g,ordering=ordering));
d = dot(u,fmpz.(leading_exponent_vector(lt)))
initial_terms = [s for s in tail if dot(u,fmpz.(leading_exponent_vector(s)))==d]
Expand All @@ -277,7 +277,7 @@ function initial(g::MPolyElem, ordering::MonomialOrdering, u::Vector{fmpz})
end

# Applies the function above to each polynomial in a list of polynomials.
function initial(G::Vector{<:MPolyElem}, ord::MonomialOrdering, u::Vector{fmpz})
function initial(G::Vector{<:MPolyRingElem}, ord::MonomialOrdering, u::Vector{fmpz})
return initial.(G,Ref(ord),Ref(u))
end

Expand All @@ -287,7 +287,7 @@ end
# - G is a Groebner basis with respect to ord
# Returns:
# - a reduced Groebner basis with respect to ord
function interreduce(G::Vector{<:MPolyElem}, ord::MonomialOrdering)
function interreduce(G::Vector{<:MPolyRingElem}, ord::MonomialOrdering)
# sort G by its leading monomials (result is smallest first)
# then reduce G[i] by G[1:i-1] for i=length(G),...,2
sort!(G,
Expand All @@ -307,9 +307,9 @@ end
# - ordH and ordG are adjacent orderings
# Returns:
# - Gnew, a Groebner basis of the original ideal w.r.t. ordH
function groebner_lift(Hnew::Vector{<:MPolyElem},
function groebner_lift(Hnew::Vector{<:MPolyRingElem},
ordH::MonomialOrdering,
G::Vector{<:MPolyElem},
G::Vector{<:MPolyRingElem},
ordG::MonomialOrdering)
# lift to groebner basis
Gnew = Hnew - reduce(Hnew,G,ordering=ordG,complete_reduction=true)
Expand All @@ -327,7 +327,7 @@ end
# Returns:
# - the reduced Groebner basis with respect to the adjacent ordering
# in direction v
function groebner_flip(G::Vector{<:MPolyElem},
function groebner_flip(G::Vector{<:MPolyRingElem},
ordG::MonomialOrdering,
homogeneityVector::Union{Vector{fmpz},Nothing},
interior_facet_point::Vector{fmpz},
Expand Down

0 comments on commit 006f4c7

Please sign in to comment.