Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Singular's Groebner Strategy Objects
AUTHORS:
- Martin Albrecht (2009-07): initial implementation - Michael Brickenstein (2009-07): initial implementation - Hans Schoenemann (2009-07): initial implementation """
#***************************************************************************** # Copyright (C) 2009 Martin Albrecht <M.R.Albrecht@rhul.ac.uk> # Copyright (C) 2009 Michael Brickenstein <brickenstein@mfo.de> # Copyright (C) 2009 Hans Schoenemann <hannes@mathematik.uni-kl.de> # # Distributed under the terms of the GNU General Public License (GPL) # http://www.gnu.org/licenses/ #*****************************************************************************
cdef extern from *: # hack to get at cython macro int unlikely(int) int likely(int)
from sage.structure.richcmp cimport richcmp from sage.libs.singular.decl cimport ideal, ring, poly, currRing from sage.libs.singular.decl cimport rChangeCurrRing from sage.libs.singular.decl cimport new_skStrategy, delete_skStrategy, id_RankFreeModule from sage.libs.singular.decl cimport initEcartBBA, enterSBba, initBuchMoraCrit, initS, pNorm, id_Delete, kTest from sage.libs.singular.decl cimport omfree, redNF, p_Copy, redtailBba
from sage.libs.singular.ring cimport singular_ring_reference, singular_ring_delete
from sage.rings.polynomial.multi_polynomial_ideal_libsingular cimport sage_ideal_to_singular_ideal from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomial_libsingular, MPolynomialRing_libsingular, new_MP from sage.rings.polynomial.plural cimport new_NCP
cdef class GroebnerStrategy(SageObject): """ A Wrapper for Singular's Groebner Strategy Object.
This object provides functions for normal form computations and other functions for Groebner basis computation.
ALGORITHM:
Uses Singular via libSINGULAR """ def __cinit__(self, L): """ Create a new :class:`GroebnerStrategy` object for the generators of the ideal ``L``.
INPUT:
- ``L`` - a multivariate polynomial ideal
EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P.<x,y,z> = PolynomialRing(QQ) sage: I = Ideal([x+z,y+z+1]) sage: strat = GroebnerStrategy(I); strat Groebner Strategy for ideal generated by 2 elements over Multivariate Polynomial Ring in x, y, z over Rational Field
TESTS::
sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: strat = GroebnerStrategy(None) Traceback (most recent call last): ... TypeError: First parameter must be a multivariate polynomial ideal.
sage: P.<x,y,z> = PolynomialRing(QQ,order='neglex') sage: I = Ideal([x+z,y+z+1]) sage: strat = GroebnerStrategy(I) Traceback (most recent call last): ... NotImplementedError: The local case is not implemented yet.
sage: P.<x,y,z> = PolynomialRing(CC,order='neglex') sage: I = Ideal([x+z,y+z+1]) sage: strat = GroebnerStrategy(I) Traceback (most recent call last): ... TypeError: First parameter's ring must be multivariate polynomial ring via libsingular.
sage: P.<x,y,z> = PolynomialRing(ZZ) sage: I = Ideal([x+z,y+z+1]) sage: strat = GroebnerStrategy(I) Traceback (most recent call last): ... NotImplementedError: Only coefficient fields are implemented so far.
"""
rChangeCurrRing(R._ring)
#- creating temp data structures #- set S #- init local data struct
cdef int j rChangeCurrRing(R._ring)
def __dealloc__(self): """ TESTS::
sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P.<x,y,z> = PolynomialRing(GF(32003)) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: del strat """ # WARNING: the Cython class self._parent is no longer accessible! # see http://trac.sagemath.org/sage_trac/ticket/11339
else:
def _repr_(self): """ TESTS::
sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P.<x,y,z> = PolynomialRing(GF(32003)) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: strat # indirect doctest Groebner Strategy for ideal generated by 2 elements over Multivariate Polynomial Ring in x, y, z over Finite Field of size 32003 """
def ideal(self): """ Return the ideal this strategy object is defined for.
EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P.<x,y,z> = PolynomialRing(GF(32003)) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: strat.ideal() Ideal (x + z, y + z) of Multivariate Polynomial Ring in x, y, z over Finite Field of size 32003 """
def ring(self): """ Return the ring this strategy object is defined over.
EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P.<x,y,z> = PolynomialRing(GF(32003)) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: strat.ring() Multivariate Polynomial Ring in x, y, z over Finite Field of size 32003 """
def __richcmp__(self, other, op): """ EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P.<x,y,z> = PolynomialRing(GF(19)) sage: I = Ideal([P(0)]) sage: strat = GroebnerStrategy(I) sage: strat == GroebnerStrategy(I) True sage: I = Ideal([x+1,y+z]) sage: strat == GroebnerStrategy(I) False """ except TypeError: return NotImplemented
def __reduce__(self): """ EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P.<x,y,z> = PolynomialRing(GF(32003)) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: loads(dumps(strat)) == strat True """
cpdef MPolynomial_libsingular normal_form(self, MPolynomial_libsingular p): """ Compute the normal form of ``p`` with respect to the generators of this object.
EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P.<x,y,z> = PolynomialRing(QQ) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: strat.normal_form(x*y) # indirect doctest z^2 sage: strat.normal_form(x + 1) -z + 1
TESTS::
sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P.<x,y,z> = PolynomialRing(QQ) sage: I = Ideal([P(0)]) sage: strat = GroebnerStrategy(I) sage: strat.normal_form(x) x sage: strat.normal_form(P(0)) 0 """ raise TypeError("parent(p) must be the same as this object's parent.") rChangeCurrRing(self._parent._ring)
cdef class NCGroebnerStrategy(SageObject): """ A Wrapper for Singular's Groebner Strategy Object.
This object provides functions for normal form computations and other functions for Groebner basis computation.
ALGORITHM:
Uses Singular via libSINGULAR """ def __init__(self, L): """ Create a new :class:`GroebnerStrategy` object for the generators of the ideal ``L``.
INPUT:
- ``L`` - an ideal in a g-algebra
EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H.<x,y,z> = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one()]) sage: NCGroebnerStrategy(I) #random Groebner Strategy for ideal generated by 3 elements over Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z}
TESTS::
sage: strat = NCGroebnerStrategy(None) Traceback (most recent call last): ... TypeError: First parameter must be an ideal in a g-algebra.
sage: P.<x,y,z> = PolynomialRing(CC,order='neglex') sage: I = Ideal([x+z,y+z+1]) sage: strat = NCGroebnerStrategy(I) Traceback (most recent call last): ... TypeError: First parameter must be an ideal in a g-algebra.
"""
raise TypeError("First parameter's ring must be a g-algebra.")
raise NotImplementedError("The local case is not implemented yet.")
raise NotImplementedError("Only coefficient fields are implemented so far.")
rChangeCurrRing(R._ring)
#- creating temp data structures #- set S #- init local data struct
cdef int j
def __dealloc__(self): """ TESTS::
sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H.<x,y,z> = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one()]) sage: strat = NCGroebnerStrategy(I) sage: del strat # indirect doctest """
else:
def _repr_(self): """ TESTS::
sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H.<x,y,z> = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one()]) sage: strat = NCGroebnerStrategy(I) sage: strat # indirect doctest #random Groebner Strategy for ideal generated by 3 elements over Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {z*x: x*z + 2*x, z*y: y*z - 2*y, y*x: x*y - z} """
def ideal(self): """ Return the ideal this strategy object is defined for.
EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H.<x,y,z> = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one()]) sage: strat = NCGroebnerStrategy(I) sage: strat.ideal() == I True
"""
def ring(self): """ Return the ring this strategy object is defined over.
EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H.<x,y,z> = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one()]) sage: strat = NCGroebnerStrategy(I) sage: strat.ring() is H True """
def __richcmp__(self, other, op): """ EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H.<x,y,z> = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one()]) sage: strat = NCGroebnerStrategy(I) sage: strat == NCGroebnerStrategy(I) True sage: I = H.ideal([y^2, x^2, z^2-H.one()], side='twosided') sage: strat == NCGroebnerStrategy(I) False """ except TypeError: return NotImplemented
def __reduce__(self): """ EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H.<x,y,z> = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one()]) sage: strat = NCGroebnerStrategy(I) sage: loads(dumps(strat)) == strat True """
cpdef NCPolynomial_plural normal_form(self, NCPolynomial_plural p): """ Compute the normal form of ``p`` with respect to the generators of this object.
EXAMPLES::
sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H.<x,y,z> = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: JL = H.ideal([x^3, y^3, z^3 - 4*z]) sage: JT = H.ideal([x^3, y^3, z^3 - 4*z], side='twosided') sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: SL = NCGroebnerStrategy(JL.std()) sage: ST = NCGroebnerStrategy(JT.std()) sage: SL.normal_form(x*y^2) x*y^2 sage: ST.normal_form(x*y^2) y*z
""" raise TypeError("parent(p) must be the same as this object's parent.") rChangeCurrRing(self._parent._ring)
cdef int max_ind
""" EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A.<x,y,z> = FreeAlgebra(QQ, 3) sage: H.<x,y,z> = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one()]) sage: strat = NCGroebnerStrategy(I) sage: loads(dumps(strat)) == strat # indirect doctest True """
""" EXAMPLES::
sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P.<x,y,z> = PolynomialRing(GF(32003)) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: loads(dumps(strat)) == strat # indirect doctest True """ |