Skip to content

Commit

Permalink
Deprecate coeffs (#393)
Browse files Browse the repository at this point in the history
* Replace coeffs -> coefficients.

* Replace lc, lt, lm.
  • Loading branch information
wbhart authored Mar 20, 2021
1 parent 6b922bd commit 8589ccb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ lib4ti2_jll = "1493ae25-0f90-5c0e-a06c-8c5077d6d66f"
libsingular_julia_jll = "ae4fbd8f-ecdb-54f8-bbce-35570499b30e"

[compat]
AbstractAlgebra = "0.14"
AbstractAlgebra = "0.15.1"
CxxWrap = "0.11"
Nemo = "0.21"
Nemo = "0.22"
RandomExtensions = "0.4.2"
Singular_jll = "~402.000.102"
julia = "1.3"
Expand Down
5 changes: 3 additions & 2 deletions src/Singular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ import AbstractAlgebra: AbstractAlgebra, diagonal_matrix, factor,

import Nemo: add!, addeq!, base_ring, canonical_unit,
change_base_ring, characteristic, check_parent, codomain,
coeff, coeffs, compose, contains, content, crt,
coeff, coefficients, compose, contains, content, crt,
deflate, deflation, degree, degrees, derivative, divexact,
divides, domain, elem_type, evaluate, exponent_vectors, factor_squarefree,
finish, gcdinv, gen, gens, get_field, intersect, isconstant,
isgen, ismonomial, inflate, isnegative, isone,
isterm, isunit, iszero, lift, lc, lt, lm, monomials,
isterm, isunit, iszero, lift, leading_coefficient,
leading_term, leading_monomial, monomials,
MPolyBuildCtx, mul!, nvars, ordering, parent_type,
parent, primpart, promote_rule, push_term!,
reconstruct, remove, set_field!, sort_terms!,
Expand Down
17 changes: 9 additions & 8 deletions src/poly/poly.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
export spoly, PolyRing, change_base_ring, coeff, coeffs,
export spoly, PolyRing, change_base_ring, coeff, coefficients,
content, deflation, deflate, degree, degrees, degree_bound,
derivative, div, divides, evaluate, exponent,
exponent_vectors, factor, factor_squarefree, finish, gen,
has_global_ordering, has_mixed_ordering, has_local_ordering,
inflate, isgen,
ismonomial, isquotient_ring, isterm, jacobian_ideal, jacobian_matrix,
jet, lc, lt, lm, lead_exponent, monomials, MPolyBuildCtx,
jet, leading_coefficient, leading_term, leading_monomial, lead_exponent,
monomials, MPolyBuildCtx,
nvars, order, ordering, @PolynomialRing, primpart,
push_term!, remove, sort_terms!, symbols, terms, total_degree,
valuation, var_index, vars
Expand Down Expand Up @@ -220,7 +221,7 @@ end
function Base.hash(p::spoly{T}, h::UInt) where T <: Nemo.RingElem
v = 0x37eec82e994ab710%UInt
v = xor(hash(collect(exponent_vectors(p)), h), v)
for c in coeffs(p)
for c in coefficients(p)
v = xor(hash(c, h), v)
v = (v << 1) | (v >> (sizeof(Int)*8 - 1))
end
Expand Down Expand Up @@ -590,7 +591,7 @@ Return the content of the polynomial, i.e. the GCD of its coefficients.
function content(x::spoly)
R = base_ring(x)
d = R()
for c in coeffs(x)
for c in coefficients(x)
d = gcd(d, c)
if isone(d)
break
Expand Down Expand Up @@ -664,7 +665,7 @@ f values")
c = c*zero(parent(vals[j]))
end
end
cvzip = zip(coeffs(a), exponent_vectors(a))
cvzip = zip(coefficients(a), exponent_vectors(a))
for (c, v) in cvzip
t = c
for j = 1:length(vals)
Expand Down Expand Up @@ -815,7 +816,7 @@ Return a Singular polynomial in $R$ with the same coefficients and exponents as
function (R::PolyRing)(p::AbstractAlgebra.Generic.MPoly{T}) where T <: Nemo.RingElem
S = base_ring(R)
B = MPolyBuildCtx(R)
cvzip = zip(coeffs(p), exponent_vectors(p))
cvzip = zip(coefficients(p), exponent_vectors(p))
for (c, v) in cvzip
push_term!(B, S(c), v)
end
Expand All @@ -830,7 +831,7 @@ coefficients and exponents as $p$.
"""
function (R::AbstractAlgebra.Generic.MPolyRing{T})(p::Singular.spoly{Singular.n_unknown{T}}) where T <: Nemo.RingElem
B = MPolyBuildCtx(R)
cvzip = zip(coeffs(p), exponent_vectors(p))
cvzip = zip(coefficients(p), exponent_vectors(p))
for (c, v) in cvzip
push_term!(B, libSingular.julia(libSingular.cast_number_to_void(c.ptr)), v)
end
Expand Down Expand Up @@ -1104,7 +1105,7 @@ function (R::PolyRing)(f::T) where T <: Nemo.MPolyElem
parent(f) == R && return f
B = base_ring(R)
g = MPolyBuildCtx(R)
for (c, e) = zip(Nemo.coeffs(f), Nemo.exponent_vectors(f))
for (c, e) = zip(Nemo.coefficients(f), Nemo.exponent_vectors(f))
push_term!(g, B(c), e)
end
return finish(g)
Expand Down
16 changes: 8 additions & 8 deletions test/libsingular/nemo-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
f2 = y^2 + 1
f3 = x^2 + 2x + 1

f1c = [c for c in coeffs(f1)]
f1c = [c for c in coefficients(f1)]
@test isa(f1c[1], Singular.n_unknown{Nemo.fmpq})

@test f1 + 2 == 2 + f1
Expand Down Expand Up @@ -54,11 +54,11 @@ end
f2 = y^2 + 1
f3 = x^2 + 2x + 1

f1c = [c for c in coeffs(f1)]
f1c = [c for c in coefficients(f1)]

@test isa(f1c[1], Singular.n_unknown{Nemo.fmpz})

@test string(first(coeffs(f3))) == "1"
@test string(first(coefficients(f3))) == "1"

@test f1 + 2 == 2 + f1
@test f1 - 2 == -(2 - f1)
Expand Down Expand Up @@ -102,7 +102,7 @@ end
f2 = y^2 + 1
f3 = x^2 + 2x + 1

f1c = [c for c in coeffs(f1)]
f1c = [c for c in coefficients(f1)]
@test isa(f1c[1], Singular.n_unknown{Nemo.fq_nmod})

@test f1 + 2 == 2 + f1
Expand Down Expand Up @@ -155,7 +155,7 @@ end
f2 = y^2 + 1
f3 = x^2 + 2x + 1

f1c = [c for c in coeffs(f1)]
f1c = [c for c in coefficients(f1)]
@test isa(f1c[1], Singular.n_unknown{Nemo.fq})

@test f1 + 2 == 2 + f1
Expand Down Expand Up @@ -207,7 +207,7 @@ end
f2 = y^2 + 1
f3 = x^2 + 2x + 1

f1c = [c for c in coeffs(f1)]
f1c = [c for c in coefficients(f1)]
@test isa(f1c[1], Singular.n_unknown{Nemo.nf_elem})

@test f1 + 2 == 2 + f1
Expand Down Expand Up @@ -258,7 +258,7 @@ end
f2 = y^2 + 1
f3 = x^2 + 2x + 1

f1c = [c for c in coeffs(f1)]
f1c = [c for c in coefficients(f1)]
@test isa(f1c[1], Singular.n_unknown{AbstractAlgebra.Generic.Frac{Nemo.fmpz}})

@test f1 + 2 == 2 + f1
Expand Down Expand Up @@ -305,7 +305,7 @@ end
f2 = y^2 + 1
f3 = x^2 + 2x + 1

f1c = [c for c in coeffs(f1)]
f1c = [c for c in coefficients(f1)]
@test isa(f1c[1], Singular.n_unknown{Nemo.fmpz_poly})

@test f1 + 2 == 2 + f1
Expand Down
10 changes: 5 additions & 5 deletions test/poly/spoly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ end
@test nvars(R) == 1
pol = x^5 + 3x + 2

@test length(collect(coeffs(pol))) == length(pol)
@test length(collect(coefficients(pol))) == length(pol)
@test length(collect(exponent_vectors(pol))) == length(pol)

polzip = zip(coeffs(pol), monomials(pol), terms(pol))
polzip = zip(coefficients(pol), monomials(pol), terms(pol))
r = R()
for (c, m, t) in polzip
r += c*m
Expand Down Expand Up @@ -172,9 +172,9 @@ end
@test degrees(x^2*y^3) == [2, 3]
@test vars(x^2 + 3x + 1) == [x]
@test var_index(x) == 1 && var_index(y) == 2
@test lc(3x^2 + 2x + 1) == 3
@test lm(3x^2 + 2x + 1) == x^2
@test lt(3x^2 + 2x + 1) == 3x^2
@test leading_coefficient(3x^2 + 2x + 1) == 3
@test leading_monomial(3x^2 + 2x + 1) == x^2
@test leading_term(3x^2 + 2x + 1) == 3x^2

end

Expand Down

0 comments on commit 8589ccb

Please sign in to comment.