Ticket #1396: trac1396-singular_options.patch

File trac1396-singular_options.patch, 46.9 KB (added by malb, 11 years ago)

Replaces the first patch. Full support for all Singular options in both Singular and libSingular

  • sage/interfaces/singular.py

    # HG changeset patch
    # User Simon King <simon.king@nuigalway.ie>
    # Date 1279223562 -3600
    # Node ID 7c07c97169c0748a6c934526724130aa2891c45c
    # Parent  5b3daac3d2f739480475fdb551c91a0c73d4e488
    #1396: Allow Singular's options (including prot and degBound) in libSingular; use a method decorator to ensure default options unless requested otherwise.
    
    diff -r 5b3daac3d2f7 -r 7c07c97169c0 sage/interfaces/singular.py
    a b  
    381381        self.option("redTail")
    382382        self.option("redThrough")
    383383        self.option("intStrategy")
     384        self._saved_options = self.option('get')
    384385
    385386    def __reduce__(self):
    386387        """
  • sage/libs/singular/option.pyx

    diff -r 5b3daac3d2f7 -r 7c07c97169c0 sage/libs/singular/option.pyx
    a b  
    1717By default, tail reductions are performed::
    1818
    1919    sage: from sage.libs.singular.option import opt, opt_ctx
    20     sage: opt['redTail']
     20    sage: opt['red_tail']
    2121    True
    2222    sage: std(I)[-1]
    2323    d^2*e^6 + 28*b*c*d + ...
     
    2525If we don't want this, we can create an option context, which disables
    2626this::
    2727
    28     sage: with opt_ctx(redTail=False,redSB=False):
     28    sage: with opt_ctx(red_tail=False, red_sb=False):
    2929    ...      std(I)[-1]
    3030    d^2*e^6 + 8*c^3 + ...
    3131
    3232However, this does not affect the global state::
    3333
    34     sage: opt['redTail']
     34    sage: opt['red_tail']
    3535    True
    3636
    3737On the other hand, any assignment to an option object will immediately
    3838change the global state::
    3939
    40     sage: opt['redTail'] = False
    41     sage: opt['redTail']
     40    sage: opt['red_tail'] = False
     41    sage: opt['red_tail']
    4242    False
    43     sage: opt['redTail'] = True
    44     sage: opt['redTail']
     43    sage: opt['red_tail'] = True
     44    sage: opt['red_tail']
    4545    True
    4646
    4747Assigning values within an option context, only affects this context::
    4848
    4949    sage: with opt_ctx:
    50     ...      opt['redTail'] = False
     50    ...      opt['red_tail'] = False
    5151
    52     sage: opt['redTail']
     52    sage: opt['red_tail']
    5353    True
    5454
    5555Option contexts can also be safely stacked::
    5656
    5757    sage: with opt_ctx:
    58     ...       opt['redTail'] = False
     58    ...       opt['red_tail'] = False
    5959    ...       print opt
    6060    ...       with opt_ctx:
    61     ...           opt['redThrough'] = False
     61    ...           opt['red_through'] = False
    6262    ...           print opt
    6363    ...
    6464    general options for libSingular (current value 0x00000082)
     
    6767    sage: print opt
    6868    general options for libSingular (current value 0x02000082)
    6969
     70Furthermore, the integer valued options ``deg_bound`` and
     71``mult_bound`` can be used::
     72
     73    sage: R.<x,y> = QQ[]
     74    sage: I = R*[x^3+y^2,x^2*y+1]
     75    sage: opt['deg_bound'] = 2
     76    sage: std(I)
     77    [x^2*y + 1, x^3 + y^2]
     78    sage: opt['deg_bound'] = 0
     79    sage: std(I)
     80    [y^3 - x, x^2*y + 1, x^3 + y^2]
    7081
    7182The same interface is available for verbosity options::
    7283
    7384    sage: from sage.libs.singular.option import opt_verb
    74     sage: opt_verb['notWarnSB']
     85    sage: opt_verb['not_warn_sb']
    7586    False
     87    sage: opt.reset_default()  # needed to avoid side effects
     88    sage: opt_verb.reset_default()  # needed to avoid side effects
    7689
    7790AUTHOR:
    7891
    7992- Martin Albrecht (2009-08): initial implementation
    8093- Martin Albrecht (2010-01): better interface, verbosity options
     94- Simon King (2010-07): Python-ic option names; deg_bound and mult_bound
    8195"""
    8296#*****************************************************************************
    8397#       Copyright (C) 2010 Martin Albrecht <M.R.Albrecht@rhul.ac.uk>
     
    86100#                  http://www.gnu.org/licenses/
    87101#*****************************************************************************
    88102
    89 from sage.libs.singular.decl cimport singular_options, singular_verbose_options
     103from sage.libs.singular.decl cimport singular_options, singular_verbose_options, Kstd1_deg, Kstd1_mu
    90104
    91 from sage.libs.singular.decl cimport OPT_PROT, OPT_REDSB, OPT_NOT_BUCKETS, OPT_NOT_SUGAR, OPT_SUGARCRIT, OPT_REDTHROUGH
     105from sage.libs.singular.decl cimport OPT_PROT, OPT_REDSB, OPT_NOT_BUCKETS, OPT_NOT_SUGAR, OPT_SUGARCRIT, OPT_REDTHROUGH, OPT_DEGBOUND, OPT_MULTBOUND
    92106from sage.libs.singular.decl cimport OPT_RETURN_SB, OPT_FASTHC, OPT_OLDSTD, OPT_REDTAIL, OPT_INTSTRATEGY, OPT_NOTREGULARITY
    93107from sage.libs.singular.decl cimport OPT_WEIGHTM, Sy_bit
    94108
     
    96110from sage.libs.singular.decl cimport V_LOAD_PROC, V_DEF_RES, V_DEBUG_MEM, V_SHOW_USE, V_IMAP, V_PROMPT
    97111from sage.libs.singular.decl cimport V_NSB, V_CONTENTSB, V_CANCELUNIT, V_DEG_STOP
    98112
     113_options_py_to_singular={'return_sb':'returnSB',
     114                         'fast_hc':'fastHC',
     115                         'inf_red_tail':'infRedTail',
     116                         'int_strategy':'intStrategy',
     117                         'not_regularity':'notRegularity',
     118                         'not_sugar':'notSugar',
     119                         'not_buckets':'notBuckets',
     120                         'qring_nf':'qringNF',
     121                         'redsb':'redSB',
     122                         'red_sb':'redSB',
     123                         'red_tail':'redTail',
     124                         'red_through':'redThrough',
     125                         'sugar_crit':'sugarCrit',
     126                         'weight_m':'weightM',
     127                         'content_sb':'contentSB',
     128                         'mult_bound':'multBound',
     129                         'deg_bound':'degBound',
     130                         'imap':'Imap',
     131                         'debug_lib':'debugLib',
     132                         'def_res':'defRes',
     133                         'load_lib':'loadLib',
     134                         'load_proc':'loadProc',
     135                         'not_warn_sb':'notWarnSB'}
    99136
    100137cdef class LibSingularOptions_abstract:
    101138    """
     
    120157            sage: opt['redTail'] = True
    121158            sage: opt['redTail']
    122159            True
     160            sage: opt['deg_bound'] = 2
     161
     162        The options can be named in Python or Singular style::
     163
     164            sage: opt['degBound']
     165            2
    123166        """
    124167        for k,v in kwds.iteritems():
    125168            self[k] = v
     
    129172        EXAMPLE::
    130173
    131174            sage: from sage.libs.singular.option import opt
    132             sage: opt['redTail']
     175            sage: opt['red_tail']
    133176            True
     177            sage: opt['deg_bound'] = 2
     178
     179        The options can be named in Python or Singular style::
     180
     181            sage: opt['degBound']
     182            2
     183            sage: opt.reset_default()  # needed to avoid side effects
    134184        """
     185        name = _options_py_to_singular.get(name,name)
     186        if name == "degBound":
     187            if bool(self.global_options[0] & self.name_map[name]):
     188                return Kstd1_deg
     189            return int(0)
     190        if name == "multBound":
     191            if bool(self.global_options[0] & self.name_map[name]):
     192                return Kstd1_mu
     193            return int(0)
    135194        try:
    136195            return bool(self.global_options[0] & self.name_map[name])
    137196        except KeyError:
     
    148207            ...      opt['redTail'] = False
    149208            ...      opt['redTail']
    150209            False
     210            sage: opt['red_tail']
     211            True
     212            sage: opt.reset_default()  # needed to avoid side effects
    151213        """
     214        name = _options_py_to_singular.get(name,name)
    152215        try:
    153216            if value:
    154217                self.global_options[0] = self.global_options[0] | self.name_map[name]
    155218            else:
    156219                self.global_options[0] = self.global_options[0] & ~self.name_map[name]
     220            if name == 'degBound':
     221                global Kstd1_deg
     222                Kstd1_deg = value
     223            elif name == 'multBound':
     224                global Kstd1_mu
     225                Kstd1_mu = value
    157226        except KeyError:
    158227            raise NameError("Option '%s' unknown."%(name,))
    159228
     
    163232
    164233            sage: from sage.libs.singular.option import opt
    165234            sage: hex(int(opt))
    166             '0x2000082'
     235            '0x6000082'
    167236        """
    168237        return int(self.global_options[0])
    169238
     239    def save(self):
     240        """
     241        Return a triple of integers that allow reconstruction of the options.
     242
     243        EXAMPLE::
     244
     245            sage: from sage.libs.singular.option import opt
     246            sage: opt['deg_bound']
     247            0
     248            sage: opt['red_tail']
     249            True
     250            sage: s = opt.save()
     251            sage: opt['deg_bound'] = 2
     252            sage: opt['red_tail'] = False
     253            sage: opt['deg_bound']
     254            2
     255            sage: opt['red_tail']
     256            False
     257            sage: opt.load(s)
     258            sage: opt['deg_bound']
     259            0
     260            sage: opt['red_tail']
     261            True
     262            sage: opt.reset_default()  # needed to avoid side effects
     263        """
     264        return (int(self.global_options[0]), self['deg_bound'], self['mult_bound'])
     265
    170266    def load(self, value=None):
    171267        """
    172268        EXAMPLE::
    173269
    174270            sage: from sage.libs.singular.option import opt as sopt
    175             sage: bck = int(sopt); hex(bck)
    176             '0x2000082'
     271            sage: bck = sopt.save(); hex(bck[0]), bck[1], bck[2]
     272            ('0x6000082', 0, 0)
    177273            sage: sopt['redTail'] = False
    178274            sage: hex(int(sopt))
    179             '0x82'
     275            '0x4000082'
    180276            sage: sopt.load(bck)
    181277            sage: sopt['redTail']
    182278            True
    183279        """
    184         self.global_options[0] = int(value)
     280        if value == None:
     281            value = (None,0,0)
     282        self.global_options[0] = int(value[0])
     283        global Kstd1_deg
     284        global Kstd1_mu
     285        Kstd1_deg = value[1]
     286        Kstd1_mu  = value[2]
    185287
    186288    def __repr__(self):
    187289        """
     
    189291
    190292            sage: from sage.libs.singular.option import opt as sopt
    191293            sage: sopt
    192             general options for libSingular (current value 0x02000082)
     294            general options for libSingular (current value 0x06000082)
    193295        """
    194296        return "%s options for libSingular (current value 0x%08x)"%(self.name, self.global_options[0])
    195297
     
    200302
    201303    Supported options are:
    202304
    203      - ``returnSB`` - the functions syz, intersect, quotient, modulo
    204        return a standard base instead of a generating set if returnSB
    205        is set. This option should not be used for lift.
     305     - ``return_sb`` or ``returnSB`` - the functions ``syz``,
     306       ``intersect``, ``quotient``, ``modulo`` return a standard
     307       base instead of a generating set if ``return_sb``
     308       is set. This option should not be used for ``lift``.
    206309
    207      - ``fastHC`` - tries to find the highest corner of the
    208        staircase (HC) as fast as possible during a standard basis
    209        computation (only used for local orderings).
     310     - ``fast_hc`` or ``fastHC`` - tries to find the highest corner
     311       of the staircase (HC) as fast as possible during a standard
     312       basis computation (only used for local orderings).
    210313
    211      - ``intStrategy`` - avoids division of coefficients during
    212        standard basis computations. This option is ring dependent. By
    213        default, it is set for rings with characteristic 0 and not set
    214        for all other rings.
     314     - ``int_strategy`` or ``intStrategy`` - avoids division of
     315       coefficients during standard basis computations. This option
     316       is ring dependent. By default, it is set for rings with
     317       characteristic 0 and not set for all other rings.
    215318
    216319     - ``lazy`` - uses a more lazy approach in std computations, which
    217320       was used in SINGULAR version before 2-0 (and which may lead to
    218        faster or slower computations, depending on the example)
     321       faster or slower computations, depending on the example).
    219322
    220      - ``length`` - select shorter reducers in std computations,
     323     - ``length`` - select shorter reducers in std computations.
    221324
    222      - ``notRegularity`` - disables the regularity bound for ``res`` and
    223        ``mres`` (see regularity).
     325     - ``not_regularity`` or ``notRegularity`` - disables the
     326       regularity bound for ``res`` and ``mres``.
    224327
    225      - ``notSugar`` - disables the sugar strategy during standard
    226        basis computation.
     328     - ``not_sugar`` or ``notSugar`` - disables the sugar strategy
     329       during standard basis computation.
    227330
    228      - ``notBuckets`` - disables the bucket representation of
    229        polynomials during standard basis computations. This option
    230        usually decreases the memory usage but increases the
    231        computation time. It should only be set for memory-critical
    232        standard basis computations.
     331     - ``not_buckets`` or ``notBuckets`` - disables the bucket
     332       representation of polynomials during standard basis
     333       computations. This option usually decreases the memory
     334       usage but increases the computation time. It should only
     335       be set for memory-critical standard basis computations.
    233336
    234      - ``oldStd`` - uses a more lazy approach in std computations,
    235        which was used in SINGULAR version before 2-0 (and which may
    236        lead to faster or slower computations, depending on the
    237        example)
     337     - ``old_std`` or ``oldStd`` - uses a more lazy approach in std
     338       computations, which was used in SINGULAR version before 2-0
     339       (and which may lead to faster or slower computations, depending
     340       on the example).
    238341
    239342     - ``prot`` - shows protocol information indicating the progress
    240343       during the following computations: ``facstd``, ``fglm``,
    241344       ``groebner``, ``lres``, ``mres``, ``minres``, ``mstd``,
    242        ``res``, ``slimgb``,``sres``, ``std``, ``stdfglm``,
     345       ``res``, ``slimgb``, ``sres``, ``std``, ``stdfglm``,
    243346       ``stdhilb``, ``syz``.
    244347
    245      - ``redSB`` - computes a reduced standard basis in any standard
    246        basis computation.
     348     - `red_sb`` or ``redSB`` - computes a reduced standard basis in
     349       any standard basis computation.
    247350
    248      - ``redTail`` - reduction of the tails of polynomials during
    249        standard basis computations. This option is ring dependent. By
    250        default, it is set for rings with global degree orderings and
    251        not set for all other rings.
     351     - ``red_tail`` or ``redTail`` - reduction of the tails of
     352       polynomials during standard basis computations. This option
     353       is ring dependent. By default, it is set for rings with global
     354       degree orderings and not set for all other rings.
    252355
    253      - ``redThrough`` - for inhomogenous input, polynomial reductions
    254        during standard basis computations are never postponed, but
    255        always finished through. This option is ring dependent. By
    256        default, it is set for rings with global degree orderings and
    257        not set for all other rings.
     356     - ``red_through`` or ``redThrough`` - for inhomogenous input,
     357       polynomial reductions during standard basis computations are
     358       never postponed, but always finished through. This option is
     359       ring dependent. By default, it is set for rings with global
     360       degree orderings and not set for all other rings.
    258361
    259      - ``sugarCrit`` - uses criteria similar to the homogeneous case
    260        to keep more useless pairs.
     362     - ``sugar_crit`` or ``sugarCrit`` - uses criteria similar to the
     363       homogeneous case to keep more useless pairs.
    261364
    262      - ``weightM`` - automatically computes suitable weights for the
    263        weighted ecart and the weighted sugar method.
    264                
     365     - ``weight_m`` or ``weightM`` - automatically computes suitable
     366       weights for the weighted ecart and the weighted sugar method.
     367   
     368    In addition, two integer valued parameters are supported, namely:
     369
     370    - ``deg_bound`` or ``degBound`` - The standard basis computation
     371      is stopped if the total (weighted) degree exceeds ``deg_bound``.
     372      ``deg_bound`` should not be used for a global ordering with
     373      inhomogeneous input. Reset this bound by setting ``deg_bound``
     374      to 0. The exact meaning of "degree" depends on the ring odering
     375      and the command: ``slimgb`` uses always the total degree with
     376      weights 1, ``std`` does so for block orderings, only.
     377
     378    - ``mult_bound`` or ``multBound`` - The standard basis computation
     379      is stopped if the ideal is zero-dimensional in a ring with local
     380      ordering and its multiplicity is lower than ``mult_bound``.
     381      Reset this bound by setting ``mult_bound`` to 0.
     382
    265383    EXAMPLE::
    266384
    267385        sage: from sage.libs.singular.option import LibSingularOptions
    268386        sage: libsingular_options = LibSingularOptions()
    269387        sage: libsingular_options
    270         general options for libSingular (current value 0x02000082)
     388        general options for libSingular (current value 0x06000082)
     389
     390    Here we demonstrate the intended way of using libSingular options::
     391
     392        sage: R.<x,y> = QQ[]
     393        sage: I = R*[x^3+y^2,x^2*y+1]
     394        sage: I.groebner_basis(deg_bound=2)
     395        [x^3 + y^2, x^2*y + 1]
     396        sage: I.groebner_basis()
     397        [x^3 + y^2, x^2*y + 1, y^3 - x]
     398
     399    The option ``mult_bound`` is only relevant in the local case::
     400
     401        sage: Rlocal.<x,y,z> = PolynomialRing(QQ, order='ds')
     402        sage: x^2<x
     403        True
     404        sage: J = [x^7+y^7+z^6,x^6+y^8+z^7,x^7+y^5+z^8, x^2*y^3+y^2*z^3+x^3*z^2,x^3*y^2+y^3*z^2+x^2*z^3]*Rlocal
     405        sage: J.groebner_basis(mult_bound=100)
     406        [x^3*y^2 + y^3*z^2 + x^2*z^3, x^2*y^3 + x^3*z^2 + y^2*z^3, y^5, x^6 + x*y^4*z^5, x^4*z^2 - y^4*z^2 - x^2*y*z^3 + x*y^2*z^3, z^6 - x*y^4*z^4 - x^3*y*z^5]
     407        sage: J.groebner_basis()
     408        [x^3*y^2 + y^3*z^2 + x^2*z^3, x^2*y^3 + x^3*z^2 + y^2*z^3, y^5, x^6, x^4*z^2 - y^4*z^2 - x^2*y*z^3 + x*y^2*z^3, z^6, y^4*z^3 - y^3*z^4 - x^2*z^5, x^3*y*z^4 - x^2*y^2*z^4 + x*y^3*z^4, x^3*z^5, x^2*y*z^5 + y^3*z^5, x*y^3*z^5]
     409
    271410    """
    272411    def __init__(self, **kwds):
    273412        """
     
    278417            sage: from sage.libs.singular.option import LibSingularOptions
    279418            sage: libsingular_options = LibSingularOptions()
    280419            sage: libsingular_options
    281             general options for libSingular (current value 0x02000082)
     420            general options for libSingular (current value 0x06000082)
    282421        """
    283422        self.global_options = &singular_options
    284423        self.name = "general"
     
    294433                         "redTail":       Sy_bit(OPT_REDTAIL),
    295434                         "intStrategy":   Sy_bit(OPT_INTSTRATEGY),
    296435                         "notRegularity": Sy_bit(OPT_NOTREGULARITY),
    297                          "weightM":       Sy_bit(OPT_WEIGHTM)}
     436                         "weightM":       Sy_bit(OPT_WEIGHTM),
     437                         "degBound":      Sy_bit(OPT_DEGBOUND),
     438                         "multBound":     Sy_bit(OPT_MULTBOUND)}
    298439        LibSingularOptions_abstract.__init__(self, **kwds)
    299440
     441    def reset_default(self):
     442        """
     443        Reset libSingular's default options.
     444
     445        EXAMPLE::
     446
     447            sage: from sage.libs.singular.option import opt
     448            sage: opt['red_tail']
     449            True
     450            sage: opt['red_tail'] = False
     451            sage: opt['red_tail']
     452            False
     453            sage: opt['deg_bound']
     454            0
     455            sage: opt['deg_bound'] = 2
     456            sage: opt['deg_bound']
     457            2
     458            sage: opt.reset_default()
     459            sage: opt['red_tail']
     460            True
     461            sage: opt['deg_bound']
     462            0
     463        """
     464        from sage.libs.singular.singular import _saved_options
     465        self.load(_saved_options)
     466
     467
    300468
    301469#############
    302470
     
    306474
    307475    Supported options are:
    308476
    309      - ``mem`` -
    310      - ``yacc`` -
    311      - ``redefine`` -
    312      - ``reading`` -
    313      - ``loadLib`` -
    314      - ``debugLib`` -
    315      - ``loadProc`` -
    316      - ``defRes`` -
    317      - ``debugMem`` -
    318      - ``usage`` -
    319      - ``Imap`` -
    320      - ``prompt`` -
    321      - ``notWarnSB`` - do not warn if a basis is not a standard basis
    322      - ``contentSB`` -
    323      - ``cancelunit`` -
    324                
     477     - ``mem`` - shows memory usage in square brackets.
     478     - ``yacc`` - Only available in debug version.
     479     - ``redefine`` - warns about variable redefinitions.
     480     - ``reading`` - shows the number of characters read from a file.
     481     - ``loadLib`` or ``load_lib`` - shows loading of libraries.
     482     - ``debugLib`` or ``debug_lib`` - warns about syntax errors
     483       when loading a library.
     484     - ``loadProc`` or ``load_proc`` - shows loading of procedures
     485       from libraries.
     486     - ``defRes`` or ``def_res`` - shows the names of the syzygy
     487       modules while converting ``resolution`` to ``list``.
     488     - ``usage`` - shows correct usage in error messages.
     489     - ``Imap`` or ``imap`` - shows the mapping of variables with
     490       the ``fetch`` and ``imap`` commands.
     491     - ``notWarnSB`` or ``not_warn_sb`` - do not warn if
     492       a basis is not a standard basis
     493     - ``contentSB`` or ``content_sb`` - avoids to divide by the
     494       content of a polynomial in ``std`` and related algorithms.
     495       Should usually not be used.
     496     - ``cancelunit`` - avoids to divide polynomials by non-constant
     497       units in ``std`` in the local case. Should usually not be used.
     498         
    325499    EXAMPLE::
    326500
    327501        sage: from sage.libs.singular.option import LibSingularVerboseOptions
     
    350524                         "debugLib": Sy_bit(V_DEBUG_LIB),
    351525                         "loadProc": Sy_bit(V_LOAD_PROC),
    352526                         "defRes":   Sy_bit(V_DEF_RES),   
    353                          "debugMem": Sy_bit(V_DEBUG_MEM),
     527                         #"debugMem": Sy_bit(V_DEBUG_MEM),
    354528                         "usage":    Sy_bit(V_SHOW_USE), 
    355529                         "Imap":     Sy_bit(V_IMAP),     
    356                          "prompt":   Sy_bit(V_PROMPT),   
    357                          "notWarnSB":Sy_bit(V_NSB),       
     530                         #"prompt":   Sy_bit(V_PROMPT),   
     531                         "notWarnSB":Sy_bit(V_NSB),
    358532                         "contentSB":Sy_bit(V_CONTENTSB),
    359                          "cancelunit":Sy_bit(V_CANCELUNIT),
     533                         "cancelunit":Sy_bit(V_CANCELUNIT)
    360534                         }
    361535        LibSingularOptions_abstract.__init__(self, **kwds)
    362536
     537    def reset_default(self):
     538        """
     539        Return to libSingular's default verbosity options
     540
     541        EXAMPLE::
     542
     543            sage: from sage.libs.singular.option import opt_verb
     544            sage: opt_verb['not_warn_sb']
     545            False
     546            sage: opt_verb['not_warn_sb'] = True
     547            sage: opt_verb['not_warn_sb']
     548            True
     549            sage: opt_verb.reset_default()
     550            sage: opt_verb['not_warn_sb']
     551            False
     552
     553        """
     554        from sage.libs.singular.singular import _saved_verbose_options
     555        self.global_options[0] = int(_saved_verbose_options)
     556
    363557cdef class LibSingularOptionsContext:
    364558    """
    365559    Option context
     
    370564
    371565        sage: from sage.libs.singular.option import opt, opt_ctx
    372566        sage: opt
    373         general options for libSingular (current value 0x02000082)
     567        general options for libSingular (current value 0x06000082)
    374568
    375569    ::
    376570
     
    379573        ...       with opt_ctx(redThrough=False):
    380574        ...           print opt
    381575        ...
    382         general options for libSingular (current value 0x00000082)
    383         general options for libSingular (current value 0x00000002)
     576        general options for libSingular (current value 0x04000082)
     577        general options for libSingular (current value 0x04000002)
    384578
    385579        sage: print opt
    386         general options for libSingular (current value 0x02000082)
     580        general options for libSingular (current value 0x06000082)
    387581    """
    388582    cdef list bck
     583    cdef list bck_degBound
     584    cdef list bck_multBound
    389585    cdef public LibSingularOptions_abstract opt
    390586    cdef object options
    391587
     
    400596            general options context for libSingular
    401597        """
    402598        self.bck = []
     599        self.bck_degBound = []
     600        self.bck_multBound = []
    403601        self.options = kwds
    404602        self.opt = opt
    405603
     
    415613            False
    416614        """
    417615        self.bck.append(self.opt.global_options[0])
     616        self.bck_degBound.append(Kstd1_deg)
     617        self.bck_multBound.append(Kstd1_mu)
    418618        opt = self.opt.__class__()
    419619        for k,v in self.options.iteritems():
    420620            opt[k] = v
     
    447647            False
    448648        """
    449649        self.opt.global_options[0] = self.bck.pop()
     650        global Kstd1_deg
     651        global Kstd1_mu
     652        Kstd1_deg = self.bck_degBound.pop()
     653        Kstd1_mu  = self.bck_multBound.pop()
    450654
    451655    def __repr__(self):
    452656        """
     
    460664
    461665
    462666opt = LibSingularOptions()
     667opt.reset_default()
    463668opt_verb = LibSingularVerboseOptions()
     669opt_verb.reset_default()
    464670opt_ctx = LibSingularOptionsContext(opt)
    465671opt_verb_ctx = LibSingularOptionsContext(opt_verb)
  • sage/libs/singular/singular-cdefs.pxi

    diff -r 5b3daac3d2f7 -r 7c07c97169c0 sage/libs/singular/singular-cdefs.pxi
    a b  
    1414cdef extern from "stdlib.h":
    1515    void delete "delete" (void *ptr)
    1616
    17 
    1817cdef extern from "factory.h":
    1918
    2019    #
     
    995994    poly *prCopyR_NoSort(poly *p, ring *r, ring *dest_r)
    996995    poly *prCopyR(poly *p, ring *r, ring *dest_r)
    997996
    998 
    999 
    1000997    cdef int LANG_TOP
    1001998
    1002999cdef extern from "stairc.h":
     
    10091006        leftv  *m
    10101007        void (*Init)(int n)
    10111008
     1009cdef extern from "kstd1.h":
     1010    cdef extern int Kstd1_deg   # degBound, default 0
     1011    cdef extern int Kstd1_mu    # multBound, default 0
     1012
    10121013cdef extern from "intvec.h":
    10131014    # for the moment we need only new, as we use the cleanup of sleftv
    10141015    # to get rid of it again
  • sage/libs/singular/singular.pyx

    diff -r 5b3daac3d2f7 -r 7c07c97169c0 sage/libs/singular/singular.pyx
    a b  
    2626from sage.misc.misc_c import is_64_bit
    2727
    2828from sage.libs.singular.decl cimport intvec
    29 from sage.libs.singular.decl cimport SR_HDL, SR_INT, SR_TO_INT, singular_options
     29from sage.libs.singular.decl cimport SR_HDL, SR_INT, SR_TO_INT, singular_options, singular_verbose_options
    3030from sage.libs.singular.decl cimport On, Off, SW_USE_NTL, SW_USE_NTL_GCD_0, SW_USE_EZGCD, SW_USE_NTL_SORT, SW_USE_NTL_GCD_P
    3131from sage.libs.singular.decl cimport napoly, lnumber, Sy_bit, OPT_REDSB, OPT_INTSTRATEGY, OPT_REDTAIL, OPT_REDTHROUGH
    3232from sage.libs.singular.decl cimport nlGetNom, nlGetDenom, nlDelete, nlInit2gmp
     
    4848from sage.structure.parent_base cimport ParentWithBase
    4949from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomial_libsingular
    5050
     51_saved_options = (int(0),0,0)
     52
    5153cdef Rational si2sa_QQ(number *n, ring *_ring):
    5254    """
    5355    TESTS::
     
    645647    far is to load the library again and to specify ``RTLD_GLOBAL``.
    646648    """
    647649    global singular_options
     650    global singular_verbose_options
    648651    global max_exponent_size
    649652
    650653    cdef void *handle = NULL
     
    667670
    668671    dlclose(handle)
    669672
    670     # we set some global Singular options
     673    # we set and save some global Singular options
    671674    singular_options = singular_options | Sy_bit(OPT_REDSB) | Sy_bit(OPT_INTSTRATEGY) | Sy_bit(OPT_REDTAIL) | Sy_bit(OPT_REDTHROUGH)
    672        
     675    global _saved_options
     676    global _saved_verbose_options
     677    _saved_options = (int(singular_options), 0, 0)
     678    _saved_verbose_options = int(singular_verbose_options)
     679
    673680    On(SW_USE_NTL)
    674681    On(SW_USE_NTL_GCD_0)
    675682    On(SW_USE_NTL_GCD_P)
  • sage/rings/polynomial/multi_polynomial_ideal.py

    diff -r 5b3daac3d2f7 -r 7c07c97169c0 sage/rings/polynomial/multi_polynomial_ideal.py
    a b  
    244244import sage.rings.polynomial.toy_variety as toy_variety
    245245import sage.rings.polynomial.toy_d_basis as toy_d_basis
    246246
    247 class RedSBContext:
     247class LibSingularDefaultContext:
     248    def __init__(self, singular=singular_default):
     249        from sage.libs.singular.option import opt_ctx
     250        self.libsingular_option_context = opt_ctx
     251    def __enter__(self):
     252        """
     253        EXAMPLE::
     254
     255            sage: from sage.rings.polynomial.multi_polynomial_ideal import SingularDefaultContext
     256            sage: P.<a,b,c> = PolynomialRing(QQ,3, order='lex')
     257            sage: I = sage.rings.ideal.Katsura(P,3)
     258            sage: singular.option('noredTail')
     259            sage: singular.option('noredThrough')
     260            sage: Is = I._singular_()
     261            sage: with SingularDefaultContext(): rgb = Is.groebner()
     262            sage: rgb
     263            84*c^4-40*c^3+c^2+c,
     264            7*b+210*c^3-79*c^2+3*c,
     265            7*a-420*c^3+158*c^2+8*c-7
     266        """
     267        self.libsingular_option_context.__enter__()
     268        self.libsingular_option_context.opt.reset_default()
     269        self.libsingular_option_context.opt['red_sb'] = True
     270        self.libsingular_option_context.opt['red_tail'] = True
     271        self.libsingular_option_context.opt['deg_bound'] = 0
     272        self.libsingular_option_context.opt['mult_bound'] = 0
     273
     274    def __exit__(self, typ, value, tb):
     275        """
     276        EXAMPLE::
     277
     278            sage: from sage.rings.polynomial.multi_polynomial_ideal import SingularDefaultContext
     279            sage: P.<a,b,c> = PolynomialRing(QQ,3, order='lex')
     280            sage: I = sage.rings.ideal.Katsura(P,3)
     281            sage: singular.option('noredTail')
     282            sage: singular.option('noredThrough')
     283            sage: Is = I._singular_()
     284            sage: with SingularDefaultContext(): rgb = Is.groebner()
     285            sage: rgb
     286            84*c^4-40*c^3+c^2+c,
     287            7*b+210*c^3-79*c^2+3*c,
     288            7*a-420*c^3+158*c^2+8*c-7
     289        """
     290        self.libsingular_option_context.__exit__(typ,value,tb)
     291
     292
     293class SingularDefaultContext:
    248294    """
    249295    Within this context all Singular Groebner basis calculations are
    250296    reduced automatically.
     
    252298    AUTHORS:
    253299
    254300    - Martin Albrecht
     301    - Simon King
    255302    """
    256303    def __init__(self, singular=singular_default):
    257304        """
     
    264311       
    265312        EXAMPLE::
    266313       
    267             sage: from sage.rings.polynomial.multi_polynomial_ideal import RedSBContext
     314            sage: from sage.rings.polynomial.multi_polynomial_ideal import SingularDefaultContext
    268315            sage: P.<a,b,c> = PolynomialRing(QQ,3, order='lex')
    269316            sage: I = sage.rings.ideal.Katsura(P,3)
    270317            sage: singular.option('noredTail')
     
    279326        ::
    280327       
    281328            sage: from __future__ import with_statement
    282             sage: with RedSBContext(): rgb = Is.groebner()
     329            sage: with SingularDefaultContext(): rgb = Is.groebner()
    283330            sage: rgb
    284331            84*c^4-40*c^3+c^2+c,
    285332            7*b+210*c^3-79*c^2+3*c,
     
    299346           Groebner basis is computed so the user does not need to use
    300347           it manually.
    301348        """
    302         from sage.libs.singular.option import opt_ctx
    303349        self.singular = singular
    304         self.libsingular_option_context = opt_ctx
    305350
    306351    def __enter__(self):
    307352        """
    308353        EXAMPLE::
    309354       
    310             sage: from sage.rings.polynomial.multi_polynomial_ideal import RedSBContext
     355            sage: from sage.rings.polynomial.multi_polynomial_ideal import SingularDefaultContext
    311356            sage: P.<a,b,c> = PolynomialRing(QQ,3, order='lex')
    312357            sage: I = sage.rings.ideal.Katsura(P,3)
    313358            sage: singular.option('noredTail')
    314359            sage: singular.option('noredThrough')
    315360            sage: Is = I._singular_()
    316             sage: with RedSBContext(): rgb = Is.groebner()
     361            sage: with SingularDefaultContext(): rgb = Is.groebner()
    317362            sage: rgb
    318363            84*c^4-40*c^3+c^2+c,
    319364            7*b+210*c^3-79*c^2+3*c,
    320365            7*a-420*c^3+158*c^2+8*c-7
    321366        """
     367        try:
     368            self.bck_degBound = int(self.singular.eval('degBound'))
     369        except RuntimeError:
     370            self.bck_degBound = int(0)
     371        try:
     372            self.bck_multBound = int(self.singular.eval('multBound'))
     373        except RuntimeError:
     374            self.bck_multBound = int(0)
    322375        self.o = self.singular.option("get")
     376        self.singular.option('set',self.singular._saved_options)
    323377        self.singular.option("redSB")
    324         self.libsingular_option_context.__enter__()
    325         self.libsingular_option_context.opt['redSB'] = True
    326         self.libsingular_option_context.opt['redTail'] = True
     378        self.singular.option("redTail")
     379        try:
     380            self.singular.eval('degBound=0')
     381        except RuntimeError:
     382            pass
     383        try:
     384            self.singular.eval('multBound=0')
     385        except RuntimeError:
     386            pass
    327387
    328388    def __exit__(self, typ, value, tb):
    329389        """
    330390        EXAMPLE::
    331391       
    332             sage: from sage.rings.polynomial.multi_polynomial_ideal import RedSBContext
     392            sage: from sage.rings.polynomial.multi_polynomial_ideal import SingularDefaultContext
    333393            sage: P.<a,b,c> = PolynomialRing(QQ,3, order='lex')
    334394            sage: I = sage.rings.ideal.Katsura(P,3)
    335395            sage: singular.option('noredTail')
    336396            sage: singular.option('noredThrough')
    337397            sage: Is = I._singular_()
    338             sage: with RedSBContext(): rgb = Is.groebner()
     398            sage: with SingularDefaultContext(): rgb = Is.groebner()
    339399            sage: rgb
    340400            84*c^4-40*c^3+c^2+c,
    341401            7*b+210*c^3-79*c^2+3*c,
    342402            7*a-420*c^3+158*c^2+8*c-7
    343403        """
    344404        self.singular.option("set",self.o)
    345         self.libsingular_option_context.__exit__(typ,value,tb)
     405        try:
     406            self.singular.eval('degBound=%d'%self.bck_degBound)
     407        except RuntimeError:
     408            pass
     409        try:
     410            self.singular.eval('multBound=%d'%self.bck_multBound)
     411        except RuntimeError:
     412            pass
    346413
    347 def redSB(func):
     414def singular_standard_options(func):
    348415    """
    349416    Decorator to force a reduced Singular groebner basis.
    350417   
     
    363430    """
    364431    def wrapper(*args, **kwds):
    365432        """
    366         Execute function in ``RedSBContext``.
     433        Execute function in ``SingularDefaultContext``.
    367434        """
    368         with RedSBContext():
     435        with SingularDefaultContext():
    369436            return func(*args, **kwds)
    370437
    371438    from sage.misc.sageinspect import sage_getsource
     
    374441    wrapper.__doc__ = func.__doc__
    375442    return wrapper
    376443
     444def libsingular_standard_options(func):
     445    """
     446    Decorator to force a reduced Singular groebner basis.
     447
     448    TESTS::
     449
     450        sage: P.<a,b,c,d,e> = PolynomialRing(GF(127))
     451        sage: J = sage.rings.ideal.Cyclic(P).homogenize()
     452        sage: from sage.misc.sageinspect import sage_getsource
     453        sage: "buchberger" in sage_getsource(J.interreduced_basis)
     454        True
     455
     456    .. note::
     457
     458       This decorator is used automatically internally so the user
     459       does not need to use it manually.
     460    """
     461    def wrapper(*args, **kwds):
     462        """
     463        Execute function in ``LibSingularDefaultContext``.
     464        """
     465        with LibSingularDefaultContext():
     466            return func(*args, **kwds)
     467
     468    from sage.misc.sageinspect import sage_getsource
     469    wrapper._sage_src_ = lambda: sage_getsource(func)
     470    wrapper.__name__ = func.__name__
     471    wrapper.__doc__ = func.__doc__
     472    return wrapper
     473
    377474class RequireField(MethodDecorator):
    378475    """
    379476    Decorator which throws an exception if a computation over a
     
    608705        I.plot()
    609706
    610707    @require_field
    611     @redSB
     708    @libsingular_standard_options
    612709    def complete_primary_decomposition(self, algorithm="sy"):
    613710        r"""
    614711        Return a list of primary ideals and their associated primes such
     
    772869        return [I for I, _ in self.complete_primary_decomposition(algorithm)]
    773870
    774871    @require_field
    775     @redSB
    776872    def associated_primes(self, algorithm='sy'):
    777873        r"""
    778874        Return a list of the associated primes of primary ideals of
     
    837933        return [P for _,P in self.complete_primary_decomposition(algorithm)]
    838934           
    839935    @require_field
     936    @singular_standard_options
     937    @libsingular_standard_options
    840938    def triangular_decomposition(self, algorithm=None, singular=singular_default):
    841939        """
    842940        Decompose zero-dimensional ideal ``self`` into triangular
     
    10761174        else:
    10771175            return vd
    10781176
    1079     @redSB
     1177    @singular_standard_options
    10801178    def _groebner_basis_singular(self, algorithm="groebner", *args, **kwds):
    10811179        """
    10821180        Return the reduced Groebner basis of this ideal. If the
     
    11391237        S =  Sequence([R(S[i+1]) for i in range(len(S))], R, check=False, immutable=True)
    11401238        return S
    11411239
     1240    @cached_method
    11421241    def _groebner_basis_singular_raw(self, algorithm="groebner", singular=singular_default, *args, **kwds):
    11431242        r"""
    11441243        Return a Groebner basis in Singular format.
     
    11521251            b*d^4 - b + d^5 - d, b*c - b*d + c^2*d^4 + c*d - 2*d^2,
    11531252            b^2 + 2*b*d + d^2, a + b + c + d]
    11541253        """
    1155         try:
    1156             return self.__gb_singular
    1157         except AttributeError:
    1158             pass
    1159         # singular options are preserved by @redSB so we don't
    1160         # need to do that here too
    1161         for o,v in kwds.iteritems():
    1162             if v:
    1163                 singular.option(o)
    1164             else:
    1165                 singular.option("no"+o)
     1254        #try:
     1255        #    return self.__gb_singular
     1256        #except AttributeError:
     1257        #    pass
     1258        # singular options are preserved by @singular_standard_options,
     1259        # so we don't eed to do that here too
     1260        from sage.libs.singular.option import _options_py_to_singular
     1261        S = self._singular_()   # for degBound, we need to ensure
     1262                                # that a ring is defined
     1263        for o,v in kwds.iteritems():
     1264            o = _options_py_to_singular.get(o,o)
     1265            if v:
     1266                if o in ['degBound','multBound']:
     1267                    singular.eval(o+'=%d'%v)
     1268                else:
     1269                    singular.option(o)
     1270            else:
     1271                if o in ['degBound','multBound']:
     1272                    singular.eval(o+'=0')
     1273                else:
     1274                    singular.option("no"+o)
    11661275
    11671276        if algorithm=="groebner":
    11681277            S = self._singular_().groebner()
     
    11791288        self.__gb_singular = S
    11801289        return S
    11811290
    1182     @redSB
    1183     def _groebner_basis_libsingular(self, algorithm="groebner", redsb=True, red_tail=True):
     1291    @libsingular_standard_options
     1292    def _groebner_basis_libsingular(self, algorithm="groebner", *args, **kwds):
    11841293        """
    11851294        Return the reduced Groebner basis of this ideal. If the
    11861295        Groebner basis for this ideal has been calculated before the
     
    12361345
    12371346        import sage.libs.singular
    12381347        groebner = sage.libs.singular.ff.groebner
     1348        from sage.all import get_verbose
    12391349
    1240         opt['redSB'] = redsb
    1241         opt['redTail'] = red_tail
     1350        if get_verbose()>=2:
     1351            opt['prot'] = True
     1352        for name,value in kwds.iteritems():
     1353            if value is not None:
     1354                opt[name] = value
    12421355
    12431356        T = self.ring().term_order()
    12441357       
     
    12901403            self.__genus = Integer(genus(self))
    12911404            return self.__genus
    12921405
    1293     @redSB
     1406    @libsingular_standard_options
    12941407    def intersection(self, other):
    12951408        """
    12961409        Return the intersection of the two ideals.
     
    13261439        return R.ideal(K)
    13271440
    13281441    @require_field
    1329     @redSB
     1442    @libsingular_standard_options
    13301443    def minimal_associated_primes(self):
    13311444        """
    13321445        OUTPUT:
     
    13541467        return [R.ideal(J) for J in M]
    13551468
    13561469    @require_field
    1357     @redSB
     1470    @libsingular_standard_options
    13581471    def radical(self):
    13591472        r"""
    13601473        The radical of this ideal.
     
    14071520        return S.ideal(r)
    14081521
    14091522    @require_field
    1410     @redSB
     1523    @libsingular_standard_options
    14111524    def integral_closure(self, p=0, r=True, singular=singular_default):
    14121525        """
    14131526        Let `I` = ``self``.
     
    14341547            sage: I.integral_closure()
    14351548            [x^2, y^5, -x*y^3]
    14361549       
    1437         ALGORITHM: Use Singular
     1550        ALGORITHM: Use libSingular
    14381551        """
    14391552        R = self.ring()
    14401553        import sage.libs.singular
     
    14721585        S = syz(self)
    14731586        return matrix(self.ring(), S)
    14741587
    1475     @redSB
    14761588    def reduced_basis(self):
    14771589        r"""
    14781590        .. warning::
     
    15161628        deprecation("This function is deprecated. It will be removed in a future release of Sage. Please use the interreduced_basis() function instead.")
    15171629        return self.interreduced_basis()
    15181630
    1519     @redSB
     1631    @singular_standard_options
     1632    @libsingular_standard_options
    15201633    def interreduced_basis(self):
    15211634        r"""
    15221635        If this ideal is spanned by `(f_1, ..., f_n)` this method
     
    15831696        return ret
    15841697
    15851698    @cached_method
     1699    @singular_standard_options
    15861700    def basis_is_groebner(self, singular=singular_default):
    15871701        r"""
    15881702        Returns ``True`` if the generators of this ideal
     
    16881802        return True
    16891803
    16901804    @require_field
    1691     @redSB
     1805    @singular_standard_options
     1806    @libsingular_standard_options
    16921807    def transformed_basis(self, algorithm="gwalk", other_ring=None, singular=singular_default):
    16931808        """
    16941809        Returns a lex or ``other_ring`` Groebner Basis for this ideal.
     
    17801895        else:
    17811896            raise TypeError, "Cannot convert basis with given algorithm"
    17821897
    1783     @redSB
     1898    @libsingular_standard_options
    17841899    def elimination_ideal(self, variables):
    17851900        r"""
    17861901        Returns the elimination ideal this ideal with respect to the
     
    18151930        Is = MPolynomialIdeal(R,self.groebner_basis())
    18161931        return MPolynomialIdeal(R, eliminate(Is, prod(variables)) )
    18171932
    1818     @redSB
     1933    @libsingular_standard_options
    18191934    def quotient(self, J):
    18201935        r"""
    18211936        Given ideals `I` = ``self`` and `J` in the same polynomial
     
    23972512                                        symmetry=symmetry, verbose=verbose)
    23982513
    23992514    @cached_method
    2400     def groebner_basis(self, algorithm='', *args, **kwds):
     2515    def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, *args, **kwds):
    24012516        """
    2402         Return the reduced Groebner basis of this ideal. A Groebner
    2403         basis `g_1,...,g_n` for an ideal `I` is a basis such that
    2404         `<LM(g_i)> = LM(I)`, i.e., the leading monomial ideal of
    2405         `I` is spanned by the leading terms of
    2406         `g_1,...,g_n`. Groebner bases are the key concept in
    2407         computational ideal theory in multivariate polynomial rings
    2408         which allows a variety of problems to be solved.
     2517        Return the reduced Groebner basis of this ideal.
     2518
     2519        A Groebner basis `g_1,...,g_n` for an ideal `I` is a
     2520        generating set such that `<LM(g_i)> = LM(I)`, i.e.,
     2521        the leading monomial ideal of `I` is spanned by the
     2522        leading terms of `g_1,...,g_n`. Groebner bases are
     2523        the key concept in computational ideal theory in
     2524        multivariate polynomial rings which allows a variety
     2525        of problems to be solved.
     2526
    24092527        Additionally, a *reduced* Groebner basis `G` is a unique
    2410         representation for the ideal `<G>` with respect to the chosen
    2411         monomial ordering.
     2528        representation for the ideal `<G>` with respect to the
     2529        chosen monomial ordering.
    24122530       
    24132531        INPUT:
    24142532       
     
    25582676            sage: I.groebner_basis('magma:GroebnerBasis') # optional - magma
    25592677            [a - 60*c^3 + 158/7*c^2 + 8/7*c - 1, b + 30*c^3 - 79/7*c^2 + 3/7*c, c^4 - 10/21*c^3 + 1/84*c^2 + 1/84*c]
    25602678       
     2679        Singular and libSingular can compute Groebner basis with degree
     2680        restrictions::
     2681
     2682            sage: R.<x,y> = QQ[]
     2683            sage: I = R*[x^3+y^2,x^2*y+1]
     2684            sage: I.groebner_basis(algorithm='singular')
     2685            [x^3 + y^2, x^2*y + 1, y^3 - x]
     2686            sage: I.groebner_basis(algorithm='singular',deg_bound=2)
     2687            [x^3 + y^2, x^2*y + 1]
     2688            sage: I.groebner_basis()
     2689            [x^3 + y^2, x^2*y + 1, y^3 - x]
     2690            sage: I.groebner_basis(deg_bound=2)
     2691            [x^3 + y^2, x^2*y + 1]
     2692
     2693        In the case of libSingular, a protocol is printed, if the
     2694        verbosity level is at least 2, or if the argument ``prot``
     2695        is provided. For some reason, the protocol does not appear
     2696        during doctests, so, we skip the examples with protocol
     2697        output.
     2698        ::
     2699
     2700            sage: set_verbose(2)
     2701            sage: I = R*[x^3+y^2,x^2*y+1]
     2702            sage: I.groebner_basis()  # not tested
     2703            std in (0),(x,y),(dp(2),C)
     2704            [4294967295:2]3ss4s6
     2705            (S:2)--
     2706            product criterion:1 chain criterion:0
     2707            [x^3 + y^2, x^2*y + 1, y^3 - x]
     2708            sage: I.groebner_basis(prot=False)
     2709            [x^3 + y^2, x^2*y + 1, y^3 - x]
     2710            sage: set_verbose(0)
     2711            sage: I.groebner_basis(prot=True)  # not tested
     2712            std in (0),(x,y),(dp(2),C)
     2713            [4294967295:2]3ss4s6
     2714            (S:2)--
     2715            product criterion:1 chain criterion:0
     2716            [x^3 + y^2, x^2*y + 1, y^3 - x]
     2717
     2718        The list of available options is provided at
     2719        :class:`~sage.libs.singular.option.LibSingularOptions`.
     2720
    25612721        Groebner bases over `\ZZ` can be computed. ::
    25622722       
    25632723            sage: P.<a,b,c> = PolynomialRing(ZZ,3)
     
    26402800
    26412801        if algorithm is '':
    26422802            try:
    2643                 gb = self._groebner_basis_libsingular("groebner", *args, **kwds)
     2803                gb = self._groebner_basis_libsingular("groebner", deg_bound=deg_bound, mult_bound=mult_bound, *args, **kwds)
    26442804            except (TypeError,NameError), msg: # conversion to Singular not supported
    26452805                try:
    2646                     gb = self._groebner_basis_singular("groebner", *args, **kwds)
     2806                    gb = self._groebner_basis_singular("groebner", deg_bound=deg_bound, mult_bound=mult_bound, *args, **kwds)
    26472807                except (TypeError,NameError), msg: # conversion to Singular not supported
    26482808                    if self.ring().term_order().is_global() and is_IntegerModRing(self.ring().base_ring()) and not self.ring().base_ring().is_field():
    26492809                        verbose("Warning: falling back to very slow toy implementation.", level=0)
     
    26642824                            raise TypeError, "Local/unknown orderings not supported by 'toy_buchberger' implementation."
    26652825
    26662826        elif algorithm.startswith('singular:'):
    2667             gb = self._groebner_basis_singular(algorithm[9:])
     2827            gb = self._groebner_basis_singular(algorithm[9:], deg_bound=deg_bound, mult_bound=mult_bound, *args, **kwds)
    26682828        elif algorithm.startswith('libsingular:'):
    2669             gb = self._groebner_basis_libsingular(algorithm[len('libsingular:'):], *args, **kwds)
     2829            gb = self._groebner_basis_libsingular(algorithm[len('libsingular:'):], deg_bound=deg_bound, mult_bound=mult_bound, *args, **kwds)
    26702830        elif algorithm == 'macaulay2:gb':
    26712831            gb = self._groebner_basis_macaulay2(*args, **kwds)
    26722832        elif algorithm == 'magma:GroebnerBasis':