code
stringlengths
17
6.64M
def pickle_monom(self): return (Monomial, (list(self.variables()),))
def pickle_var(self): return (Variable, (self.index(), self.ring()))
def _decode_ring(code): import os (identifier, data, varnames, blocks) = code global _polybori_parallel_rings try: _polybori_parallel_rings except NameError: _polybori_parallel_rings = {} for key in [key for key in _polybori_parallel_rings if (not _polybori_parallel_rings[key][...
def _encode_ring(ring): import os identifier = (ring.id(), os.getpid()) global _polybori_parallel_rings try: _polybori_parallel_rings except NameError: _polybori_parallel_rings = {} for key in [key for key in _polybori_parallel_rings if (not _polybori_parallel_rings[key][0]())]...
def pickle_ring(self): return (_decode_ring, (_encode_ring(self),))
def groebner_basis_first_finished(I, *l): '\n\n INPUT:\n\n - ``I`` -- ideal\n - ``l`` -- keyword dictionaries, which will be keyword arguments to groebner_basis.\n\n OUTPUT:\n\n - tries to compute ``groebner_basis(I, **kwd)`` for kwd in l\n - returns the result of the first terminated computatio...
def gen_random_poly(ring, l, deg, vars_set, seed=123): '\n Generate a random polynomial with coefficients in ``ring``.\n\n EXAMPLES::\n\n sage: from sage.rings.polynomial.pbori.PyPolyBoRi import Ring, Variable\n sage: from sage.rings.polynomial.pbori.randompoly import gen_random_poly\n ...
def sparse_random_system(ring, number_of_polynomials, variables_per_polynomial, degree, random_seed=None): '\n Generate a sparse random system.\n\n Generate a system, which is sparse in the sense, that each polynomial\n contains only a small subset of variables. In each variable that occurrs\n in a po...
def sparse_random_system_data_file_content(number_of_variables, **kwds): '\n TESTS::\n\n sage: from sage.rings.polynomial.pbori.randompoly import sparse_random_system_data_file_content\n sage: sparse_random_system_data_file_content(10, number_of_polynomials=5, variables_per_polynomial=3, degree=2...
def input_signals(p): return list((p + p.lex_lead()).vars_as_monomial().variables())
def output_signal(p): return next(iter(p.lex_lead().variables()))
def rank(data): parents = {} res = {} for p in data: out = output_signal(p) parents.setdefault(out, []) for v in input_signals(p): parents.setdefault(v, []).append(out) def do_rank(v): if (v in res): return res[v] my_res = res[v] = max((...
def all_monomials_of_degree_d_old(d, variables): '\n Return monomials of degree d in the given variables.\n\n Obsolete version ?\n ' if (d == 0): return BooleConstant(1) if (not variables): return [] variables = sorted(set(variables), reverse=True, key=top_index) m = varia...
def all_monomials_of_degree_d(d, variables): '\n Return monomials of degree d in the given variables.\n ' variables = Monomial(variables) variables = list(variables.variables()) if (not variables): assert (d == 0) return BooleConstant(1) ring = variables[0].ring() if (d >...
def power_set(variables): '\n Return all subsets of the given variables.\n ' if (not variables): return BooleConstant(1) variables = sorted(set(variables), reverse=True, key=top_index) res = Polynomial(1, variables[0].ring()).set() for v in variables: res = if_then_else(v, re...
def monomial_from_indices(ring, indices): res = Monomial(ring) for i in sorted(indices, reverse=True): res = (res * ring.variable(i)) return res
def used_vars(l, bound=None): if (not l): return BooleConstant(1) m = Monomial(Polynomial(next(iter(l))).vars_as_monomial()) for p in l[1:]: m = (m * Polynomial(p).vars_as_monomial()) if (bound and (len(m) > bound)): return m return m
def used_vars_set(l, bound=None): if (not l): return BooleConstant(1) s = set() for p in l: s.update(Polynomial(p).vars_as_monomial().variables()) if (bound and (len(s) > bound)): break sorted_s = sorted(list(s), key=top_index, reverse=True) m = Monomial(next(it...
class Polynomial_generic_sparse(Polynomial): "\n A generic sparse polynomial.\n\n The ``Polynomial_generic_sparse`` class defines functionality for sparse\n polynomials over any base ring. A sparse polynomial is represented using a\n dictionary which maps each exponent to the corresponding coefficient...
class Polynomial_generic_domain(Polynomial, IntegralDomainElement): def __init__(self, parent, is_gen=False, construct=False): Polynomial.__init__(self, parent, is_gen=is_gen) def is_unit(self): '\n Return ``True`` if this polynomial is a unit.\n\n *EXERCISE* (Atiyah-McDonald, ...
class Polynomial_generic_field(Polynomial_singular_repr, Polynomial_generic_domain, EuclideanDomainElement): @coerce_binop def quo_rem(self, other): '\n Return a tuple ``(quotient, remainder)`` where\n ``self = quotient * other + remainder``.\n\n EXAMPLES::\n\n sage: #...
class Polynomial_generic_sparse_field(Polynomial_generic_sparse, Polynomial_generic_field): "\n EXAMPLES::\n\n sage: R.<x> = PolynomialRing(Frac(RR['t']), sparse=True)\n sage: f = x^3 - x + 17\n sage: type(f)\n <class 'sage.rings.polynomial.polynomial_ring.PolynomialRing_field_with_...
class Polynomial_generic_dense_field(Polynomial_generic_dense, Polynomial_generic_field): def __init__(self, parent, x=None, check=True, is_gen=False, construct=False): Polynomial_generic_dense.__init__(self, parent, x, check, is_gen)
class Polynomial_generic_cdv(Polynomial_generic_domain): '\n A generic class for polynomials over complete discrete\n valuation domains and fields.\n\n AUTHOR:\n\n - Xavier Caruso (2013-03)\n ' def newton_slopes(self, repetition=True): '\n Return a list of the Newton slopes of t...
class Polynomial_generic_dense_cdv(Polynomial_generic_dense_inexact, Polynomial_generic_cdv): pass
class Polynomial_generic_sparse_cdv(Polynomial_generic_sparse, Polynomial_generic_cdv): pass
class Polynomial_generic_cdvr(Polynomial_generic_cdv): pass
class Polynomial_generic_dense_cdvr(Polynomial_generic_dense_cdv, Polynomial_generic_cdvr): pass
class Polynomial_generic_sparse_cdvr(Polynomial_generic_sparse_cdv, Polynomial_generic_cdvr): pass
class Polynomial_generic_cdvf(Polynomial_generic_cdv, Polynomial_generic_field): pass
class Polynomial_generic_dense_cdvf(Polynomial_generic_dense_cdv, Polynomial_generic_cdvf): pass
class Polynomial_generic_sparse_cdvf(Polynomial_generic_sparse_cdv, Polynomial_generic_cdvf): pass
def _mul_fateman_to_int2(f_list, g_list): '\n Convert a polynomial to an integer by evaluating it\n\n INPUT: p, a list of integers\n\n OUTPUT: padding\n ' max_coeff_f = max([abs(i) for i in f_list]) max_coeff_g = max([abs(i) for i in g_list]) b = (((1 + min(len(f_list), len(g_list))) * max...
def _mul_fateman_to_poly(number, padding): '\n Converts a number to a polynomial, according to a padding.\n\n OUTPUT:\n\n a list containing the coefficient of a polynomial of degree len(list)\n ' coeffs = [] flag = 0 append = coeffs.append if (number < 0): number = (- number) ...
def _mul_fateman_mul(f, g): '\n Multiply 2 polynomials\n ' f = f.change_ring(QQ) g = g.change_ring(QQ) f_list = f.list() g_list = g.list() fgcd = f_list[0].content(f_list) ggcd = g_list[0].content(g_list) z_poly_f = (f * fgcd.denominator()).change_ring(ZZ) z_poly_g = (g * ggc...
class PolynomialQuotientRingFactory(UniqueFactory): '\n Create a quotient of a polynomial ring.\n\n INPUT:\n\n - ``ring`` - a univariate polynomial ring\n\n - ``polynomial`` - an element of ``ring`` with a unit leading coefficient\n\n - ``names`` - (optional) name for the variable\n\n OUTPUT:...
def is_PolynomialQuotientRing(x): return isinstance(x, PolynomialQuotientRing_generic)
class PolynomialQuotientRing_generic(QuotientRing_generic): "\n Quotient of a univariate polynomial ring by an ideal.\n\n EXAMPLES::\n\n sage: R.<x> = PolynomialRing(Integers(8)); R\n Univariate Polynomial Ring in x over Ring of integers modulo 8\n sage: S.<xbar> = R.quotient(x^2 + 1); ...
class PolynomialQuotientRing_coercion(DefaultConvertMap_unique): "\n A coercion map from a :class:`PolynomialQuotientRing` to a\n :class:`PolynomialQuotientRing` that restricts to the coercion map on the\n underlying ring of constants.\n\n EXAMPLES::\n\n sage: R.<x> = ZZ[]\n sage: S.<x> ...
class PolynomialQuotientRing_domain(PolynomialQuotientRing_generic, IntegralDomain): '\n EXAMPLES::\n\n sage: R.<x> = PolynomialRing(ZZ)\n sage: S.<xbar> = R.quotient(x^2 + 1)\n sage: S\n Univariate Quotient Polynomial Ring in xbar\n over Integer Ring with modulus x^2 + 1\n ...
class PolynomialQuotientRing_field(PolynomialQuotientRing_domain, Field): '\n EXAMPLES::\n\n sage: # needs sage.rings.number_field\n sage: R.<x> = PolynomialRing(QQ)\n sage: S.<xbar> = R.quotient(x^2 + 1)\n sage: S\n Univariate Quotient Polynomial Ring in xbar over Rational F...
class PolynomialQuotientRingElement(polynomial_singular_interface.Polynomial_singular_repr, CommutativeRingElement): "\n Element of a quotient of a polynomial ring.\n\n EXAMPLES::\n\n sage: P.<x> = QQ[]\n sage: Q.<xi> = P.quo([(x^2 + 1)])\n sage: xi^2\n -1\n sage: singular...
def is_PolynomialRing(x): '\n Return ``True`` if ``x`` is a *univariate* polynomial ring (and not a\n sparse multivariate polynomial ring in one variable).\n\n EXAMPLES::\n\n sage: from sage.rings.polynomial.polynomial_ring import is_PolynomialRing\n sage: from sage.rings.polynomial.multi_p...
class PolynomialRing_general(ring.Algebra): '\n Univariate polynomial ring over a ring.\n ' def __init__(self, base_ring, name=None, sparse=False, implementation=None, element_class=None, category=None): "\n EXAMPLES::\n\n sage: R.<x> = QQ['x']\n sage: R(-1) + R(1)\...
class PolynomialRing_commutative(PolynomialRing_general, ring.CommutativeAlgebra): '\n Univariate polynomial ring over a commutative ring.\n ' def __init__(self, base_ring, name=None, sparse=False, implementation=None, element_class=None, category=None): if (base_ring not in _CommutativeRings):...
class PolynomialRing_integral_domain(PolynomialRing_commutative, PolynomialRing_singular_repr, ring.IntegralDomain): def __init__(self, base_ring, name='x', sparse=False, implementation=None, element_class=None, category=None): "\n TESTS::\n\n sage: from sage.rings.polynomial.polynomial...
class PolynomialRing_field(PolynomialRing_integral_domain, ring.PrincipalIdealDomain): def __init__(self, base_ring, name='x', sparse=False, implementation=None, element_class=None, category=None): "\n TESTS::\n\n sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_fi...
class PolynomialRing_dense_finite_field(PolynomialRing_field): "\n Univariate polynomial ring over a finite field.\n\n EXAMPLES::\n\n sage: R = PolynomialRing(GF(27, 'a'), 'x') # needs sage.rings.finite_rings\n sage: type(R) ...
class PolynomialRing_cdvr(PolynomialRing_integral_domain): '\n A class for polynomial ring over complete discrete valuation rings\n ' def __init__(self, base_ring, name=None, sparse=False, implementation=None, element_class=None, category=None): '\n TESTS::\n\n sage: from sage...
class PolynomialRing_cdvf(PolynomialRing_cdvr, PolynomialRing_field): '\n A class for polynomial ring over complete discrete valuation fields\n ' def __init__(self, base_ring, name=None, sparse=False, implementation=None, element_class=None, category=None): '\n TESTS::\n\n sag...
class PolynomialRing_dense_padic_ring_generic(PolynomialRing_cdvr): '\n A class for dense polynomial ring over p-adic rings\n ' def __init__(self, base_ring, name=None, implementation=None, element_class=None, category=None): PolynomialRing_cdvr.__init__(self, base_ring, sparse=False, name=name...
class PolynomialRing_dense_padic_field_generic(PolynomialRing_cdvf): '\n A class for dense polynomial ring over p-adic fields\n ' def __init__(self, base_ring, name=None, implementation=None, element_class=None, category=None): PolynomialRing_cdvf.__init__(self, base_ring, sparse=False, name=na...
class PolynomialRing_dense_padic_ring_capped_relative(PolynomialRing_dense_padic_ring_generic): def __init__(self, base_ring, name=None, implementation=None, element_class=None, category=None): "\n TESTS::\n\n sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dense_...
class PolynomialRing_dense_padic_ring_capped_absolute(PolynomialRing_dense_padic_ring_generic): def __init__(self, base_ring, name=None, implementation=None, element_class=None, category=None): "\n TESTS::\n\n sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dense_...
class PolynomialRing_dense_padic_ring_fixed_mod(PolynomialRing_dense_padic_ring_generic): def __init__(self, base_ring, name=None, implementation=None, element_class=None, category=None): "\n TESTS::\n\n sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dense_padic_...
class PolynomialRing_dense_padic_field_capped_relative(PolynomialRing_dense_padic_field_generic): def __init__(self, base_ring, name=None, implementation=None, element_class=None, category=None): "\n TESTS::\n\n sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dens...
class PolynomialRing_dense_mod_n(PolynomialRing_commutative): def __init__(self, base_ring, name=None, element_class=None, implementation=None, category=None): "\n TESTS::\n\n sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_dense_mod_n as PRing\n sage: ...
class PolynomialRing_dense_mod_p(PolynomialRing_dense_finite_field, PolynomialRing_dense_mod_n, PolynomialRing_singular_repr): def __init__(self, base_ring, name='x', implementation=None, element_class=None, category=None): "\n TESTS::\n\n sage: P = GF(2)['x']; P ...
def polygen(ring_or_element, name='x'): '\n Return a polynomial indeterminate.\n\n INPUT:\n\n - ``polygen(base_ring, name="x")``\n\n - ``polygen(ring_element, name="x")``\n\n If the first input is a ring, return a polynomial generator over\n that ring. If it is a ring element, return a polynomia...
def polygens(base_ring, names='x', *args): "\n Return indeterminates over the given base ring with the given\n names.\n\n EXAMPLES::\n\n sage: x,y,z = polygens(QQ,'x,y,z')\n sage: (x+y+z)^2\n x^2 + 2*x*y + y^2 + 2*x*z + 2*y*z + z^2\n sage: parent(x)\n Multivariate Polyn...
def PolynomialRing(base_ring, *args, **kwds): '\n Return the globally unique univariate or multivariate polynomial\n ring with given properties and variable name or names.\n\n There are many ways to specify the variables for the polynomial ring:\n\n 1. ``PolynomialRing(base_ring, name, ...)``\n 2. ...
def unpickle_PolynomialRing(base_ring, arg1=None, arg2=None, sparse=False): '\n Custom unpickling function for polynomial rings.\n\n This has the same positional arguments as the old\n ``PolynomialRing`` constructor before :trac:`23338`.\n ' args = [arg for arg in (arg1, arg2) if (arg is not None)...
def _get_from_cache(key): key = tuple(key) return _cache.get(key)
def _save_in_cache(key, R): key = tuple(key) _cache[key] = R
def _single_variate(base_ring, name, sparse=None, implementation=None, order=None): sparse = bool(sparse) key = [base_ring, name, sparse, implementation] R = _get_from_cache(key) if (R is not None): return R from . import polynomial_ring constructor = None kwds = {} if sparse: ...
def _multi_variate(base_ring, names, sparse=None, order='degrevlex', implementation=None): if (sparse is None): sparse = True if (not sparse): raise NotImplementedError('a dense representation of multivariate polynomials is not supported') from sage.rings.polynomial.term_order import TermO...
@weak_cached_function def polynomial_default_category(base_ring_category, n_variables): "\n Choose an appropriate category for a polynomial ring.\n\n It is assumed that the corresponding base ring is nonzero.\n\n INPUT:\n\n - ``base_ring_category`` -- The category of ring over which the polynomial\n ...
def BooleanPolynomialRing_constructor(n=None, names=None, order='lex'): "\n Construct a boolean polynomial ring with the following\n parameters:\n\n INPUT:\n\n - ``n`` -- number of variables (an integer > 1)\n - ``names`` -- names of ring variables, may be a string or list/tuple of strings\n - `...
def _do_singular_init_(singular, base_ring, char, _vars, order): "\n Implementation of :meth:`PolynomialRing_singular_repr._singular_init_`.\n\n This code was extracted from :class:`PolynomialRing_singular_repr`\n to make it callable from other places, in particular\n :class:`MPolynomialRing_libsingul...
class PolynomialRing_singular_repr(): '\n Implements methods to convert polynomial rings to Singular.\n\n This class is a base class for all univariate and multivariate\n polynomial rings which support conversion from and to Singular\n rings.\n ' def _singular_(self, singular=singular): ...
def can_convert_to_singular(R): "\n Return ``True`` if this ring's base field or ring can be\n represented in Singular, and the polynomial ring has at\n least one generator.\n\n The following base rings are supported: finite fields,\n rationals, number fields, and real and complex fields.\n\n EX...
class Polynomial_singular_repr(): '\n Implements coercion of polynomials to Singular polynomials.\n\n This class is a base class for all (univariate and multivariate)\n polynomial classes which support conversion from and to\n Singular polynomials.\n\n Due to the incompatibility of Python extension...
def _singular_func(self, singular=singular): '\n Return Singular polynomial matching this polynomial.\n\n INPUT:\n\n - ``singular`` - Singular instance to use.\n\n EXAMPLES::\n\n sage: # needs sage.libs.singular\n sage: P.<a,b> = PolynomialRing(GF(7), 2)\n sage: f = (a^3 + 2*b^2*a...
def _singular_init_func(self, singular=singular): '\n Return corresponding Singular polynomial but enforce that a new\n instance is created in the Singular interpreter.\n\n Use ``self._singular_()`` instead.\n ' self.parent()._singular_(singular).set_ring() self.__singular = singular(str(self)...
def _base_ring_to_fraction_field(S): "\n Return the unique skew polynomial ring over the fraction field of\n ``S.base_ring()`` which has ``S`` a sub-ring (internal method).\n\n INPUT:\n\n - ``S`` -- a skew polynomial ring\n\n OUTPUT:\n\n - ``Q`` -- the skew polynomial ring over the fraction fiel...
def _minimal_vanishing_polynomial(R, eval_pts): "\n Return the minimal vanishing polynomial (internal function).\n\n See the documentation for\n :meth:`SkewPolynomialRing.minimal_vanishing_polynomial` for a description.\n\n INPUT:\n\n - ``R`` -- a skew polynomial ring over a field\n\n - ``eval_p...
def _lagrange_polynomial(R, eval_pts, values): "\n Return the Lagrange polynomial of the given points if it exists.\n\n Otherwise return an unspecified polynomial (internal method).\n\n See the documentation for\n :meth:`SkewPolynomialRing.lagrange_polynomial` for a description\n of Lagrange polyno...
class SkewPolynomialRing(OrePolynomialRing): def __init__(self, base_ring, morphism, derivation, name, sparse, category=None): '\n Initialize ``self``.\n\n INPUT:\n\n - ``base_ring`` -- a commutative ring\n\n - ``twisting_morphism`` -- an automorphism of the base ring\n\n ...
class SectionSkewPolynomialCenterInjection(Section): "\n Section of the canonical injection of the center of a skew\n polynomial ring into this ring.\n\n TESTS::\n\n sage: # needs sage.rings.finite_rings\n sage: k.<a> = GF(5^3)\n sage: S.<x> = SkewPolynomialRing(k, k.frobenius_endomo...
class SkewPolynomialCenterInjection(RingHomomorphism): "\n Canonical injection of the center of a skew polynomial ring\n into this ring.\n\n TESTS::\n\n sage: # needs sage.rings.finite_rings\n sage: k.<a> = GF(5^3)\n sage: S.<x> = SkewPolynomialRing(k, k.frobenius_endomorphism())\n ...
class SkewPolynomialRing_finite_order(SkewPolynomialRing): '\n A specialized class for skew polynomial rings whose twising morphism\n has finite order.\n\n .. SEEALSO::\n\n - :class:`sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing`\n - :mod:`sage.rings.polynomial.skew_polynomi...
class SkewPolynomialRing_finite_field(SkewPolynomialRing_finite_order): '\n A specialized class for skew polynomial rings over finite fields.\n\n .. SEEALSO::\n\n - :class:`sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing`\n - :mod:`sage.rings.polynomial.skew_polynomial_finite_fie...
class SymmetricIdeal(Ideal_generic): "\n Ideal in an Infinite Polynomial Ring, invariant under permutation of variable indices\n\n THEORY:\n\n An Infinite Polynomial Ring with finitely many generators `x_\\ast,\n y_\\ast, ...` over a field `F` is a free commutative `F`-algebra\n generated by infini...
class TermOrder(SageObject): '\n A term order.\n\n See ``sage.rings.polynomial.term_order`` for details on supported\n term orders.\n ' def __setstate__(self, dict): "\n Translate old pickled TermOrder objects.\n\n See Issue :issue:`11316`.\n\n EXAMPLES::\n\n ...
def termorder_from_singular(S): "\n Return the Sage term order of the basering in the given Singular interface\n\n INPUT:\n\n An instance of the Singular interface.\n\n EXAMPLES::\n\n sage: from sage.rings.polynomial.term_order import termorder_from_singular\n sage: singular.eval('ring r...
def spol(f, g): '\n Compute the S-polynomial of f and g.\n\n INPUT:\n\n - ``f, g`` -- polynomials\n\n OUTPUT: the S-polynomial of f and g\n\n EXAMPLES::\n\n sage: R.<x,y,z> = PolynomialRing(QQ)\n sage: from sage.rings.polynomial.toy_buchberger import spol\n sage: spol(x^2 - z ...
def buchberger(F): "\n Compute a Groebner basis using the original version of Buchberger's\n algorithm as presented in [BW1993]_, page 214.\n\n INPUT:\n\n - ``F`` -- an ideal in a multivariate polynomial ring\n\n OUTPUT: a Groebner basis for F\n\n .. NOTE::\n\n The verbosity of this functi...
def buchberger_improved(F): "\n Compute a Groebner basis using an improved version of Buchberger's\n algorithm as presented in [BW1993]_, page 232.\n\n This variant uses the Gebauer-Moeller Installation to apply\n Buchberger's first and second criterion to avoid useless pairs.\n\n INPUT:\n\n - `...
def update(G, B, h): "\n Update ``G`` using the set of critical pairs ``B`` and the\n polynomial ``h`` as presented in [BW1993]_, page 230. For this,\n Buchberger's first and second criterion are tested.\n\n This function implements the Gebauer-Moeller Installation.\n\n INPUT:\n\n - ``G`` -- an ...
def select(P): "\n Select a polynomial using the normal selection strategy.\n\n INPUT:\n\n - ``P`` -- a list of critical pairs\n\n OUTPUT: an element of P\n\n EXAMPLES::\n\n sage: from sage.rings.polynomial.toy_buchberger import select\n sage: R.<x,y,z> = PolynomialRing(QQ, order='lex...
def inter_reduction(Q): '\n Compute inter-reduced polynomials from a set of polynomials.\n\n INPUT:\n\n - ``Q`` -- a set of polynomials\n\n OUTPUT:\n\n if ``Q`` is the set `f_1, ..., f_n`, this method returns `g_1,\n ..., g_s` such that:\n\n - `(f_1,...,f_n) = (g_1,...,g_s)`\n - `LM(g_i) \...
def spol(g1, g2): "\n Return the S-Polynomial of ``g_1`` and ``g_2``.\n\n Let `a_i t_i` be `LT(g_i)`, `b_i = a/a_i` with `a = LCM(a_i,a_j)`,\n and `s_i = t/t_i` with `t = LCM(t_i,t_j)`. Then the S-Polynomial\n is defined as: `b_1s_1g_1 - b_2s_2g_2`.\n\n INPUT:\n\n - ``g1`` -- polynomial\n - `...
def gpol(g1, g2): "\n Return the G-Polynomial of ``g_1`` and ``g_2``.\n\n Let `a_i t_i` be `LT(g_i)`, `a = a_i*c_i + a_j*c_j` with `a =\n GCD(a_i,a_j)`, and `s_i = t/t_i` with `t = LCM(t_i,t_j)`. Then the\n G-Polynomial is defined as: `c_1s_1g_1 - c_2s_2g_2`.\n\n INPUT:\n\n - ``g1`` -- polynomia...
def LM(f): return f.lm()
def LC(f): return f.lc()
def d_basis(F, strat=True): '\n Return the `d`-basis for the Ideal ``F`` as defined in [BW1993]_.\n\n INPUT:\n\n - ``F`` -- an ideal\n - ``strat`` -- use update strategy (default: ``True``)\n\n EXAMPLES::\n\n sage: from sage.rings.polynomial.toy_d_basis import d_basis\n sage: A.<x,y> ...
def select(P): '\n The normal selection strategy.\n\n INPUT:\n\n - ``P`` -- a list of critical pairs\n\n OUTPUT:\n\n an element of P\n\n EXAMPLES::\n\n sage: from sage.rings.polynomial.toy_d_basis import select\n sage: A.<x,y> = PolynomialRing(ZZ, 2)\n sage: f = -y^2 - y + x...
def update(G, B, h): "\n Update ``G`` using the list of critical pairs ``B`` and the\n polynomial ``h`` as presented in [BW1993]_, page 230. For this,\n Buchberger's first and second criterion are tested.\n\n This function uses the Gebauer-Moeller Installation.\n\n INPUT:\n\n - ``G`` -- an inter...
def is_triangular(B) -> bool: '\n Check whether the basis ``B`` of an ideal is triangular.\n\n That is: check whether the largest variable in ``B[i]`` with\n respect to the ordering of the base ring ``R`` is ``R.gens()[i]``.\n\n The algorithm is based on the definition of a triangular basis,\n give...
def coefficient_matrix(polys): '\n Generate the matrix ``M`` whose entries are the coefficients of ``polys``.\n\n The entries of row ``i`` of ``M`` consist of the coefficients of\n ``polys[i]``.\n\n INPUT:\n\n - ``polys`` -- a list/tuple of polynomials\n\n OUTPUT:\n\n A matrix ``M`` of the co...