Ticket #13237: 13237_singular_3_1_5.patch

File 13237_singular_3_1_5.patch, 15.7 KB (added by jdemeyer, 9 years ago)

Patch for the Sage library

  • doc/en/constructions/polynomials.rst

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1343333036 -7200
    # Node ID 48aa91b80f43a5dd1ccd91415e66b9814a8b31ac
    # Parent  90cdc6a8ad4e4bed83142b4ca0e6c551acd73204
    Fix doctests for Singular-3-1-5
    
    diff --git a/doc/en/constructions/polynomials.rst b/doc/en/constructions/polynomials.rst
    a b  
    9292    sage: f =  9*y^6 - 9*x^2*y^5 - 18*x^3*y^4 - 9*x^5*y^4 + 9*x^6*y^2 + 9*x^7*y^3\
    9393    ...   + 18*x^8*y^2 - 9*x^11
    9494    sage: f.factor()
    95     (-9) * (x^5 - y^2) * (x^6 - 2*x^3*y^2 - x^2*y^3 + y^4)
     95    (9) * (-x^5 + y^2) * (x^6 - 2*x^3*y^2 - x^2*y^3 + y^4)
    9696
    9797.. index::
    9898   pair: polynomial; gcd
  • sage/calculus/wester.py

    diff --git a/sage/calculus/wester.py b/sage/calculus/wester.py
    a b  
    472472    sage: print d
    473473    a^3*b^2*c - a^2*b^3*c - a^3*b*c^2 + a*b^3*c^2 + a^2*b*c^3 - a*b^2*c^3 - a^3*b^2*d + a^2*b^3*d + a^3*c^2*d - b^3*c^2*d - a^2*c^3*d + b^2*c^3*d + a^3*b*d^2 - a*b^3*d^2 - a^3*c*d^2 + b^3*c*d^2 + a*c^3*d^2 - b*c^3*d^2 - a^2*b*d^3 + a*b^2*d^3 + a^2*c*d^3 - b^2*c*d^3 - a*c^2*d^3 + b*c^2*d^3
    474474    sage: print d.factor()
    475     (-1) * (c - d) * (b - d) * (b - c) * (-a + b) * (a - d) * (a - c)
     475    (-1) * (c - d) * (-b + c) * (b - d) * (-a + c) * (-a + b) * (a - d)
    476476
    477477::
    478478
  • sage/libs/singular/function.pyx

    diff --git a/sage/libs/singular/function.pyx b/sage/libs/singular/function.pyx
    a b  
    8989
    9090from sage.rings.polynomial.multi_polynomial_ideal_libsingular cimport sage_ideal_to_singular_ideal, singular_ideal_to_sage_sequence
    9191
    92 from sage.libs.singular.decl cimport leftv, idhdl, poly, ideal, ring, number, intvec, lists
    93 from sage.libs.singular.decl cimport sleftv_bin, omAllocBin, omFreeBin, omStrDup, slists_bin, omAlloc0Bin
    94 from sage.libs.singular.decl cimport iiMake_proc, iiExprArith1, iiExprArith2, iiExprArith3, iiExprArithM, iiLibCmd
    95 from sage.libs.singular.decl cimport ggetid, IDEAL_CMD, CMD_M, POLY_CMD, PROC_CMD, RING_CMD, QRING_CMD, NUMBER_CMD, INT_CMD, INTVEC_CMD, RESOLUTION_CMD
    96 from sage.libs.singular.decl cimport MODUL_CMD, LIST_CMD, MATRIX_CMD, VECTOR_CMD, STRING_CMD, V_LOAD_LIB, V_REDEFINE, INTMAT_CMD, NONE, PACKAGE_CMD
    97 from sage.libs.singular.decl cimport IsCmd, rChangeCurrRing, currRing, p_Copy, rIsPluralRing, rPrint, rOrderingString
    98 from sage.libs.singular.decl cimport IDROOT, enterid, currRingHdl, memcpy, IDNEXT, IDTYP, IDPACKAGE
    99 from sage.libs.singular.decl cimport errorreported, verbose, Sy_bit, currentVoice, myynest
    100 from sage.libs.singular.decl cimport intvec_new_int3, intvec_new, matrix, mpNew
    101 from sage.libs.singular.decl cimport p_Add_q, p_SetComp, p_GetComp, pNext, p_Setm, IDELEMS
    102 from sage.libs.singular.decl cimport idInit, syStrategy, atSet, atGet, setFlag, FLAG_STD
     92from sage.libs.singular.decl cimport *
    10393
    10494from sage.libs.singular.option import opt_ctx
    10595from sage.libs.singular.polynomial cimport singular_vector_maximal_component, singular_polynomial_check
     
    10801070        cdef leftv *arg1
    10811071        cdef leftv *arg2
    10821072        cdef leftv *arg3
    1083         if self.arity != CMD_M:
    1084             number_of_arguments=len(argument_list)
    10851073
    1086             if number_of_arguments == 1:
     1074        cdef int number_of_arguments = len(argument_list)
     1075
     1076        # Handle functions with an arbitrary number of arguments, sent
     1077        # by an argument list.
     1078        if self.arity in [CMD_M, ROOT_DECL_LIST, RING_DECL_LIST]:
     1079            if _ring != currRing: rChangeCurrRing(_ring)
     1080            iiExprArithM(res, argument_list.args, self.cmd_n)
     1081            return res
     1082
     1083        if number_of_arguments == 1:
     1084            if self.arity in [CMD_1, CMD_12, CMD_13, CMD_123, RING_CMD]:
    10871085                arg1 = argument_list.pop_front()
    10881086                if _ring != currRing: rChangeCurrRing(_ring)
    10891087                iiExprArith1(res, arg1, self.cmd_n)
    10901088                free_leftv(arg1)
    1091                  
    1092             elif number_of_arguments == 2:
     1089                return res
     1090             
     1091        elif number_of_arguments == 2:
     1092            if self.arity in [CMD_2, CMD_12, CMD_23, CMD_123]:
    10931093                arg1 = argument_list.pop_front()
    10941094                arg2 = argument_list.pop_front()
    10951095                if _ring != currRing: rChangeCurrRing(_ring)
    1096                 iiExprArith2(res, arg1, self.cmd_n, arg2, self.cmd_n>255)
     1096                iiExprArith2(res, arg1, self.cmd_n, arg2, True)
    10971097                free_leftv(arg1)
    10981098                free_leftv(arg2)
     1099                return res
    10991100
    1100             elif number_of_arguments == 3:
     1101        elif number_of_arguments == 3:
     1102            if self.arity in [CMD_3, CMD_13, CMD_23, CMD_123, RING_CMD]:
    11011103                arg1 = argument_list.pop_front()
    11021104                arg2 = argument_list.pop_front()
    11031105                arg3 = argument_list.pop_front()
     
    11061108                free_leftv(arg1)
    11071109                free_leftv(arg2)
    11081110                free_leftv(arg3)
    1109         else:
    1110             if _ring != currRing: rChangeCurrRing(_ring)
    1111             iiExprArithM(res, argument_list.args, self.cmd_n)
     1111                return res
    11121112
    1113         return res
     1113        global errorreported
     1114        global error_messages
     1115
     1116        errorreported += 1
     1117        error_messages.append("Wrong number of arguments")
     1118        return NULL
    11141119
    11151120    cdef bint free_res(self):
    11161121        """
     
    12031208            Traceback (most recent call last):                                         
    12041209            ...
    12051210            RuntimeError: Error in Singular function call 'size':
    1206              size(`int`,`int`) failed
    1207 
     1211             Wrong number of arguments
    12081212            sage: size('foobar', ring=P)
    12091213            6
    12101214
     
    14341438
    14351439    if errorreported:
    14361440        errorreported = 0
    1437         error_msg = " " + "\n ".join(error_messages)
    1438         raise RuntimeError("Error in Singular function call '%s':\n%s"%(self._name,
    1439                                                                            error_msg))
     1441        raise RuntimeError("Error in Singular function call '%s':\n %s"%
     1442            (self._name, "\n ".join(error_messages)))
    14401443
    14411444    res = argument_list.to_python(_res)
    14421445   
     
    15391542
    15401543    INPUT:
    15411544
    1542     - ``name`` - the name of the function
     1545    - ``name`` -- the name of the function
    15431546
    1544     EXAMPLE::
     1547    EXAMPLES::
    15451548
    1546         sage: from sage.libs.singular.function import singular_function
    15471549        sage: P.<x,y,z> = PolynomialRing(QQ)
    15481550        sage: f = 3*x*y + 2*z + 1
    15491551        sage: g = 2*x + 1/2
    15501552        sage: I = Ideal([f,g])
    15511553
    1552         sage: number_foobar = singular_function('number_foobar');
    1553         Traceback (most recent call last):                                         
    1554         ...
    1555         NameError: Function 'number_foobar' is not defined.
     1554    ::
    15561555
    1557         sage: from sage.libs.singular.function import lib as singular_lib
    1558         sage: singular_lib('general.lib')
    1559         sage: number_e = singular_function('number_e')
    1560         sage: number_e(10r,ring=P)
    1561         67957045707/25000000000
    1562         sage: RR(number_e(10r,ring=P))
    1563         2.71828182828000
    1564 
     1556        sage: from sage.libs.singular.function import singular_function
    15651557        sage: std = singular_function("std")
    15661558        sage: std(I)
    15671559        [3*y - 8*z - 4, 4*x + 1]
    1568         sage: singular_list = singular_function("list")
    1569         sage: singular_list(2, 3, 6, ring=P)
    1570         [2, 3, 6]
    15711560        sage: size = singular_function("size")
    15721561        sage: size([2, 3, 3], ring=P)
    15731562        3
     
    15781567        sage: factorize = singular_function("factorize")
    15791568        sage: factorize(f)
    15801569        [[1, 3*x*y + 2*z + 1], (1, 1)]
     1570        sage: factorize(f, 1)
     1571        [3*x*y + 2*z + 1]
     1572
     1573    We give a wrong number of arguments::
     1574
     1575        sage: factorize(ring=P)
     1576        Traceback (most recent call last):                                         
     1577        ...
     1578        RuntimeError: Error in Singular function call 'factorize':
     1579         Wrong number of arguments
     1580        sage: factorize(f, 1, 2)
     1581        Traceback (most recent call last):
     1582        ...
     1583        RuntimeError: Error in Singular function call 'factorize':
     1584         Wrong number of arguments
     1585        sage: factorize(f, 1, 2, 3)
     1586        Traceback (most recent call last):                                         
     1587        ...
     1588        RuntimeError: Error in Singular function call 'factorize':
     1589         Wrong number of arguments
     1590
     1591    The Singular function ``list`` can be called with any number of
     1592    arguments::
     1593
     1594        sage: singular_list = singular_function("list")
     1595        sage: singular_list(2, 3, 6, ring=P)
     1596        [2, 3, 6]
     1597        sage: singular_list(ring=P)
     1598        []
     1599        sage: singular_list(1, ring=P)
     1600        [1]
     1601        sage: singular_list(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ring=P)
     1602        [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
     1603
     1604    We try to define a non-existing function::
     1605
     1606        sage: number_foobar = singular_function('number_foobar');
     1607        Traceback (most recent call last):                                         
     1608        ...
     1609        NameError: Function 'number_foobar' is not defined.
     1610
     1611    ::
     1612
     1613        sage: from sage.libs.singular.function import lib as singular_lib
     1614        sage: singular_lib('general.lib')
     1615        sage: number_e = singular_function('number_e')
     1616        sage: number_e(10r,ring=P)
     1617        67957045707/25000000000
     1618        sage: RR(number_e(10r,ring=P))
     1619        2.71828182828000
     1620
     1621    ::
     1622
    15811623        sage: singular_lib('primdec.lib')
    15821624        sage: primdecGTZ = singular_function("primdecGTZ")
    15831625        sage: primdecGTZ(I)
  • sage/libs/singular/singular-cdefs.pxi

    diff --git a/sage/libs/singular/singular-cdefs.pxi b/sage/libs/singular/singular-cdefs.pxi
    a b  
    899899    # tail reduction
    900900    poly *redtailBba(poly *p, int index, skStrategy *strat)
    901901 
     902    cdef int CMD_1
     903    cdef int CMD_2
     904    cdef int CMD_12
     905    cdef int CMD_3
     906    cdef int CMD_13
     907    cdef int CMD_23
     908    cdef int CMD_123
    902909    cdef int CMD_M
     910    cdef int ROOT_DECL
     911    cdef int ROOT_DECL_LIST
     912    cdef int RING_DECL
     913    cdef int RING_DECL_LIST
    903914    cdef int INT_CMD
    904915    cdef int INTMAT_CMD
    905916    cdef int POLY_CMD
  • sage/rings/polynomial/multi_polynomial_ideal.py

    diff --git a/sage/rings/polynomial/multi_polynomial_ideal.py b/sage/rings/polynomial/multi_polynomial_ideal.py
    a b  
    12771277            [Ideal (a - 1, b - 1, c - 1, d^2 + 3*d + 1, e + d + 3) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
    12781278            Ideal (a - 1, b - 1, c^2 + 3*c + 1, d + c + 3, e - 1) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
    12791279            Ideal (a - 1, b^2 + 3*b + 1, c + b + 3, d - 1, e - 1) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
    1280             Ideal (a - 1, b^4 + b^3 + b^2 + b + 1, c - b^2, d - b^3, e + b^3 + b^2 + b + 1) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
     1280            Ideal (a - 1, b^4 + b^3 + b^2 + b + 1, -c + b^2, -d + b^3, e + b^3 + b^2 + b + 1) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
    12811281            Ideal (a^2 + 3*a + 1, b - 1, c - 1, d - 1, e + a + 3) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
    12821282            Ideal (a^2 + 3*a + 1, b + a + 3, c - 1, d - 1, e - 1) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
    1283             Ideal (a^4 - 4*a^3 + 6*a^2 + a + 1, 11*b^2 - 6*b*a^3 + 26*b*a^2 - 41*b*a + 4*b + 8*a^3 - 31*a^2 + 40*a + 24, 11*c + 3*a^3 - 13*a^2 + 26*a - 2, 11*d + 3*a^3 - 13*a^2 + 26*a - 2, 11*e + 11*b - 6*a^3 + 26*a^2 - 41*a + 4) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
    1284             Ideal (a^4 + a^3 + a^2 + a + 1, b - 1, c + a^3 + a^2 + a + 1, d - a^3, e - a^2) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
     1283            Ideal (a^4 - 4*a^3 + 6*a^2 + a + 1, -11*b^2 + 6*b*a^3 - 26*b*a^2 + 41*b*a - 4*b - 8*a^3 + 31*a^2 - 40*a - 24, 11*c + 3*a^3 - 13*a^2 + 26*a - 2, 11*d + 3*a^3 - 13*a^2 + 26*a - 2, -11*e - 11*b + 6*a^3 - 26*a^2 + 41*a - 4) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
     1284            Ideal (a^4 + a^3 + a^2 + a + 1, b - 1, c + a^3 + a^2 + a + 1, -d + a^3, -e + a^2) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
    12851285            Ideal (a^4 + a^3 + a^2 + a + 1, b - a, c - a, d^2 + 3*d*a + a^2, e + d + 3*a) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
    12861286            Ideal (a^4 + a^3 + a^2 + a + 1, b - a, c^2 + 3*c*a + a^2, d + c + 3*a, e - a) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
    12871287            Ideal (a^4 + a^3 + a^2 + a + 1, b^2 + 3*b*a + a^2, c + b + 3*a, d - a, e - a) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
    1288             Ideal (a^4 + a^3 + a^2 + a + 1, b^3 + b^2*a + b^2 + b*a^2 + b*a + b + a^3 + a^2 + a + 1, c + b^2*a^3 + b^2*a^2 + b^2*a + b^2, d - b^2*a^2 - b^2*a - b^2 - b*a^2 - b*a - a^2, e - b^2*a^3 + b*a^2 + b*a + b + a^2 + a) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
    1289             Ideal (a^4 + a^3 + 6*a^2 - 4*a + 1, 11*b^2 - 6*b*a^3 - 10*b*a^2 - 39*b*a - 2*b - 16*a^3 - 23*a^2 - 104*a + 24, 11*c + 3*a^3 + 5*a^2 + 25*a + 1, 11*d + 3*a^3 + 5*a^2 + 25*a + 1, 11*e + 11*b - 6*a^3 - 10*a^2 - 39*a - 2) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field]
     1288            Ideal (a^4 + a^3 + a^2 + a + 1, b^3 + b^2*a + b^2 + b*a^2 + b*a + b + a^3 + a^2 + a + 1, c + b^2*a^3 + b^2*a^2 + b^2*a + b^2, -d + b^2*a^2 + b^2*a + b^2 + b*a^2 + b*a + a^2, -e + b^2*a^3 - b*a^2 - b*a - b - a^2 - a) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field,
     1289            Ideal (a^4 + a^3 + 6*a^2 - 4*a + 1, -11*b^2 + 6*b*a^3 + 10*b*a^2 + 39*b*a + 2*b + 16*a^3 + 23*a^2 + 104*a - 24, 11*c + 3*a^3 + 5*a^2 + 25*a + 1, 11*d + 3*a^3 + 5*a^2 + 25*a + 1, -11*e - 11*b + 6*a^3 + 10*a^2 + 39*a + 2) of Multivariate Polynomial Ring in e, d, c, b, a over Rational Field]
    12901290
    12911291            sage: R.<x1,x2> = PolynomialRing(QQ, 2, order='lex')
    12921292            sage: f1 = 1/2*((x1^2 + 2*x1 - 4)*x2^2 + 2*(x1^2 + x1)*x2 + x1^2)
  • sage/rings/polynomial/multi_polynomial_libsingular.pyx

    diff --git a/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/sage/rings/polynomial/multi_polynomial_libsingular.pyx
    a b  
    38583858            sage: R.<a,b,c,d> = QQ[]
    38593859            sage: f =  (-2) * (a - d) * (-a + b) * (b - d) * (a - c) * (b - c) * (c - d)
    38603860            sage: F = f.factor(); F
    3861             (-2) * (c - d) * (b - d) * (b - c) * (-a + b) * (a - d) * (a - c)
     3861            (-2) * (c - d) * (-b + c) * (b - d) * (-a + c) * (-a + b) * (a - d)
    38623862            sage: F[0][0]
    38633863            c - d
    38643864            sage: F.unit()
     
    38923892
    38933893        TESTS:
    38943894
    3895         This shows that ticket \#10270 is fixed::
     3895        This shows that :trac:`10270` is fixed::
    38963896
    38973897            sage: R.<x,y,z> = GF(3)[]
    38983898            sage: f = x^2*z^2+x*y*z-y^2
    38993899            sage: f.factor()
    39003900            x^2*z^2 + x*y*z - y^2
    39013901
    3902         This checks that ticket \#11838 is fixed::
     3902        This checks that :trac:`11838` is fixed::
    39033903
    39043904            sage: K = GF(4,'a')
    39053905            sage: a = K.gens()[0]
     
    39103910            sage: f.factor()
    39113911            x * y^3 * (y^8 + (a)*y^7 + (a + 1)*x) * (x^7*y^3 + x*y^9 + (a)*x^8 + (a)*y^4)
    39123912
    3913              ...
    3914              NotImplementedError: Factorization of multivariate polynomials over non-fields is not implemented.
    3915 
    3916         We test several examples which were known to return wrong results in the past (\#10902)::
     3913        We test several examples which were known to return wrong
     3914        results in the past (see :trac:`10902`)::
    39173915
    39183916            sage: R.<x,y> = GF(2)[]
    39193917            sage: p = x^3*y^7 + x^2*y^6 + x^2*y^3