+
    0åûj°]  ã                   ó  € R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHt ^ RIHt ^R	IHtHt ^R
IHt ^RIHtHt ^RIHtHt R t ! R R]4      tR t]R 4       tRR lt R t!R t"R t#R t$]RR l4       t%R# )zPrime ideals in number fields. )ÚPoly)ÚFF)ÚQQ)ÚZZ)ÚDomainMatrix)ÚCoercionFailed)ÚIntegerPowerable)Úpublic)Ú	round_twoÚnilradical_mod_p)ÚStructureError)ÚModuleEndomorphismÚfind_min_poly)Úcoeff_searchÚsupplement_a_subspacec                óÌ   € RpRpV P                  4       '       g   RpM1V P                  4       '       g   RpMV P                  4       '       g   RpVe   \        W,           4      hR# )aä  
Several functions in this module accept an argument which is to be a
:py:class:`~.Submodule` representing the maximal order in a number field,
such as returned by the :py:func:`~sympy.polys.numberfields.basis.round_two`
algorithm.

We do not attempt to check that the given ``Submodule`` actually represents
a maximal order, but we do check a basic set of formal conditions that the
``Submodule`` must satisfy, at a minimum. The purpose is to catch an
obviously ill-formed argument.
z4The submodule representing the maximal order should Nz'be a direct submodule of a power basis.zhave 1 as its first generator.z<have square matrix, of maximal rank, in Hermite Normal Form.)Úis_power_basis_submoduleÚstarts_with_unityÚis_sq_maxrank_HNFr   )Ú	submoduleÚprefixÚconds   &  Ú[C:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\sympy\polys\numberfields\primes.pyÚ*_check_formal_conditions_for_maximal_orderr      sc   € ð D€FØ€DØ×-Ñ-×/Ò/Ø8‰Ø×(Ñ(×*Ò*Ø/‰Ø×(Ñ(×*Ò*ØMˆØÒÜ˜V�]Ó+Ð+ñ ó    c                   óž   a € ] tR t^)t o RtRR ltR t]R 4       tRR lt	R t
R tR	 tR
 t]tR t]tR tR tR tR tR tR tR tRtV tR# )Ú
PrimeIdealz0
A prime ideal in a ring of algebraic integers.
Nc                óª   € \        V4       Wn        W n        W0n        W@n        RV n        Ve	   WPn        R# V P                  W!,          4      V n        R# )aŒ  
Parameters
==========

ZK : :py:class:`~.Submodule`
    The maximal order where this ideal lives.
p : int
    The rational prime this ideal divides.
alpha : :py:class:`~.PowerBasisElement`
    Such that the ideal is equal to ``p*ZK + alpha*ZK``.
f : int
    The inertia degree.
e : int, ``None``, optional
    The ramification index, if already known. If ``None``, we will
    compute it here.

N)r   ÚZKÚpÚalphaÚfÚ_test_factorÚ	valuationÚe)Úselfr   r   r    r!   r$   s   &&&&&&r   Ú__init__ÚPrimeIdeal.__init__.   sB   € ô$ 	3°2Ô6ØŒØŒØŒ
ØŒØ ˆÔØ’m�Ž¨¯©¸½Ó)?ˆŽr   c                óœ   € V P                   '       d   R V P                   R2# R V P                   RV P                  P                  4        R2# )Ú(Ú)ú, )Úis_inertr   r    Úas_expr©r%   s   &r   Ú__str__ÚPrimeIdeal.__str__H   sD   € Ø�=�=ˆ=Ø�t—v‘v�h˜a�=Ð Ø�4—6‘6�(˜"˜TŸZ™Z×/Ñ/Ó1Ð2°!Ð4Ð4r   c                óH   € V P                   V P                  P                  8H  # )z^
Say whether the rational prime we divide is inert, i.e. stays prime in
our ring of integers.
)r!   r   Únr.   s   &r   r,   ÚPrimeIdeal.is_inertM   s   € ð �v‰v˜Ÿ™Ÿ™Ñ"Ð"r   c                ó¢  € T;'       g+    V P                   P                  P                  P                  pV P                  V P
                  V P                  V P                  3w  r4rV\        VP                  VR7      P                  4       4      pVP                  ^8”  d   RV RVP                   2pRV RV R2pV'       d   V# RV RV RV R	2# )
a2  
Print a representation of this prime ideal.

Examples
========

>>> from sympy import cyclotomic_poly, QQ
>>> from sympy.abc import x, zeta
>>> T = cyclotomic_poly(7, x)
>>> K = QQ.algebraic_field((T, zeta))
>>> P = K.primes_above(11)
>>> print(P[0].repr())
[ (11, x**3 + 5*x**2 + 4*x - 1) e=1, f=3 ]
>>> print(P[0].repr(field_gen=zeta))
[ (11, zeta**3 + 5*zeta**2 + 4*zeta - 1) e=1, f=3 ]
>>> print(P[0].repr(field_gen=zeta, just_gens=True))
(11, zeta**3 + 5*zeta**2 + 4*zeta - 1)

Parameters
==========

field_gen : :py:class:`~.Symbol`, ``None``, optional (default=None)
    The symbol to use for the generator of the field. This will appear
    in our representation of ``self.alpha``. If ``None``, we use the
    variable of the defining polynomial of ``self.ZK``.
just_gens : bool, optional (default=False)
    If ``True``, just print the "(p, alpha)" part, showing "just the
    generators" of the prime ideal. Otherwise, print a string of the
    form "[ (p, alpha) e=..., f=... ]", giving the ramification index
    and inertia degree, along with the generators.

)Úxr)   z)/r+   r*   z[ z e=z, f=z ])r   ÚparentÚTÚgenr   r    r$   r!   ÚstrÚ	numeratorr-   Údenom)	r%   Ú	field_genÚ	just_gensr   r    r$   r!   Ú	alpha_repÚgenss	   &&&      r   ÚreprÚPrimeIdeal.reprU   s¾   € ðB ×5Ð5 §¡§¡×!1Ñ!1×!5Ñ!5ˆ	ØŸ™ §¡¨T¯V©V°T·V±VÐ;‰ˆ�!Ü˜Ÿ™¨)˜Ó4×<Ñ<Ó>Ó?ˆ	Ø�;‰;˜Œ?Ø˜I˜; b¨¯©¨Ð6ˆIØ�1�#�R˜	�{ !Ð$ˆßØˆKØ�D�6˜˜Q˜C˜t A 3 bÐ)Ð)r   c                ó"   € V P                  4       # ©N)r@   r.   s   &r   Ú__repr__ÚPrimeIdeal.__repr__€   s   € Ø�y‰y‹{Ðr   c                ó    € V P                   V P                  ,          V P                  V P                  ,          ,           pRVn        RVn        V# )a·  
Represent this prime ideal as a :py:class:`~.Submodule`.

Explanation
===========

The :py:class:`~.PrimeIdeal` class serves to bundle information about
a prime ideal, such as its inertia degree, ramification index, and
two-generator representation, as well as to offer helpful methods like
:py:meth:`~.PrimeIdeal.valuation` and
:py:meth:`~.PrimeIdeal.test_factor`.

However, in order to be added and multiplied by other ideals or
rational numbers, it must first be converted into a
:py:class:`~.Submodule`, which is a class that supports these
operations.

In many cases, the user need not perform this conversion deliberately,
since it is automatically performed by the arithmetic operator methods
:py:meth:`~.PrimeIdeal.__add__` and :py:meth:`~.PrimeIdeal.__mul__`.

Raising a :py:class:`~.PrimeIdeal` to a non-negative integer power is
also supported.

Examples
========

>>> from sympy import Poly, cyclotomic_poly, prime_decomp
>>> T = Poly(cyclotomic_poly(7))
>>> P0 = prime_decomp(7, T)[0]
>>> print(P0**6 == 7*P0.ZK)
True

Note that, on both sides of the equation above, we had a
:py:class:`~.Submodule`. In the next equation we recall that adding
ideals yields their GCD. This time, we need a deliberate conversion
to :py:class:`~.Submodule` on the right:

>>> print(P0 + 7*P0.ZK == P0.as_submodule())
True

Returns
=======

:py:class:`~.Submodule`
    Will be equal to ``self.p * self.ZK + self.alpha * self.ZK``.

See Also
========

__add__
__mul__

FT)r   r   r    Ú_starts_with_unityÚ_is_sq_maxrank_HNF)r%   ÚMs   & r   Úas_submoduleÚPrimeIdeal.as_submoduleƒ   s>   € ðn �F‰F�T—W‘WÕ˜tŸz™z¨D¯G©GÕ3Õ3ˆà$ˆÔØ#ˆÔØˆr   c                ó|   € \        V\        4      '       d"   V P                  4       VP                  4       8H  # \        # rC   )Ú
isinstancer   rJ   ÚNotImplemented©r%   Úothers   &&r   Ú__eq__ÚPrimeIdeal.__eq__À   s2   € Ü�eœZ×(Ò(Ø×$Ñ$Ó&¨%×*<Ñ*<Ó*>Ñ>Ð>ÜÐr   c                ó0   € V P                  4       V,           # )zt
Convert to a :py:class:`~.Submodule` and add to another
:py:class:`~.Submodule`.

See Also
========

as_submodule

©rJ   rO   s   &&r   Ú__add__ÚPrimeIdeal.__add__Å   ó   € ð × Ñ Ó" UÕ*Ð*r   c                ó0   € V P                  4       V,          # )zŽ
Convert to a :py:class:`~.Submodule` and multiply by another
:py:class:`~.Submodule` or a rational number.

See Also
========

as_submodule

rT   rO   s   &&r   Ú__mul__ÚPrimeIdeal.__mul__Ô   rW   r   c                ó   € V P                   # rC   )r   r.   s   &r   Ú_zeroth_powerÚPrimeIdeal._zeroth_powerã   s   € Ø�w‰wˆr   c                ó   € V # rC   © r.   s   &r   Ú_first_powerÚPrimeIdeal._first_poweræ   s   € Øˆr   c                ó˜   € V P                   f2   \        V P                  V P                  .V P                  4      V n         V P                   # )a÷  
Compute a test factor for this prime ideal.

Explanation
===========

Write $\mathfrak{p}$ for this prime ideal, $p$ for the rational prime
it divides. Then, for computing $\mathfrak{p}$-adic valuations it is
useful to have a number $\beta \in \mathbb{Z}_K$ such that
$p/\mathfrak{p} = p \mathbb{Z}_K + \beta \mathbb{Z}_K$.

Essentially, this is the same as the number $\Psi$ (or the "reagent")
from Kummer's 1847 paper (*Ueber die Zerlegung...*, Crelle vol. 35) in
which ideal divisors were invented.
)r"   Ú_compute_test_factorr   r    r   r.   s   &r   Útest_factorÚPrimeIdeal.test_factoré   s;   € ð  ×ÑÒ$Ü 4°T·V±V¸d¿j¹j¸\È4Ï7É7Ó SˆDÔØ× Ñ Ð r   c                ó   € \        W4      # )z­
Compute the $\mathfrak{p}$-adic valuation of integral ideal I at this
prime ideal.

Parameters
==========

I : :py:class:`~.Submodule`

See Also
========

prime_valuation

)Úprime_valuation)r%   ÚIs   &&r   r#   ÚPrimeIdeal.valuationý   s   € ô  ˜qÓ'Ð'r   c                ó@   € V P                  4       P                  V4      # )aP  
Reduce a :py:class:`~.PowerBasisElement` to a "small representative"
modulo this prime ideal.

Parameters
==========

elt : :py:class:`~.PowerBasisElement`
    The element to be reduced.

Returns
=======

:py:class:`~.PowerBasisElement`
    The reduced element.

See Also
========

reduce_ANP
reduce_alg_num
.Submodule.reduce_element

)rJ   Úreduce_element)r%   Úelts   &&r   rk   ÚPrimeIdeal.reduce_element  s   € ð2 × Ñ Ó"×1Ñ1°#Ó6Ð6r   c                óŽ   € V P                   P                  P                  V4      pV P                  V4      pVP	                  4       # )a+  
Reduce an :py:class:`~.ANP` to a "small representative" modulo this
prime ideal.

Parameters
==========

elt : :py:class:`~.ANP`
    The element to be reduced.

Returns
=======

:py:class:`~.ANP`
    The reduced element.

See Also
========

reduce_element
reduce_alg_num
.Submodule.reduce_element

)r   r6   Úelement_from_ANPrk   Úto_ANP©r%   Úarl   Úreds   &&  r   Ú
reduce_ANPÚPrimeIdeal.reduce_ANP*  s8   € ð2 �g‰g�n‰n×-Ñ-¨aÓ0ˆØ×!Ñ! #Ó&ˆØ�z‰z‹|Ðr   c                óä   € V P                   P                  P                  V4      pV P                  V4      pVP	                  \        \        VP                  P                  4       4      4      4      # )aK  
Reduce an :py:class:`~.AlgebraicNumber` to a "small representative"
modulo this prime ideal.

Parameters
==========

elt : :py:class:`~.AlgebraicNumber`
    The element to be reduced.

Returns
=======

:py:class:`~.AlgebraicNumber`
    The reduced element.

See Also
========

reduce_element
reduce_ANP
.Submodule.reduce_element

)	r   r6   Úelement_from_alg_numrk   Úfield_elementÚlistÚreversedÚQQ_colÚflatrq   s   &&  r   Úreduce_alg_numÚPrimeIdeal.reduce_alg_numG  sP   € ð2 �g‰g�n‰n×1Ñ1°!Ó4ˆØ×!Ñ! #Ó&ˆØ�‰œt¤H¨S¯Z©Z¯_©_Ó->Ó$?Ó@ÓAÐAr   )r   r"   r    r$   r!   r   rC   )NF)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r&   r/   Úpropertyr,   r@   rD   rJ   rQ   rU   Ú__radd__rY   Ú__rmul__r\   r`   rd   r#   rk   rt   r}   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r   r   )   s�   ø‡ € ñô@ò45ð
 ñ#ó ð#ô)*òVò;òzò
+ð €Hò+ð €Hòòò!ò((ò$7ò6÷:Bð Br   r   c                óä  € \        V4       VP                  4       pV Uu. uF#  qCP                  V4      P                  V R7      NK%  	  pp\        P
                  ! ^ VP                  3\        V 4      4      P                  ! V!  pVP                  4       R,          P                  4       pVP                  VP                  VP                  \        4      ,          VP                  R7      pV# u upi )a‘  
Compute the test factor for a :py:class:`~.PrimeIdeal` $\mathfrak{p}$.

Parameters
==========

p : int
    The rational prime $\mathfrak{p}$ divides

gens : list of :py:class:`PowerBasisElement`
    A complete set of generators for $\mathfrak{p}$ over *ZK*, EXCEPT that
    an element equivalent to rational *p* can and should be omitted (since
    it has no effect except to waste time).

ZK : :py:class:`~.Submodule`
    The maximal order where the prime ideal $\mathfrak{p}$ lives.

Returns
=======

:py:class:`~.PowerBasisElement`

References
==========

.. [1] Cohen, H. *A Course in Computational Algebraic Number Theory.*
(See Proposition 4.8.15.)

©Úmodulus©r;   )é    ºNNN)r   Úendomorphism_ringÚinner_endomorphismÚmatrixr   Úzerosr2   r   ÚvstackÚ	nullspaceÚ	transposer6   Ú
convert_tor   r;   )	r   r?   r   ÚEÚgÚmatricesÚBr5   Úbetas	   &&&      r   rc   rc   e  s¼   € ô< /¨rÔ2Ø
×ÑÓ€AÙCGÓHÁ4¸a×$Ñ$ QÓ'×.Ñ.°qÐ.Ö9Á4€HÐHÜ×Ò˜A˜rŸt™t˜9¤b¨£eÓ,×3Ò3°XÑ>€Að 	
�‰‹�dÕ×%Ñ%Ó'€AØ�9‰9�R—Y‘Y §¡¬bÓ!1Õ1¸¿¹ˆ9ÓB€DØ€Kùò Is    )C-c                óö  € VP                   VP                  r2VP                  VP                  VP                  repVP                  \        4      P                  4       V P                  ,          V,          V P                  ,          pVP                  \        4      pVP                  4       pW‚,          ^ 8w  d   ^ # VP                  4       p	Wd,          VP                  4       ,          p
W¢,          ^ 8H  p^ p WW,          p\        V4       Fd  pVP                  VRV3,          VR7      pWé,          pVP                  V4      P                  4       p\        V4       F  pWï,          WV3&   K  	  Kf  	  Wt^,
          V^,
          3,          P                  V,          ^ 8w  d    V# Wr,          pV'       d    VP                  \        4      pMVP                  \        4      pV^,          pKô    \          d     T# i ; i)aŽ  
Compute the *P*-adic valuation for an integral ideal *I*.

Examples
========

>>> from sympy import QQ
>>> from sympy.polys.numberfields import prime_valuation
>>> K = QQ.cyclotomic_field(5)
>>> P = K.primes_above(5)
>>> ZK = K.maximal_order()
>>> print(prime_valuation(25*ZK, P[0]))
8

Parameters
==========

I : :py:class:`~.Submodule`
    An integral ideal whose valuation is desired.

P : :py:class:`~.PrimeIdeal`
    The prime at which to compute the valuation.

Returns
=======

int

See Also
========

.PrimeIdeal.valuation

References
==========

.. [1] Cohen, H. *A Course in Computational Algebraic Number Theory.*
   (See Algorithm 4.8.17.)

r�   r�   )r   r   r2   r’   r;   r—   r   Úinvr   Údetrd   Úranger6   Ú	representr|   Úelementr   )rh   ÚPr   r   r2   ÚWÚdÚAÚDrœ   r!   Úneed_complete_testÚvÚjÚcÚis   &&              r   rg   rg   “  sœ  € ðT �C‰C�—‘€rØ�d‰d�B—I‘I˜rŸx™xˆ!€Aà	�‰”RÓ×ÑÓ §¡Õ)¨AÕ-°·±Õ7€Að 	
�‰”RÓ€AØ	�‰‹€AØ…u�„zÙà�=‰=‹?€Dà	��!—%‘%“'Õ€AØ�% 1™*ÐØ	€AØ
ð �Eˆä�q–ˆAØ—	‘	˜!˜A˜q˜D�'¨�	Ó+ˆAØ�IˆAà—‘˜Q“×$Ñ$Ó&ˆAÜ˜1–X�Ø�$��Q�$“ó ñ ð ��U�A˜•Eˆ\�?×"Ñ" QÕ&¨!Ô+Øð €Hð �Eˆ÷ ðØ—L‘L¤Ó$‘ð
 —‘œRÓ ˆAØ	ˆQ�Šøô "ô Øð
 €Hðús   Æ3G) Ç)G8Ç7G8Nc                óÂ  a€ \        V4       VP                  pVP                  p\        ;QJ d    V3R lV  4       F  '       d   K   RM	  RM! V3R lV  4       4      '       d   VP	                  4       # VfA   Ve   SV,          pM2\        VP                  V 4      P                  P                  4       4      pVP                  4       pVR,           Uu. uF  pSV,          NK  	  p	pW�,          p	\        \        V	4      ^4      p
V
 FO  p\        R \        W¹4       4       4      pVP                  V4      V,          pVS,          ^ 8w  g   KF  VS,          u # 	  R# u upi )a  
Given a set of *ZK*-generators of a prime ideal, compute a set of just two
*ZK*-generators for the same ideal, one of which is *p* itself.

Parameters
==========

gens : list of :py:class:`PowerBasisElement`
    Generators for the prime ideal over *ZK*, the ring of integers of the
    field $K$.

ZK : :py:class:`~.Submodule`
    The maximal order in $K$.

p : int
    The rational prime divided by the prime ideal.

f : int, optional
    The inertia degree of the prime ideal, if known.

Np : int, optional
    The norm $p^f$ of the prime ideal, if known.
    NOTE: There is no reason to supply both *f* and *Np*. Either one will
    save us from having to compute the norm *Np* ourselves. If both are known,
    *Np* is preferred since it saves one exponentiation.

Returns
=======

:py:class:`~.PowerBasisElement` representing a single algebraic integer
alpha such that the prime ideal is equal to ``p*ZK + alpha*ZK``.

References
==========

.. [1] Cohen, H. *A Course in Computational Algebraic Number Theory.*
(See Algorithm 4.7.10.)

c              3   óR   <"  € T F  qS,          P                  ^ 4      x € K  	  R# 5i)rŽ   N)Úequiv)Ú.0r™   r   s   & €r   Ú	<genexpr>Ú_two_elt_rep.<locals>.<genexpr>  s   øé € Ð
*¡T ��E�=‰=˜×Ð£Tùó   ƒ$'FTN:é   NNc              3   ó6   "  € T F  w  rW,          x € K  	  R # 5irC   r_   )r°   ÚciÚbetais   &  r   r±   r²   '  s   é € Ð;©l¡ �B—H’H«lùs   ‚)r   r6   r7   ÚallÚzeroÚabsÚsubmodule_from_gensr’   rŸ   Úbasis_element_pullbacksr   ÚlenÚsumÚzipÚnorm)r?   r   r   r!   ÚNpÚpbr7   ÚomegaÚomrœ   Úsearchr«   r    r2   s   &&f&&         r   Ú_two_elt_reprÆ   ì  s  ø€ ôP /¨rÔ2Ø	�‰€BØ
�‰€A÷ ƒsÔ
*¡TÓ
*‡s‡s‚sÔ
*¡TÓ
*×*Ò*Ø�w‰w‹yÐà	‚zØŠ=Ø�A•‰Bä�R×+Ñ+¨DÓ1×8Ñ8×<Ñ<Ó>Ó?ˆBà×&Ñ&Ó(€EØ  ž9Ó%™9�RˆAˆb�DˆD™9€DÐ%Ø…L€DÜœ#˜d›) QÓ'€FÛˆÜÑ;¬c°!¬lÓ;Ó;ˆð �J‰J�q‹M˜RÕˆØˆq�5�AŽ:à˜1•9Òó ùò &s   ÃEc                óÒ  € VP                   P                  p\        W R7      pVP                  4       w  rE\	        V4      ^8X  dG   V^ ,          ^,          ^8X  d2   \        WVP                   P                  4       VP                  ^4      .# V UUu. uFI  w  rg\        WVP                   P                  \        V\        R7      4      VP                  4       V4      NKK  	  upp# u uppi )a'  
Compute the decomposition of rational prime *p* in the ring of integers
*ZK* (given as a :py:class:`~.Submodule`), in the "easy case", i.e. the
case where *p* does not divide the index of $\theta$ in *ZK*, where
$\theta$ is the generator of the ``PowerBasis`` of which *ZK* is a
``Submodule``.
r‹   ©Údomain)r6   r7   r   Úfactor_listr½   r   r¹   r2   Úelement_from_polyr   Údegree)r   r   r7   ÚT_barÚlcÚflÚtr$   s   &&      r   Ú_prime_decomp_easy_caserÑ   1  s¿   € ð 	�	‰	�‰€AÜ�Ô€EØ×ÑÓ �F€BÜ
ˆ2ƒw�!„|˜˜1�˜a� AœÜ˜2 "§)¡)§.¡.Ó"2°B·D±D¸!Ó<Ð=Ð=ñ ôñ ‘�ô �rØ—y‘y×2Ñ2´4¸Ä"Ô3EÓFØ—x‘x“z 1ö&ñ òð ùó s   ÂAC#c                óF  a€ V P                   pVP                  w  rEV^ 8X  d   VP                  V\        4      pM,VP	                  VP                  V\        4      R,          4      pVP                  ^,          V8  d7   \        VP                  \        S4      4      4      P                  \        4      pVP                  V4      pVP                  4        VP                  V4      p\        VV3R l4      pVP                  SR7      p	V	P                  4       '       g   Q hW—3# )aç  
Parameters
==========

I : :py:class:`~.Module`
    An ideal of ``ZK/pZK``.
p : int
    The rational prime being factored.
ZK : :py:class:`~.Submodule`
    The maximal order.

Returns
=======

Pair ``(N, G)``, where:

    ``N`` is a :py:class:`~.Module` representing the kernel of the map
    ``a |--> a**p - a`` on ``(O/pO)/I``, guaranteed to be a module with
    unity.

    ``G`` is a :py:class:`~.Module` representing a basis for the separable
    algebra ``A = O/I`` (see Cohen).

c                 ó$   <€ V S,          V ,
          # rC   r_   )r5   r   s   &€r   Ú<lambda>Ú._prime_decomp_compute_kernel.<locals>.<lambda>s  s   ø€ ¨!¨Q­$°®(r   r‹   )r�   rŽ   )r’   ÚshapeÚeyer   Úhstackr   r—   r   Úsubmodule_from_matrixÚcompute_mult_tabÚdiscard_beforer   Úkernelr   )
rh   r   r   r¤   r2   Úrr›   ÚGÚphiÚNs
   &f&       r   Ú_prime_decomp_compute_kernelrá   D  sæ   ø€ ð2 	
�‰€AØ�7‰7�D€Að 	ˆA„vØ�E‰E�!”R‹L‰à�H‰H�Q—U‘U˜1œb“\ $Õ'Ó(ˆØ‡w�wˆq…z�A„~Ü! !§,¡,¬r°!«uÓ"5Ó6×AÑAÄ"ÓEˆà
× Ñ  Ó#€Að
 ×ÑÔØ	×Ñ˜Ó€Aä
˜QÔ 2Ó
3€CØ�
‰
˜1ˆ
Ó€AØ×Ñ× Ò Ð Ð Øˆ4€Kr   c                óT  € V P                   P                  w  r4W4,
          pVP                   V P                   ,          p\        VP                  ^,          4       Uu. uF(  qrP                  VRV3,          VP                  R7      NK*  	  pp\        W‚WR7      p	\        W!W•4      # u upi )a}  
We have reached the case where we have a maximal (hence prime) ideal *I*,
which we know because the quotient ``O/I`` is a field.

Parameters
==========

I : :py:class:`~.Module`
    An ideal of ``O/pO``.
p : int
    The rational prime being factored.
ZK : :py:class:`~.Submodule`
    The maximal order.

Returns
=======

:py:class:`~.PrimeIdeal` instance representing this prime

r�   r�   )r!   )r’   rÖ   r    r6   r;   rÆ   r   )
rh   r   r   Úmr2   r!   rÞ   rª   r?   r    s
   &&&       r   Ú_prime_decomp_maximal_idealrä   y  s…   € ð* �8‰8�>‰>�D€AØ	�€AØ
�	‰	�A—H‘HÕ€AÜ8=¸a¿g¹gÀa½jÔ8IÓJÑ8I°1�I‰I�a˜˜1˜•g R§X¡XˆIÖ.Ñ8I€DÐJÜ˜ 1Ô*€EÜ�b˜UÓ&Ð&ùò Ks   Á.B%c                óJ  aa€ V P                   V8X  d!   VP                   VJ d   VP                   VJ g   Q hV! ^4      P                  4       pVP                  VJ g   Q h. o\        V\	        V4      SR7      pVP                  4       w  rxV^ ,          ^ ,          p	VP                  V	4      p
V	P                  V
4      w  r¼pV^8X  g   Q h\        \        \        W¹,          \        R7      P                  P                  4       4      4      o\        VV3R l\        \!        S4      4       4       4      p^V,
          pWï.p. pV FÚ  pVP                  4       pVP                  VJ g   Q hV P"                  P%                  \	        V4      4      P&                  ! VP)                  4        Uu. uF%  pVV,          P+                  \	        V4      R7      NK'  	  up!  pVP-                  4       P%                  \        4      pVP/                  V4      pVP1                  V4       KÜ  	  V# u upi )zá
Perform the step in the prime decomposition algorithm where we have determined
the quotient ``ZK/I`` is _not_ a field, and we want to perform a non-trivial
factorization of *I* by locating an idempotent element of ``ZK/I``.
)ÚpowersrÈ   c              3   óR   <"  € T F  pSV,          SV,          ,          x € K  	  R # 5irC   r_   )r°   r¬   r˜   Úalpha_powerss   & €€r   r±   Ú,_prime_decomp_split_ideal.<locals>.<genexpr>°  s!   øé € Ð;©]¨ˆq��t�L •O×#Ò#«]ùr³   )r6   Ú	to_parentÚmoduler   r   rÊ   ÚquoÚgcdexry   rz   r   r   ÚrepÚto_listr¾   r    r½   r’   r—   rØ   Úbasis_elementsÚcolumnÚcolumnspacerÙ   Úappend)rh   r   rà   rÞ   r   r    rã   rÎ   rÏ   Úm1Úm2ÚUÚVr™   Úeps1Úeps2ÚidempsÚfactorsÚepsr$   rÄ   r§   r¤   ÚHr˜   rè   s   &&&&&                   @@r   Ú_prime_decomp_split_idealrþ   –  sº  ù€ ð �8‰8�rŒ>˜aŸh™h¨"›n°·±¸Q³Ð>Ð>ñ
 ˆa‹D�N‰NÓ€EØ�<‰<˜1ÓÐÐà€LÜ�eœR ›U¨<Ô8€Að �]‰]‹_�F€BØ	ˆA�ˆq�€BØ	
�‰ˆr‹€BØ�h‰h�r‹l�G€Aˆ!à�Œ6€Mˆ6ÜŒX”d˜1�6¬"Ô-×1Ñ1×9Ñ9Ó;Ó<Ó=€AÜÕ;¬U´3°q³6¬]Ó;Ó;€DØˆt�8€DØˆ\€FØ€GÛˆØ�M‰M‹OˆØ�x‰x˜2‹~Ðˆ~Ø�H‰H×Ñ¤ 1£Ó&×-Ò-Ø46×4EÑ4EÔ4Gó0
Ù4G¨bˆQ��V�O‰O¤2 a£5ˆOÖ)Ñ4Gñ0
ñ ˆð �M‰M‹O×&Ñ&¤rÓ*ˆØ×$Ñ$ QÓ'ˆØ�‰�qÖñ ð €Nùò0
s   Æ%+H 
c                óf  € Vf   Vf   \        R4      hVe   \        V4       Vf   VP                  P                  p/ pVe   Vf   \	        WR7      w  r#VP                  4       pWc,          pWp,          ^ 8w  d   \        W4      # T;'       g%    VP                  V 4      ;'       g    \        W 4      pV.p. p	V'       dr   VP                  4       p
\        W V4      w  r¼VP                  ^8X  d    \        W V4      pV	P                  V4       KV  \        W W¼V4      w  rïVP                  Wï.4       Ky  V	# )a  
Compute the decomposition of rational prime *p* in a number field.

Explanation
===========

Ordinarily this should be accessed through the
:py:meth:`~.AlgebraicField.primes_above` method of an
:py:class:`~.AlgebraicField`.

Examples
========

>>> from sympy import Poly, QQ
>>> from sympy.abc import x, theta
>>> T = Poly(x ** 3 + x ** 2 - 2 * x + 8)
>>> K = QQ.algebraic_field((T, theta))
>>> print(K.primes_above(2))
[[ (2, x**2 + 1) e=1, f=1 ], [ (2, (x**2 + 3*x + 2)/2) e=1, f=1 ],
 [ (2, (3*x**2 + 3*x)/2) e=1, f=1 ]]

Parameters
==========

p : int
    The rational prime whose decomposition is desired.

T : :py:class:`~.Poly`, optional
    Monic irreducible polynomial defining the number field $K$ in which to
    factor. NOTE: at least one of *T* or *ZK* must be provided.

ZK : :py:class:`~.Submodule`, optional
    The maximal order for $K$, if already known.
    NOTE: at least one of *T* or *ZK* must be provided.

dK : int, optional
    The discriminant of the field $K$, if already known.

radical : :py:class:`~.Submodule`, optional
    The nilradical mod *p* in the integers of $K$, if already known.

Returns
=======

List of :py:class:`~.PrimeIdeal` instances.

References
==========

.. [1] Cohen, H. *A Course in Computational Algebraic Number Theory.*
   (See Algorithm 6.2.9.)

z)At least one of T or ZK must be provided.)Úradicals)Ú
ValueErrorr   r6   r7   r
   ÚdiscriminantrÑ   Úgetr   Úpoprá   r2   rä   ró   rþ   Úextend)r   r7   r   ÚdKÚradicalr   ÚdTÚ	f_squaredÚstackÚprimesrh   rà   rÞ   r£   ÚI1ÚI2s   &&&&&           r   Úprime_decompr  À  s  € ðn 	‚y�R’ZÜÐDÓEÐEØ	‚~Ü2°2Ô6Ø‚yØ�I‰I�K‰KˆØ€HØ	‚z�R’ZÜ˜1Ô0‰ˆØ	
�‰Ó	€BØ•€IØ…}˜ÔÜ& qÓ-Ð-Ø×CÐC˜Ÿ™ a›×CÐCÔ,<¸RÓ,C€GØˆI€EØ€Fß
Ø�I‰I‹KˆÜ+¨A°"Ó5‰ˆØ�3‰3�!Œ8Ü+¨A°"Ó5ˆAØ�M‰M˜!Öä.¨q°Q¸2Ó>‰FˆBØ�L‰L˜"˜Ö"Ø€Mr   )NN)NNNN)&rƒ   Úsympy.polys.polytoolsr   Úsympy.polys.domains.finitefieldr   Ú!sympy.polys.domains.rationalfieldr   Úsympy.polys.domains.integerringr   Ú!sympy.polys.matrices.domainmatrixr   Úsympy.polys.polyerrorsr   Úsympy.polys.polyutilsr   Úsympy.utilities.decoratorr	   Úbasisr
   r   Ú
exceptionsr   Úmodulesr   r   Ú	utilitiesr   r   r   r   rc   rg   rÆ   rÑ   rá   rä   rþ   r  r_   r   r   Ú<module>r     s“   ðÙ %å &Ý .Ý 0Ý .Ý :Ý 1Ý 2Ý ,ß .Ý &ß 6ß :ò,ô0yBÐ!ô yBòx	+ð\ ñUó ðUôpBòJò&2òj'ò:'ðT óOó òOr   