
    \hZ                         S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	  SSK
Jr  SSKJr  SSKJr  SS	KJr  SS
KJrJrJrJr  SSKJr  \ " S S\\\5      5       rS rg)z1Implementation of :class:`AlgebraicField` class.     )AddMul)S)Dummysymbols)CharacteristicZero)Field)SimpleDomain)ANP)CoercionFailedDomainErrorNotAlgebraicIsomorphismFailed)publicc                      \ rS rSrSr\rS=rrSr	Sr
SrSS.S jrS rS	 rS
 rS rSS.S jrS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"S r#S r$S  r%S! r&S" r'S(S# jr(S$ r)S% r*S)S& jr+S'r,g)*AlgebraicField   aP   Algebraic number field :ref:`QQ(a)`

A :ref:`QQ(a)` domain represents an `algebraic number field`_
`\mathbb{Q}(a)` as a :py:class:`~.Domain` in the domain system (see
:ref:`polys-domainsintro`).

A :py:class:`~.Poly` created from an expression involving `algebraic
numbers`_ will treat the algebraic numbers as generators if the generators
argument is not specified.

>>> from sympy import Poly, Symbol, sqrt
>>> x = Symbol('x')
>>> Poly(x**2 + sqrt(2))
Poly(x**2 + (sqrt(2)), x, sqrt(2), domain='ZZ')

That is a multivariate polynomial with ``sqrt(2)`` treated as one of the
generators (variables). If the generators are explicitly specified then
``sqrt(2)`` will be considered to be a coefficient but by default the
:ref:`EX` domain is used. To make a :py:class:`~.Poly` with a :ref:`QQ(a)`
domain the argument ``extension=True`` can be given.

>>> Poly(x**2 + sqrt(2), x)
Poly(x**2 + sqrt(2), x, domain='EX')
>>> Poly(x**2 + sqrt(2), x, extension=True)
Poly(x**2 + sqrt(2), x, domain='QQ<sqrt(2)>')

A generator of the algebraic field extension can also be specified
explicitly which is particularly useful if the coefficients are all
rational but an extension field is needed (e.g. to factor the
polynomial).

>>> Poly(x**2 + 1)
Poly(x**2 + 1, x, domain='ZZ')
>>> Poly(x**2 + 1, extension=sqrt(2))
Poly(x**2 + 1, x, domain='QQ<sqrt(2)>')

It is possible to factorise a polynomial over a :ref:`QQ(a)` domain using
the ``extension`` argument to :py:func:`~.factor` or by specifying the domain
explicitly.

>>> from sympy import factor, QQ
>>> factor(x**2 - 2)
x**2 - 2
>>> factor(x**2 - 2, extension=sqrt(2))
(x - sqrt(2))*(x + sqrt(2))
>>> factor(x**2 - 2, domain='QQ<sqrt(2)>')
(x - sqrt(2))*(x + sqrt(2))
>>> factor(x**2 - 2, domain=QQ.algebraic_field(sqrt(2)))
(x - sqrt(2))*(x + sqrt(2))

The ``extension=True`` argument can be used but will only create an
extension that contains the coefficients which is usually not enough to
factorise the polynomial.

>>> p = x**3 + sqrt(2)*x**2 - 2*x - 2*sqrt(2)
>>> factor(p)                         # treats sqrt(2) as a symbol
(x + sqrt(2))*(x**2 - 2)
>>> factor(p, extension=True)
(x - sqrt(2))*(x + sqrt(2))**2
>>> factor(x**2 - 2, extension=True)  # all rational coefficients
x**2 - 2

It is also possible to use :ref:`QQ(a)` with the :py:func:`~.cancel`
and :py:func:`~.gcd` functions.

>>> from sympy import cancel, gcd
>>> cancel((x**2 - 2)/(x - sqrt(2)))
(x**2 - 2)/(x - sqrt(2))
>>> cancel((x**2 - 2)/(x - sqrt(2)), extension=sqrt(2))
x + sqrt(2)
>>> gcd(x**2 - 2, x - sqrt(2))
1
>>> gcd(x**2 - 2, x - sqrt(2), extension=sqrt(2))
x - sqrt(2)

When using the domain directly :ref:`QQ(a)` can be used as a constructor
to create instances which then support the operations ``+,-,*,**,/``. The
:py:meth:`~.Domain.algebraic_field` method is used to construct a
particular :ref:`QQ(a)` domain. The :py:meth:`~.Domain.from_sympy` method
can be used to create domain elements from normal SymPy expressions.

>>> K = QQ.algebraic_field(sqrt(2))
>>> K
QQ<sqrt(2)>
>>> xk = K.from_sympy(3 + 4*sqrt(2))
>>> xk  # doctest: +SKIP
ANP([4, 3], [1, 0, -2], QQ)

Elements of :ref:`QQ(a)` are instances of :py:class:`~.ANP` which have
limited printing support. The raw display shows the internal
representation of the element as the list ``[4, 3]`` representing the
coefficients of ``1`` and ``sqrt(2)`` for this element in the form
``a * sqrt(2) + b * 1`` where ``a`` and ``b`` are elements of :ref:`QQ`.
The minimal polynomial for the generator ``(x**2 - 2)`` is also shown in
the :ref:`dup-representation` as the list ``[1, 0, -2]``. We can use
:py:meth:`~.Domain.to_sympy` to get a better printed form for the
elements and to see the results of operations.

>>> xk = K.from_sympy(3 + 4*sqrt(2))
>>> yk = K.from_sympy(2 + 3*sqrt(2))
>>> xk * yk  # doctest: +SKIP
ANP([17, 30], [1, 0, -2], QQ)
>>> K.to_sympy(xk * yk)
17*sqrt(2) + 30
>>> K.to_sympy(xk + yk)
5 + 7*sqrt(2)
>>> K.to_sympy(xk ** 2)
24*sqrt(2) + 41
>>> K.to_sympy(xk / yk)
sqrt(2)/14 + 9/7

Any expression representing an algebraic number can be used to generate
a :ref:`QQ(a)` domain provided its `minimal polynomial`_ can be computed.
The function :py:func:`~.minpoly` function is used for this.

>>> from sympy import exp, I, pi, minpoly
>>> g = exp(2*I*pi/3)
>>> g
exp(2*I*pi/3)
>>> g.is_algebraic
True
>>> minpoly(g, x)
x**2 + x + 1
>>> factor(x**3 - 1, extension=g)
(x - 1)*(x - exp(2*I*pi/3))*(x + 1 + exp(2*I*pi/3))

It is also possible to make an algebraic field from multiple extension
elements.

>>> K = QQ.algebraic_field(sqrt(2), sqrt(3))
>>> K
QQ<sqrt(2) + sqrt(3)>
>>> p = x**4 - 5*x**2 + 6
>>> factor(p)
(x**2 - 3)*(x**2 - 2)
>>> factor(p, domain=K)
(x - sqrt(2))*(x + sqrt(2))*(x - sqrt(3))*(x + sqrt(3))
>>> factor(p, extension=[sqrt(2), sqrt(3)])
(x - sqrt(2))*(x + sqrt(2))*(x - sqrt(3))*(x + sqrt(3))

Multiple extension elements are always combined together to make a single
`primitive element`_. In the case of ``[sqrt(2), sqrt(3)]`` the primitive
element chosen is ``sqrt(2) + sqrt(3)`` which is why the domain displays
as ``QQ<sqrt(2) + sqrt(3)>``. The minimal polynomial for the primitive
element is computed using the :py:func:`~.primitive_element` function.

>>> from sympy import primitive_element
>>> primitive_element([sqrt(2), sqrt(3)], x)
(x**4 - 10*x**2 + 1, [1, 1])
>>> minpoly(sqrt(2) + sqrt(3), x)
x**4 - 10*x**2 + 1

The extension elements that generate the domain can be accessed from the
domain using the :py:attr:`~.ext` and :py:attr:`~.orig_ext` attributes as
instances of :py:class:`~.AlgebraicNumber`. The minimal polynomial for
the primitive element as a :py:class:`~.DMP` instance is available as
:py:attr:`~.mod`.

>>> K = QQ.algebraic_field(sqrt(2), sqrt(3))
>>> K
QQ<sqrt(2) + sqrt(3)>
>>> K.ext
sqrt(2) + sqrt(3)
>>> K.orig_ext
(sqrt(2), sqrt(3))
>>> K.mod  # doctest: +SKIP
DMP_Python([1, 0, -10, 0, 1], QQ)

The `discriminant`_ of the field can be obtained from the
:py:meth:`~.discriminant` method, and an `integral basis`_ from the
:py:meth:`~.integral_basis` method. The latter returns a list of
:py:class:`~.ANP` instances by default, but can be made to return instances
of :py:class:`~.Expr` or :py:class:`~.AlgebraicNumber` by passing a ``fmt``
argument. The maximal order, or ring of integers, of the field can also be
obtained from the :py:meth:`~.maximal_order` method, as a
:py:class:`~sympy.polys.numberfields.modules.Submodule`.

>>> zeta5 = exp(2*I*pi/5)
>>> K = QQ.algebraic_field(zeta5)
>>> K
QQ<exp(2*I*pi/5)>
>>> K.discriminant()
125
>>> K = QQ.algebraic_field(sqrt(5))
>>> K
QQ<sqrt(5)>
>>> K.integral_basis(fmt='sympy')
[1, 1/2 + sqrt(5)/2]
>>> K.maximal_order()
Submodule[[2, 0], [1, 1]]/2

The factorization of a rational prime into prime ideals of the field is
computed by the :py:meth:`~.primes_above` method, which returns a list
of :py:class:`~sympy.polys.numberfields.primes.PrimeIdeal` instances.

>>> zeta7 = exp(2*I*pi/7)
>>> K = QQ.algebraic_field(zeta7)
>>> K
QQ<exp(2*I*pi/7)>
>>> K.primes_above(11)
[(11, _x**3 + 5*_x**2 + 4*_x - 1), (11, _x**3 - 4*_x**2 - 5*_x - 1)]

The Galois group of the Galois closure of the field can be computed (when
the minimal polynomial of the field is of sufficiently small degree).

>>> K.galois_group(by_name=True)[0]
S6TransitiveSubgroups.C6

Notes
=====

It is not currently possible to generate an algebraic extension over any
domain other than :ref:`QQ`. Ideally it would be possible to generate
extensions like ``QQ(x)(sqrt(x**2 - 2))``. This is equivalent to the
quotient ring ``QQ(x)[y]/(y**2 - x**2 + 2)`` and there are two
implementations of this kind of quotient ring/extension in the
:py:class:`~.QuotientRing` and :py:class:`~.MonogenicFiniteExtension`
classes.  Each of those implementations needs some work to make them fully
usable though.

.. _algebraic number field: https://en.wikipedia.org/wiki/Algebraic_number_field
.. _algebraic numbers: https://en.wikipedia.org/wiki/Algebraic_number
.. _discriminant: https://en.wikipedia.org/wiki/Discriminant_of_an_algebraic_number_field
.. _integral basis: https://en.wikipedia.org/wiki/Algebraic_number_field#Integral_basis
.. _minimal polynomial: https://en.wikipedia.org/wiki/Minimal_polynomial_(field_theory)
.. _primitive element: https://en.wikipedia.org/wiki/Primitive_element_theorem
TFNaliasc                   UR                   (       d  [        S5      eSSKJn  [	        U5      S:X  a!  [        US   [        5      (       a	  US   SS nOUnUc  [	        U5      S:X  a  [        US   SS5      nXPl         U" X2S9U l	         U R                  R                  R                  U l         U=U l        U l        SU l        U R                  4=U l        U l        U " U" S5      U" S5      /5      U l        U R&                  R)                  U R                  R+                  5       U5      U l        U R&                  R-                  U R                  R+                  5       U5      U l        SU l        SU l        0 U l        g)a\  
Parameters
==========

dom : :py:class:`~.Domain`
    The base field over which this is an extension field.
    Currently only :ref:`QQ` is accepted.

*ext : One or more :py:class:`~.Expr`
    Generators of the extension. These should be expressions that are
    algebraic over `\mathbb{Q}`.

alias : str, :py:class:`~.Symbol`, None, optional (default=None)
    If provided, this will be used as the alias symbol for the
    primitive element of the :py:class:`~.AlgebraicField`.
    If ``None``, while ``ext`` consists of exactly one
    :py:class:`~.AlgebraicNumber`, its alias (if any) will be used.
z&ground domain must be a rational fieldr   to_number_field   Nr   r   )is_QQr   sympy.polys.numberfieldsr   len
isinstancetuplegetattrorig_extextminpolyrepmoddomaindomngensr   gensunitdtypezeroto_listone_maximal_order_discriminant_nilradicals_mod_p)selfr'   r   r"   r   r!   s         Z/var/www/auris/envauris/lib/python3.13/site-packages/sympy/polys/domains/algebraicfield.py__init__AlgebraicField.__init__   sG   & yyFGG<s8q=ZA661vabzHH=SX]CFGT2E 	 #34	 88##''	 "%$dh
$(HH;.ty#a&#a&)*	JJOODHH$4$4$6<	::>>$(("2"2"4c:"!"$    c                 j    U R                  XR                  R                  5       U R                  5      $ N)r+   r%   r-   r'   )r2   elements     r3   newAlgebraicField.newG  s$    zz'88#3#3#5txx@@r6   c                 d    [        U R                  5      S-   [        U R                  5      -   S-   $ )N<>)strr'   r"   r2   s    r3   __str__AlgebraicField.__str__J  s'    488}s"S]2S88r6   c                     [        U R                  R                  U R                  U R                  U R
                  45      $ r8   )hash	__class____name__r+   r'   r"   r@   s    r3   __hash__AlgebraicField.__hash__M  s,    T^^,,djj$((DHHMNNr6   c                     [        U[        5      (       a9  U R                  UR                  :H  =(       a    U R                  UR                  :H  $ [        $ )z0Returns ``True`` if two domains are equivalent. )r   r   r+   r"   NotImplemented)r2   others     r3   __eq__AlgebraicField.__eq__P  s:    e^,,::,FUYY1FF!!r6   c                P    [        U R                  /U R                  4U-   Q7SU06$ )z?Returns an algebraic field, i.e. `\mathbb{Q}(\alpha, \ldots)`. r   )r   r'   r"   )r2   r   	extensions      r3   algebraic_fieldAlgebraicField.algebraic_fieldW  s&    dhhP488+	*AP%PPr6   c                 8    U R                   R                  U5      $ )z@Convert ``a`` of ``dtype`` to an :py:class:`~.AlgebraicNumber`. )r"   field_elementr2   as     r3   
to_alg_numAlgebraicField.to_alg_num[  s    xx%%a((r6   c                 f    [        U S5      (       d  [        U 5      U l        U R                  U5      $ )z.Convert ``a`` of ``dtype`` to a SymPy object. 
_converter)hasattr_make_converterrY   rT   s     r3   to_sympyAlgebraicField.to_sympy_  s,     t\**-d3DOq!!r6   c                     U " U R                   R                  U5      /5      $ ! [         a     Of = fSSKJn   U " U" XR
                  5      R                  5       5      $ ! [        [        4 a    [        U< SU < 35      ef = f)z)Convert SymPy's expression to ``dtype``. r   r   z$ is not a valid algebraic number in )	r'   
from_sympyr   r   r   r"   native_coeffsr   r   )r2   rU   r   s      r3   r_   AlgebraicField.from_sympyg  s    	,,Q/011 		 	=	H884BBDEE/0 	H >?FH H	Hs   !$ 
11%A! !#Bc                 D    U " U R                   R                  X5      5      $ z.Convert a Python ``int`` object to ``dtype``. r'   convertK1rU   K0s      r3   from_ZZAlgebraicField.from_ZZv      "&&..'((r6   c                 D    U " U R                   R                  X5      5      $ rc   rd   rf   s      r3   from_ZZ_pythonAlgebraicField.from_ZZ_pythonz  rk   r6   c                 D    U " U R                   R                  X5      5      $ z3Convert a Python ``Fraction`` object to ``dtype``. rd   rf   s      r3   from_QQAlgebraicField.from_QQ~  rk   r6   c                 D    U " U R                   R                  X5      5      $ rp   rd   rf   s      r3   from_QQ_pythonAlgebraicField.from_QQ_python  rk   r6   c                 D    U " U R                   R                  X5      5      $ )z,Convert a GMPY ``mpz`` object to ``dtype``. rd   rf   s      r3   from_ZZ_gmpyAlgebraicField.from_ZZ_gmpy  rk   r6   c                 D    U " U R                   R                  X5      5      $ )z,Convert a GMPY ``mpq`` object to ``dtype``. rd   rf   s      r3   from_QQ_gmpyAlgebraicField.from_QQ_gmpy  rk   r6   c                 D    U " U R                   R                  X5      5      $ )z.Convert a mpmath ``mpf`` object to ``dtype``. rd   rf   s      r3   from_RealFieldAlgebraicField.from_RealField  rk   r6   c                     [        SU -  5      e)z)Returns a ring associated with ``self``. z#there is no ring associated with %s)r   r@   s    r3   get_ringAlgebraicField.get_ring  s    ?$FGGr6   c                 T    U R                   R                  UR                  5       5      $ )z#Returns True if ``a`` is positive. )r'   is_positiveLCrT   s     r3   r   AlgebraicField.is_positive      xx##ADDF++r6   c                 T    U R                   R                  UR                  5       5      $ )z#Returns True if ``a`` is negative. )r'   is_negativer   rT   s     r3   r   AlgebraicField.is_negative  r   r6   c                 T    U R                   R                  UR                  5       5      $ )z'Returns True if ``a`` is non-positive. )r'   is_nonpositiver   rT   s     r3   r   AlgebraicField.is_nonpositive      xx&&qttv..r6   c                 T    U R                   R                  UR                  5       5      $ )z'Returns True if ``a`` is non-negative. )r'   is_nonnegativer   rT   s     r3   r   AlgebraicField.is_nonnegative  r   r6   c                     U$ )zReturns numerator of ``a``.  rT   s     r3   numerAlgebraicField.numer  s    r6   c                     U R                   $ )zReturns denominator of ``a``. )r.   rT   s     r3   denomAlgebraicField.denom  s    xxr6   c                 B    U R                  UR                  U5      5      $ )z=Convert AlgebraicField element 'a' to another AlgebraicField r_   r\   rf   s      r3   from_AlgebraicField"AlgebraicField.from_AlgebraicField      }}R[[^,,r6   c                 B    U R                  UR                  U5      5      $ )z4Convert a GaussianInteger element 'a' to ``dtype``. r   rf   s      r3   from_GaussianIntegerRing'AlgebraicField.from_GaussianIntegerRing  r   r6   c                 B    U R                  UR                  U5      5      $ )z5Convert a GaussianRational element 'a' to ``dtype``. r   rf   s      r3   from_GaussianRationalField)AlgebraicField.from_GaussianRationalField  r   r6   c                 L    SSK Jn  U" X R                  S9u  p#X l        X0l        g )Nr   )	round_two)radicals)sympy.polys.numberfields.basisr   r1   r/   r0   )r2   r   ZKdKs       r3   _do_round_twoAlgebraicField._do_round_two  s#    <4*A*AB r6   c                 T    U R                   c  U R                  5         U R                   $ )z
Compute the maximal order, or ring of integers, of the field.

Returns
=======

:py:class:`~sympy.polys.numberfields.modules.Submodule`.

See Also
========

integral_basis

)r/   r   r@   s    r3   maximal_orderAlgebraicField.maximal_order  s(     & """r6   c                    U R                  5       nUR                  nUR                  S   n[        U5       Vs/ s H:  oPR	                  [        [        USS2U4   R                  5       5      5      5      PM<     nnUS:X  a!  U Vs/ s H  opR                  U5      PM     sn$ US:X  a!  U Vs/ s H  opR                  U5      PM     sn$ U$ s  snf s  snf s  snf )a[  
Get an integral basis for the field.

Parameters
==========

fmt : str, None, optional (default=None)
    If ``None``, return a list of :py:class:`~.ANP` instances.
    If ``"sympy"``, convert each element of the list to an
    :py:class:`~.Expr`, using ``self.to_sympy()``.
    If ``"alg"``, convert each element of the list to an
    :py:class:`~.AlgebraicNumber`, using ``self.to_alg_num()``.

Examples
========

>>> from sympy import QQ, AlgebraicNumber, sqrt
>>> alpha = AlgebraicNumber(sqrt(5), alias='alpha')
>>> k = QQ.algebraic_field(alpha)
>>> B0 = k.integral_basis()
>>> B1 = k.integral_basis(fmt='sympy')
>>> B2 = k.integral_basis(fmt='alg')
>>> print(B0[1])  # doctest: +SKIP
ANP([mpq(1,2), mpq(1,2)], [mpq(1,1), mpq(0,1), mpq(-5,1)], QQ)
>>> print(B1[1])
1/2 + alpha/2
>>> print(B2[1])
alpha/2 + 1/2

In the last two cases we get legible expressions, which print somewhat
differently because of the different types involved:

>>> print(type(B1[1]))
<class 'sympy.core.add.Add'>
>>> print(type(B2[1]))
<class 'sympy.core.numbers.AlgebraicNumber'>

See Also
========

to_sympy
to_alg_num
maximal_order
r   Nsympyalg)
r   	QQ_matrixshaperanger:   listreversedflatr\   rV   )r2   fmtr   MnjBbs           r3   integral_basisAlgebraicField.integral_basis  s    Z !LLGGAJ?DQxHx!XXd8AadGLLN345xH'>./0aMM!$a00E\0121OOA&22 I02s   ACC-Cc                 T    U R                   c  U R                  5         U R                   $ )z"Get the discriminant of the field.)r0   r   r@   s    r3   discriminantAlgebraicField.discriminant
  s&    % !!!r6   c                     SSK Jn  U R                  5       nU R                  5       nU R                  R                  U5      nU" XXES9$ )z@Compute the prime ideals lying above a given rational prime *p*.r   )prime_decomp)r   r   radical)sympy.polys.numberfields.primesr   r   r   r1   get)r2   pr   r   r   rads         r3   primes_aboveAlgebraicField.primes_above  sD    @! %%))!,A99r6   c                 R    U R                   R                  5       R                  XUS9$ )ak  
Compute the Galois group of the Galois closure of this field.

Examples
========

If the field is Galois, the order of the group will equal the degree
of the field:

>>> from sympy import QQ
>>> from sympy.abc import x
>>> k = QQ.alg_field_from_poly(x**4 + 1)
>>> G, _ = k.galois_group()
>>> G.order()
4

If the field is not Galois, then its Galois closure is a proper
extension, and the order of the Galois group will be greater than the
degree of the field:

>>> k = QQ.alg_field_from_poly(x**4 - 2)
>>> G, _ = k.galois_group()
>>> G.order()
8

See Also
========

sympy.polys.numberfields.galoisgroups.galois_group

)by_name	max_tries	randomize)r"   minpoly_of_elementgalois_group)r2   r   r   r   s       r3   r   AlgebraicField.galois_group  s1    @ xx**,99I : G 	Gr6   )rY   r0   r/   r1   r'   r&   r"   r)   r%   r(   r.   r!   r   r*   r,   r8   )F   F)-rF   
__module____qualname____firstlineno____doc__r   r+   is_AlgebraicFieldis_Algebraicis_Numericalhas_assoc_Ringhas_assoc_Fieldr4   r:   rA   rG   rL   rP   rV   r\   r_   ri   rm   rq   rt   rw   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__r   r6   r3   r   r      s    bH E'++LNO(, H%TA9O" 15 Q)"H)))))))H,,//--- #&5n":!Gr6   r   c                 h  ^^^ U R                   R                  5       nU R                  R                  nU R                  R                  mUR
                  (       d7  [        U R                  R                  5       5       Vs/ s H  o1U-  PM	     nnGOSSK	J
n  [        UR                  5       R                  5       6 u  pg[        S[        U5       3[         S9n[#        [        X5      5      n	U R                  U   n
[        U
R$                  5       Vs/ s H  oR&                  R)                  U5      PM     nn[        X5       VVs0 s H  u  pX" U5      _M     nnnU
R&                  R+                  U5      nU	R                  5        VVs/ s H  u  nnU
R                  U" UU5      5      PM      nnnU
R,                  U/n[        SU R                  R                  5       5       H+  nUS   U-  R/                  U5      nUR1                  U5        M-     U Vs/ s H"  nUR                  5       R3                  U	5      PM$     nnU Vs/ s H  nUR5                  5       PM     nnU Vs/ s H)  n[#        S [6        R8                  " U5       5       5      PM+     nn[;        5       R<                  " U6 mT VVs/ s H:  nU Vs/ s H)  nU" UR?                  U[@        RB                  5      5      PM+     snPM<     snnmUUU4S jnU$ s  snf s  snf s  snnf s  snnf s  snf s  snf s  snf s  snf s  snnf )	z/Construct the converter to convert back to Exprr   )r#   za:)cls   c              3   L   #    U  H  oR                  5       S S S2   v   M     g 7f)Nr   )as_coeff_Mul).0ts     r3   	<genexpr>"_make_converter.<locals>.<genexpr>p  s      C2BQ.."4R4(2Bs   "$c           
         > U R                  5       SSS2   nT Vs/ s H  n[        S [        X!5       5       5      PM      nnU Vs/ s H  nT	" U5      PM     nn[        S [        UT5       5       6 nU$ s  snf s  snf )z!Convert a to Expr using converterNr   c              3   .   #    U  H  u  pX-  v   M     g 7fr8   r   )r   mijajs      r3   r   5_make_converter.<locals>.converter.<locals>.<genexpr>y  s     <WS#&s   c              3   <   #    U  H  u  p[        X5      v   M     g 7fr8   r   )r   crU   s      r3   r   r   {  s     H*G$!CII*Gs   )r-   sumzipr   )
rU   aimi
coeffs_domr   coeffs_sympyres
algebraicsmatrixtoexprs
          r3   	converter"_make_converter.<locals>.converterv  sw    YY[2GMNvc<B<<v
N+56:aq	:6H#lJ*GHI
 O6s   %A6A;)"r"   as_exprr'   r_   r\   is_Addr   r%   degree sympy.polys.numberfields.minpolyr#   r   as_coefficients_dictitemsr   r   r   dictr(   ringmonomial_basis	from_dictr.   remappendxreplaceexpandr   	make_argssetunionr   r   Zero)Kr"   todomr   powersr#   r)   coeffssymssym2genRimonomsmr   ext_dictext_polysgminpolys
ext_poly_nr   termsrU   r   r   r   r   r   s                             @@@r3   r[   r[   <  s    %%--/CEEEUU^^F::"'"78"7Qq&"78 	= C446<<>?CI;'U3s4' EE$K49!''NCNq&&''*NC,/,?@,?DAAuQxK,?@66##H-<CMMOLODAqALLA/OL %%"q!%%,,.)A *x/44X>JMM*% * :@@A!))+&&w/@ #))&Qahhj&F) NTTVTC#--2BCCVETe$J@JK
161uQUU1aff%&6
KF k 9& D@L A * U6KsB    L$L	L%L)LL'0L$5
L.?0L)/L.)L.N)r   sympy.core.addr   sympy.core.mulr   sympy.core.singletonr   sympy.core.symbolr   r   &sympy.polys.domains.characteristiczeror	   sympy.polys.domains.fieldr
    sympy.polys.domains.simpledomainr   sympy.polys.polyclassesr   sympy.polys.polyerrorsr   r   r   r   sympy.utilitiesr   r   r[   r   r6   r3   <module>r'     sV    7   " , E + 9 ' _ _ "iGU. iG iGXBr6   