Package sage :: Package rings :: Package polynomial :: Module polynomial_singular_interface
[hide private]
[frames] | no frames]

Module polynomial_singular_interface

source code


Polynomial Interfaces to Singular

AUTHORS:
     -- Martin Albrecht <malb@informatik.uni-bremen.de> (2006-04-21)
     -- Robert Bradshaw: Re-factor to avoid multiple inheritance vs. Cython (2007-09)

TESTS:
    sage: R = PolynomialRing(GF(2**8,'a'),10,'x', order='invlex')
    sage: R == loads(dumps(R))
    True
    sage: P.<a,b> = PolynomialRing(GF(7), 2)
    sage: f = (a^3 + 2*b^2*a)^7; f
    a^21 + 2*a^7*b^14



Classes [hide private]
  PolynomialRing_singular_repr
Implements methods to convert polynomial rings to Singular.
  Polynomial_singular_repr
Implements coercion of polynomials to Singular polynomials.
Functions [hide private]
 
can_convert_to_singular(R)
Returns True if this ring's base field or ring can be represented in Singular, and the polynomial ring has at least one generator.
source code
 
_singular_func(self, singular=Singular, have_ring=False, force=False)
Return Singular polynomial matching this polynomial.
source code
 
_singular_init_func(self, singular=Singular, have_ring=False, force=False)
Return corresponding Singular polynomial but enforce that a new instance is created in the Singular interpreter.
source code
 
lcm_func(self, right, have_ring=False)
Returns the least common multiple of this element and the right element.
source code
 
resultant_func(self, other, variable=['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1', 'a...)
computes the resultant of self and the first argument with respect to the variable given as the second argument.
source code
Function Details [hide private]

can_convert_to_singular(R)

source code 

Returns True if this ring's base field or ring can be
represented in Singular, and the polynomial ring has at
least one generator.  If this is True then this polynomial
ring can be represented in Singular.

The following base rings are supported: $GF(p)$, $GF(p^n)$,
rationals, number fields, and real and complex fields.

EXAMPLES:
    sage: from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular
    sage: can_convert_to_singular(PolynomialRing(QQ, names=['x']))
    True

    sage: can_convert_to_singular(PolynomialRing(QQ, names=[]))
    False

_singular_func(self, singular=Singular, have_ring=False, force=False)

source code 

Return Singular polynomial matching this polynomial.

INPUT:
    singular -- Singular instance to use

    have_ring -- if True we will not attempt to set this
                 element's ring as the current Singular
                 ring. This is useful to speed up a batch of
                 f._singular_() calls. However, it's dangerous
                 as it might lead to wrong results if another
                 ring is singluar.current_ring().  (default:
                 False)

    force -- polynomials over ZZ may be coerced to Singular by
             treating them as polynomials over QQ. This is
             inexact but works for some cases where the
             coeffients are not considered (default: False).


EXAMPLES:
    sage: P.<a,b> = PolynomialRing(GF(7), 2)
    sage: f = (a^3 + 2*b^2*a)^7; f
    a^21 + 2*a^7*b^14
    sage: h = f._singular_(); h
    a^21+2*a^7*b^14
    sage: P(h)
    a^21 + 2*a^7*b^14
    sage: P(h^20) == f^20
    True

    sage: R.<x> = PolynomialRing(GF(7))
    sage: f = (x^3 + 2*x^2*x)^7
    sage: f
    3*x^21
    sage: h = f._singular_(); h
    3*x^21
    sage: R(h)
    3*x^21
    sage: R(h^20) == f^20
    True

_singular_init_func(self, singular=Singular, have_ring=False, force=False)

source code 

Return corresponding Singular polynomial but enforce that a new
instance is created in the Singular interpreter.

Use self._singular_() instead.

lcm_func(self, right, have_ring=False)

source code 

Returns the least common multiple of this element and the right element.

INPUT:
    right -- multivariate polynomial
    have_ring -- see self._singular_() (default:False)

OUTPUT:
    multivariate polynomial representing the least common
    multiple of self and right

ALGORITHM: Singular

EXAMPLES:
    sage: r.<x,y> = PolynomialRing(GF(2**8,'a'),2)
    sage: a = r.base_ring().0
    sage: f = (a^2+a)*x^2*y + (a^4+a^3+a)*y + a^5
    sage: f.lcm(x^4)
    (a^2 + a)*x^6*y + (a^4 + a^3 + a)*x^4*y + (a^5)*x^4
    
    sage: w = var('w')
    sage: r.<x,y> = PolynomialRing(NumberField(w^4+1,'a'),2)
    sage: a = r.base_ring().0
    sage: f = (a^2+a)*x^2*y + (a^4+a^3+a)*y + a^5
    sage: f.lcm(x^4)
    (a^2 + a)*x^6*y + (a^3 + a - 1)*x^4*y + (-a)*x^4
    
TESTS:
    sage: R.<X>=QQ[]
    sage: a=R(1)
    sage: b=X
    sage: lcm(b,a)
    X
    sage: lcm(a,b)
    X

resultant_func(self, other, variable=['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1', 'a...)

source code 

computes the resultant of self and the first argument with
respect to the variable given as the second argument.

If a second argument is not provide the first variable of
self.parent() is chosen.

INPUT:
    other -- polynomial in self.parent()
    variable -- optional variable (of type polynomial) in self.parent() (default: None)

EXAMPLE:
    sage: P.<x,y> = PolynomialRing(QQ,2)
    sage: a = x+y
    sage: b = x^3-y^3
    sage: c = a.resultant(b); c
    -2*y^3
    sage: d = a.resultant(b,y); d
    2*x^3

TESTS:
    sage: from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_polydict_domain
    sage: P.<x,y> = MPolynomialRing_polydict_domain(QQ,2,order='degrevlex')
    sage: a = x+y
    sage: b = x^3-y^3
    sage: c = a.resultant(b); c
    -2*y^3
    sage: d = a.resultant(b,y); d
    2*x^3