def _multi_variate(base_ring, names, n, sparse, order, implementation): # if not sparse: # raise ValueError, "A dense representation of multivariate polynomials is not supported" sparse = False # "True" would be correct, since there is no dense implementation of # multivariate polynomials. However, traditionally, "False" is used in the key, # even though it is meaningless. if implementation is not None: raise ValueError( "The %s implementation is not known for multivariate polynomial rings" % implementation) names = normalize_names(n, names) n = len(names) import sage.rings.polynomial.multi_polynomial_ring as m from sage.rings.polynomial.term_order import TermOrder order = TermOrder(order, n) key = (base_ring, names, n, sparse, order) R = _get_from_cache(key) if not R is None: return R from sage.rings.polynomial.multi_polynomial_libsingular import MPolynomialRing_libsingular if isinstance(base_ring, ring.IntegralDomain): if n < 1: R = m.MPolynomialRing_polydict_domain(base_ring, n, names, order) else: try: R = MPolynomialRing_libsingular(base_ring, n, names, order) except (TypeError, NotImplementedError): R = m.MPolynomialRing_polydict_domain(base_ring, n, names, order) else: if not base_ring.is_zero(): try: R = MPolynomialRing_libsingular(base_ring, n, names, order) except (TypeError, NotImplementedError): R = m.MPolynomialRing_polydict(base_ring, n, names, order) else: R = m.MPolynomialRing_polydict(base_ring, n, names, order) _save_in_cache(key, R) return R
def _multi_variate(base_ring, names, sparse=None, order="degrevlex", implementation=None): # if not sparse: # raise ValueError("a dense representation of multivariate polynomials is not supported") sparse = False if implementation is None: force_singular = False elif implementation == "singular": force_singular = True else: raise ValueError( "unknown implementation %r for multivariate polynomial rings" % (implementation, )) n = len(names) from sage.rings.polynomial.term_order import TermOrder order = TermOrder(order, n) key = (base_ring, names, n, sparse, order) R = _get_from_cache(key) if not R is None: return R from sage.rings.polynomial.multi_polynomial_libsingular import MPolynomialRing_libsingular try: R = MPolynomialRing_libsingular(base_ring, n, names, order) except (TypeError, NotImplementedError): if force_singular: raise import sage.rings.polynomial.multi_polynomial_ring as m if isinstance(base_ring, ring.IntegralDomain): R = m.MPolynomialRing_polydict_domain(base_ring, n, names, order) else: R = m.MPolynomialRing_polydict(base_ring, n, names, order) _save_in_cache(key, R) return R