Ticket #7797: plural_functions.patch
File plural_functions.patch, 4.2 KB (added by , 9 years ago) 


sage/libs/singular/function.pyx
diff r 54342f65c59c sage/libs/singular/function.pyx
a b 13 13  Martin Albrecht (200907): clean up, enhancements, etc. 14 14  Michael Brickenstein (200910): extension to more Singular types 15 15  Martin Albrecht (201001): clean up, support for attributes 16  Burcin Erocal (20107): plural support 16 17 17 18 EXAMPLES: 18 19 … … 229 230 args.CleanUp() 230 231 omFreeBin(args, sleftv_bin) 231 232 233 def is_polynomial(p): 234 return isinstance(p, MPolynomial_libsingular) or isinstance(p, NCPolynomial_plural) 232 235 233 236 def all_polynomials(s): 234 237 """ … … 245 248 False 246 249 """ 247 250 for p in s: 248 if not is instance(p, MPolynomial_libsingular):251 if not is_polynomial(p): 249 252 return False 250 253 return True 251 254 … … 275 278 return True 276 279 277 280 281 cdef ring* sage_ring_to_singular_ring(ring) except <ring* > 1: 282 if PY_TYPE_CHECK(ring, MPolynomialRing_libsingular): 283 return (<MPolynomialRing_libsingular>ring)._ring 284 elif PY_TYPE_CHECK(ring, NCPolynomialRing_plural): 285 return (<NCPolynomialRing_plural>ring)._ring 286 raise ValueError, "no singular ring found" 287 278 288 279 289 cdef class Converter(SageObject): 280 290 """ … … 305 315 cdef leftv *v 306 316 self.args = NULL 307 317 self._sage_ring = ring 308 if PY_TYPE_CHECK(ring, MPolynomialRing_libsingular): 309 self._singular_ring = (<MPolynomialRing_libsingular>ring)._ring 310 elif PY_TYPE_CHECK(ring, NCPolynomialRing_plural): 311 self._singular_ring = (<NCPolynomialRing_plural>ring)._ring 318 if ring is not None: 319 self._singular_ring = sage_ring_to_singular_ring(ring) 312 320 313 321 from sage.matrix.matrix_mpolynomial_dense import Matrix_mpolynomial_dense 314 322 from sage.matrix.matrix_integer_dense import Matrix_integer_dense … … 579 587 """ 580 588 cdef poly* _p 581 589 if PY_TYPE_CHECK(p, MPolynomial_libsingular): 582 _p = p_Copy((<MPolynomial_libsingular>p)._poly, <ring*>((<MPolynomial_libsingular>p)._parent)._ring) 590 _p = p_Copy((<MPolynomial_libsingular>p)._poly, 591 ((<MPolynomialRing_libsingular>( 592 <MPolynomial_libsingular>p)._parent))._ring) 583 593 elif PY_TYPE_CHECK(p, NCPolynomial_plural): 584 _p = p_Copy((<NCPolynomial_plural>p)._poly, <ring*>((<NCPolynomial_plural>p)._parent)._ring) 594 _p = p_Copy((<NCPolynomial_plural>p)._poly, 595 ((<NCPolynomialRing_plural>( 596 <MPolynomial_libsingular>p)._parent))._ring) 597 585 598 return self._append(_p, POLY_CMD) 586 599 587 600 cdef leftv *append_ideal(self, i) except NULL: … … 1105 1118 elif PY_TYPE_CHECK(a, MPolynomialRing_libsingular) or \ 1106 1119 PY_TYPE_CHECK(a, NCPolynomialRing_plural): 1107 1120 ring2 = a 1108 elif PY_TYPE_CHECK(a, int) or PY_TYPE_CHECK(a, long) or PY_TYPE_CHECK(a, basestring): 1121 elif PY_TYPE_CHECK(a, int) or\ 1122 PY_TYPE_CHECK(a, long) or\ 1123 PY_TYPE_CHECK(a, basestring): 1109 1124 continue 1110 1125 elif PY_TYPE_CHECK(a, Matrix_integer_dense): 1111 1126 continue … … 1399 1414 <Resolution> 1400 1415 sage: singular_list(resolution) 1401 1416 [[(2*y, 2, y + 1, 0), (0, 2, x  1, 0), (x*y  y, y + 1, 1, y), (x^2 + 1, x  1, 1, x)], [(x  1, y  1, 2*x, 2*y)], [(0)]] 1402 1403 1417 sage: from sage.rings.polynomial.plural import NCPolynomialRing_plural 1418 sage: from sage.matrix.constructor import Matrix 1419 sage: c=Matrix(2) 1420 sage: c[0,1]=1 1421 sage: P = NCPolynomialRing_plural(QQ, 2, 'x,y', c=c, d=Matrix(2)) 1422 sage: (x,y)=[P.gen(i) for i in xrange(2)] 1423 sage: I= Sequence([x*y,x+y], check=False, immutable=True)#P.ideal(x*y,x+y) 1424 sage: twostd = singular_function("twostd") 1425 sage: twostd(I) 1426 [x + y, x*y  y, 2*y, x^2 + 1] 1427 sage: M=syz(I) 1428 sage: M 1429 [(2*y, 2, y + 1, 0), (0, 2, x  1, 0), (x*y  y, y + 1, 1, y), (x^2 + 1, x  1, 1, x)] 1430 sage: syz(M) 1431 [(x  1, y  1, 2*x, 2*y)] 1404 1432 """ 1405 1433 1406 1434 cdef SingularFunction fnc