+
    i                     D    R t ^ RIHtHt R tR tR tR tR tR t	R t
R	# )
zCImplementation of matrix FGLM Groebner basis conversion algorithm. )monomial_mulmonomial_divc           	     8  aaaaaa VP                   oVP                  pVP                  SR7      p\        W4      p\	        WPV4      pVP
                  .oSP                  .SP                  .\        V4      ^,
          ,          ,           .p. p\        V4       U	u. uF  q^ 3NK  	  p
p	V
P                  VV3R lRR7       V
P                  4       p\        \        V4      S4      p \        S4      p\        Wk^ ,          ,          W{^,          ,          4      p\        W4      o\        ;QJ d3    VV3R l\        V\        V4      4       4       F  '       d   K   RM(	  RM$! VV3R l\        V\        V4      4       4       4      '       d   VP                  \!        SV^,          ,          V^ ,          4      SP                  4      pTP#                  \        V4       U	u/ uF  p	SV	,          SV	,          bK  	  up	4      pVV,
          P%                  V4      pV'       d   VP'                  V4       M\)        VSV4      pSP'                  \!        SV^,          ,          V^ ,          4      4       VP'                  V4       T
P+                  \        V4       U	u. uF  qV3NK  	  up	4       \-        \/        V
4      4      p
V
P                  VV3R lRR7       V
 UaUau. uFP  w  oo\        ;QJ d!    VVV3R lV 4       F  '       d   K   RM	  RM! VVV3R lV 4       4      '       g   KL  SS3NKR  	  p
ppV
'       g2   V Uu. uF  pVP1                  4       NK  	  pp\3        VV3R	 lRR7      # V
P                  4       pEK  u up	i u up	i u up	i u uppi u upi )
a6  
Converts the reduced Groebner basis ``F`` of a zero-dimensional
ideal w.r.t. ``O_from`` to a reduced Groebner basis
w.r.t. ``O_to``.

References
==========

.. [1] J.C. Faugere, P. Gianni, D. Lazard, T. Mora (1994). Efficient
       Computation of Zero-dimensional Groebner Bases by Change of
       Ordering
)orderc                 R   < S! \        SV ^,          ,          V ^ ,          4      4      #    _incr_kk_lO_toSs   &u/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/polys/fglmtools.py<lambda>matrix_fglm.<locals>.<lambda>!   s    4#a&	3q6 :;    Tkeyreversec              3   P   <"   T F  pSV,          SP                   8H  x  K  	  R # 5iN)zero).0i_lambdadomains   & r   	<genexpr>matrix_fglm.<locals>.<genexpr>+   s      K2JQwqzV[[(2Js   #&Fc                 R   < S! \        SV ^,          ,          V ^ ,          4      4      # r   r	   r   s   &r   r   r   ;   s    4#a&	3q6(B#Cr   c              3   v   <"   T F.  p\        \        SS,          S4      VP                  4      R J x  K0  	  R # 5ir   )r   r
   LM)r   gr   kls   & r   r   r   =   s0     *cab\]<!a8H!$$+OSW+Wabs   69c                 (   < S! V P                   4      # r   )r!   )r"   r   s   &r   r   r   A   s    4:r   )r   ngensclone_basis_representing_matrices
zero_monomoner   lenrangesortpop_identity_matrix_matrix_mulallterm_newr
   	from_dictset_ringappend_updateextendlistsetmonicsorted)Fringr   r&   ring_to	old_basisMVGr   LtPsvltrestr"   r#   r$   r   r   r   s   &&f               ``@@@r   matrix_fglmrK      s    [[FJJEjjtj$GqIyT2A 
A
**Y!);<	<=A
Au&AQA&FF;TFJ	AY0A
FA$Q4)a#3K%3y>2JK333K%3y>2JKKKwq1w!5vzzBB>>U1X"FX1Q4#3X"FGDd$$W-A 7A&AHHWQqtWad+,HHQKHHeEl3l!fl34SVAFFCTFR"#d!Ass*cab*csss*cab*c'cVaV!d%&(Q!'')QA(!!5tDDEEGG 	' #G 4 e )s0   NNNN0N	N+NNc                     \        \        V R V 4      W,          ^,           .,           \        W^,           R  4      ,           4      # r   )tupler9   )mr#   s   &&r   r
   r
   F   s5    aeqz)Dq56O;<<r   c                     \        V 4       Uu. uF  q!P                  .V ,          NK  	  pp\        V 4       F  pVP                  W4,          V&   K  	  V# u upi r   )r-   r   r+   )nr   _rA   r   s   &&   r   r0   r0   J   sM    "'(+(Q++q(A+1X**Q  H 	,s   Ac                    aa V  Uau. uF+  o\        VV3R  l\        \        S4      4       4       4      NK-  	  up# u upi )c              3   R   <"   T F  pSV,          SV,          ,          x  K  	  R # 5ir    )r   r   rowrH   s   & r   r   _matrix_mul.<locals>.<genexpr>T   s     5}!A1}s   $')sumr-   r,   )rA   rH   rU   s   &f`r   r1   r1   S   s.    ABC#C5uSV}55CCCs   1<c           	     <  a \        V3R l\        V \        S4      4       4       4      p\        \        S4      4       Ft  pWC8w  g   K  \        \        W$,          4      4       Uu. uFB  qRV,          V,          W#,          V,          SV,          ,          SV,          ,          ,
          NKD  	  upW$&   Kv  	  \        \        W#,          4      4       Uu. uF   qRV,          V,          SV,          ,          NK"  	  upW#&   W ,          W#,          uW#&   W &   V# u upi u upi )z=
Update ``P`` such that for the updated `P'` `P' v = e_{s}`.
c              3   H   <"   T F  pSV,          ^ 8w  g   K  Vx  K  	  R# 5i)    NrT   )r   jr   s   & r   r   _update.<locals>.<genexpr>[   s     A-!qAA-s   "
")minr-   r,   )rG   r   rF   r#   rr[   s   &f&   r   r7   r7   W   s     	AuQG-AAA3w< 6KPQTUVUYQZK[\K[aaDGqtAw3wqzAAAK[\AD ! +0AD	*:;*:QaDGgaj  *:;ADqtJAD!$H ];s   %AD&Dc                   a aaaa SP                   oSP                  ^,
          oV3R lpVV VV3R lp\        S^,           4       Uu. uF  qT! V! V4      4      NK  	  up# u upi )zb
Compute the matrices corresponding to the linear maps `m \mapsto
x_i m` for all variables `x_i`.
c                 f   < \        ^ .V ,          ^.,           ^ .SV ,
          ,          ,           4      # )rZ   )rM   )r   us   &r   var#_representing_matrices.<locals>.varo   s)    aS1Ws]aSAE]233r   c                   < \        \        S
4      4       Uu. uF   pSP                  .\        S
4      ,          NK"  	  pp\        S
4       Fn  w  r4SP	                  \        W4      SP                  4      P                  S	4      pVP                  4        F!  w  rgS
P                  V4      pWrV,          V&   K#  	  Kp  	  V# u upi r   )
r-   r,   r   	enumerater3   r   r+   remtermsindex)rN   rQ   rA   r   rH   r^   monomcoeffr[   rC   basisr   r>   s   &        r   representing_matrix3_representing_matrices.<locals>.representing_matrixr   s    16s5z1BC1BAfkk]SZ''1BCe$DAl10&**=AA!DA !	KK&!Q !* %  Ds   &B?)r   r&   r-   )rk   rC   r>   rb   rl   r   r   ra   s   fff   @@r   r)   r)   g   sV    
 [[F

1A4
 
 27q1u>AA'>>>s   A!c                H  aa	 VP                   pV  Uu. uF  q3P                  NK  	  ppVP                  .p. pV'       d   VP                  4       o	VP	                  S	4       \        VP                  4       Uau. uFS  o\        ;QJ d     VV	3R lV 4       F  '       d   K   RM	  RM! VV	3R lV 4       4      '       g   KG  \        S	S4      NKU  	  ppVP                  V4       VP                  VRR7       K  \        \        V4      4      p\        WbR7      # u upi u upi )z
Computes a list of monomials which are not divisible by the leading
monomials wrt to ``O`` of ``G``. These monomials are a basis of
`K[X_1, \ldots, X_n]/(G)`.
c              3   T   <"   T F  p\        \        SS4      V4      R J x  K  	  R # 5ir   )r   r
   )r   lmgr#   rE   s   & r   r   _basis.<locals>.<genexpr>   s*      *(  1s3t;(s   %(FTr   )r   )r   r!   r*   r/   r6   r-   r&   r2   r
   r8   r.   r9   r:   r<   )
rC   r>   r   r"   leading_monomials
candidatesrk   r#   new_candidatesrE   s
   &&     ` @r   r(   r(      s     JJE'()q!q)//"JE
NNQ16tzz1B +1BAs *(*sss *(* * ('!Q-1B + 	.)E40UE%##! *+s   D9D	D!DDN)__doc__sympy.polys.monomialsr   r   rK   r
   r0   r1   r7   r)   r(   rT   r   r   <module>rw      s2    I ==@=D ?4$r   