(exprs, *symbols, **options)
Construct a ring deriving generators and domain from options and input expressions.

    Parameters
    ----------
    exprs : :class:`Expr` or sequence of :class:`Expr` (sympifiable)
    symbols : sequence of :class:`Symbol`/:class:`Expr`
    options : keyword arguments understood by :class:`Options`

    Examples
    --------
    >>> from sympy.core import symbols
    >>> from sympy.polys.rings import sring
    >>> from sympy.polys.domains import ZZ
    >>> from sympy.polys.orderings import lex

    >>> x, y, z = symbols("x,y,z")
    >>> R, f = sring(x + 2*y + 3*z)
    >>> R
    Polynomial ring in x, y, z over ZZ with lex order
    >>> f
    x + 2*y + 3*z
    >>> type(_)
    <class 'sympy.polys.rings.PolyElement'>
Construct a ring deriving generators and domain from options and input expressions.
Construct a ring deriving generators and domain from options and input expressions .
def sring(exprs, *symbols, **options):
    """Construct a ring deriving generators and domain from options and input expressions.

    Parameters
    ----------
    exprs : :class:`Expr` or sequence of :class:`Expr` (sympifiable)
    symbols : sequence of :class:`Symbol`/:class:`Expr`
    options : keyword arguments understood by :class:`Options`

    Examples
    --------
    >>> from sympy.core import symbols
    >>> from sympy.polys.rings import sring
    >>> from sympy.polys.domains import ZZ
    >>> from sympy.polys.orderings import lex

    >>> x, y, z = symbols("x,y,z")
    >>> R, f = sring(x + 2*y + 3*z)
    >>> R
    Polynomial ring in x, y, z over ZZ with lex order
    >>> f
    x + 2*y + 3*z
    >>> type(_)
    <class 'sympy.polys.rings.PolyElement'>

    """
    single = False

    if not is_sequence(exprs):
        exprs, single = [exprs], True

    exprs = list(map(sympify, exprs))
    opt = build_options(symbols, options)

    # TODO: rewrite this so that it doesn't use expand() (see poly()).
    reps, opt = _parallel_dict_from_expr(exprs, opt)

    if opt.domain is None:
        # NOTE: this is inefficient because construct_domain() automatically
        # performs conversion to the target domain. It shouldn't do this.
        coeffs = sum([ list(rep.values()) for rep in reps ], [])
        opt.domain, _ = construct_domain(coeffs, opt=opt)

    _ring = PolyRing(opt.gens, opt.domain, opt.order)
    polys = list(map(_ring.from_dict, reps))

    if single:
        return (_ring, polys[0])
    else:
        return (_ring, polys)
def sring ( exprs , * symbols , * * options ) : single = False if not is_sequence ( exprs ) : exprs , single = [ exprs ] , True exprs = list ( map ( sympify , exprs ) ) opt = build_options ( symbols , options ) # TODO: rewrite this so that it doesn't use expand() (see poly()). reps , opt = _parallel_dict_from_expr ( exprs , opt ) if opt . domain is None : # NOTE: this is inefficient because construct_domain() automatically # performs conversion to the target domain. It shouldn't do this. coeffs = sum ( [ list ( rep . values ( ) ) for rep in reps ] , [ ] ) opt . domain , _ = construct_domain ( coeffs , opt = opt ) _ring = PolyRing ( opt . gens , opt . domain , opt . order ) polys = list ( map ( _ring . from_dict , reps ) ) if single : return ( _ring , polys [ 0 ] ) else : return ( _ring , polys )