def _single_variate(base_ring, names, sparse): """ EXAMPLES:: sage: from sage.rings.polynomial.laurent_polynomial_ring import _single_variate sage: _single_variate(QQ, ('x',), False) Univariate Laurent Polynomial Ring in x over Rational Field """ ############################################################ # This should later get moved to an actual single variate # # implementation with valuation tracking, # # but I don't want to right now. # ############################################################ # We need to come up with a name for the inverse that is easy to search # for in a string *and* doesn't overlap with the name that we already have. # For now, I'm going to use a name mangling with checking method. names = normalize_names(1, names) key = (base_ring, names, sparse) P = _get_from_cache(key) if P is not None: return P prepend_string = "qk" while True: if prepend_string in names: prepend_string += 'k' else: break R = _multi_variate_poly(base_ring, names, 1, sparse, 'degrevlex', None) P = LaurentPolynomialRing_mpair(R, prepend_string, names) _save_in_cache(key, P) return P
def _multi_variate(base_ring, names, n, sparse, order): """ EXAMPLES:: sage: from sage.rings.polynomial.laurent_polynomial_ring import _multi_variate sage: _multi_variate(QQ, ('x','y'), 2, False, 'degrevlex') Multivariate Laurent Polynomial Ring in x, y over Rational Field """ # We need to come up with a name for the inverse that is easy to search # for in a string *and* doesn't overlap with the name that we already have. # For now, I'm going to use a name mangling with checking method. names = normalize_names(n, names) from .term_order import TermOrder order = TermOrder(order, n) if isinstance(names, list): names = tuple(names) elif isinstance(names, str): if ',' in names: names = tuple(names.split(',')) key = (base_ring, names, n, sparse, order) P = _get_from_cache(key) if P is not None: return P prepend_string = "qk" while True: for a in names: if prepend_string in a: prepend_string += 'k' break else: break R = _multi_variate_poly(base_ring, names, n, sparse, order, None) P = LaurentPolynomialRing_mpair(R, prepend_string, names) _save_in_cache(key, P) return P
def _multi_variate(base_ring, names, n, sparse, order): """ EXAMPLES:: sage: from sage.rings.polynomial.laurent_polynomial_ring import _multi_variate sage: _multi_variate(QQ, ('x','y'), 2, False, 'degrevlex') Multivariate Laurent Polynomial Ring in x, y over Rational Field """ # We need to come up with a name for the inverse that is easy to search # for in a string *and* doesn't overlap with the name that we already have. # For now, I'm going to use a name mangling with checking method. names = normalize_names(n, names) from term_order import TermOrder order = TermOrder(order, n) if isinstance(names, list): names = tuple(names) elif isinstance(names, str): if ',' in names: names = tuple(names.split(',')) key = (base_ring, names, n, sparse, order) P = _get_from_cache(key) if P is not None: return P prepend_string = "qk" while True: for a in names: if prepend_string in a: prepend_string += 'k' break else: break R = _multi_variate_poly(base_ring, names, n, sparse, order, None) P = LaurentPolynomialRing_mpair(R, prepend_string, names) _save_in_cache(key, P) return P