Ë
    W¨œj©	  ã                   ój   — d Z ddlmZmZ ddlmZ ddlZddlm	Z	 dd„ fd	„Z
d
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)zDThis submodule contains tools for working with numpy.poly1d objects.é    )ÚdivisionÚabsolute_import)ÚcombinationsNé   )ÚiscloseFc                  ó   — y)NT© )Úrs    úg/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/svgpathtools/polytools.pyÚ<lambda>r      s   € °dó    c                 ó¦  — t        j                  | «      }|r0|D �cg c]%  }t        |j                  d«      sŒ|j                  ‘Œ' }}|D �cg c]  } ||«      sŒ|‘Œ }}g }t        t        |d«      «      D ]&  \  }\  }}t        ||«      sŒ|j                  |«       Œ( t        |«      D ��cg c]  \  }}||vsŒ|‘Œ c}}S c c}w c c}w c c}}w )a{  
    Returns the roots of a polynomial with coefficients given in p.
      p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
    INPUT:
    p - Rank-1 array-like object of polynomial coefficients.
    realroots - a boolean.  If true, only real roots will be returned  and the
        condition function can be written assuming all roots are real.
    condition - a boolean-valued function.  Only roots satisfying this will be
        returned.  If realroots==True, these conditions should assume the roots
        are real.
    OUTPUT:
    A list containing the roots of the polynomial.
    NOTE:  This uses np.isclose and np.rootsr   é   )ÚnpÚrootsr   ÚimagÚrealÚ	enumerater   Úappend)	ÚpÚ	realrootsÚ	conditionr   r
   Ú
duplicatesÚidxÚr1Úr2s	            r   Ú	polyrootsr      sÄ   € ô �H‰H�Q‹K€EÙÙ!&Ó=¡˜A¬'°!·&±&¸!Õ*<�—“ ˆÐ=ÙÓ.™�1¡¨1¥ŠQ˜€EÐ.à€JÜ"¤<°°qÓ#9Ö:‰ˆ‰Xˆb�"Ü�2�r�?Ø×Ñ˜cÕ"ð ;ô & eÔ,ÔFÑ,‘&�#�q°¸:Ò0EŠAÐ,ÒFÐFùò >ùÚ.ùó Gs"   œC¸CÁCÁCÂ.CÂ;Cc                 ó    — t        | dd„ ¬«      S )záReturns the real roots between 0 and 1 of the polynomial with
    coefficients given in p,
      p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
    p can also be a np.poly1d object.  See polyroots for more information.Tc                 ó"   — d| cxk  xr dk  S c S )Nr   r   r	   )Útvals    r   r   zpolyroots01.<locals>.<lambda>+   s   € ¸qÀD¾~ÈA½~r   )r   r   )r   )r   s    r   Úpolyroots01r!   &   s   € ô
 �Q $Ñ2MÔNÐNr   c                 óZ  — t        | t        j                  «      rt        |t        j                  «      sJ ‚|t        j                  dg«      k7  sJ ‚ ||«      dk7  r | |«       ||«      z  S  | |«      dk(  r)t        | j	                  «       |j	                  «       |«      S t        d«      ‚)zLComputes the limit of the rational function (f/g)(t)
    as t approaches t0.r   zLimit does not exist.)Ú
isinstancer   Úpoly1dÚrational_limitÚderivÚ
ValueError)ÚfÚgÚt0s      r   r%   r%   .   sŒ   € ô �aœŸ™Ô#¬
°1´b·i±iÔ(@Ð@Ð@Ø”—	‘	˜1˜#“ÒÐÐÙˆƒu�‚zÙ�‹u‘Q�r“U‰{ÐÙ	
ˆ2‹�!ŠÜ˜aŸg™g›i¨¯©«°BÓ7Ð7äÐ0Ó1Ð1r   c                 óŒ   — 	 t        j                  | j                  j                  «      S # t        $ r | j                  cY S w xY w©N)r   r$   Úcoeffsr   ÚAttributeError©Úzs    r   r   r   ;   ó6   € ðÜ�y‰y˜Ÿ™Ÿ™Ó'Ð'øÜò Ø�v‰vŠðúó   ‚(+ «AÁAc                 óŒ   — 	 t        j                  | j                  j                  «      S # t        $ r | j                  cY S w xY wr,   )r   r$   r-   r   r.   r/   s    r   r   r   B   r1   r2   c                 óT   — t        j                  | j                  j                  «      S ©zDeprecated.)r   r$   r-   r   ©Úpolys    r   Úpoly_real_partr8   I   ó   € ä�9‰9�T—[‘[×%Ñ%Ó&Ð&r   c                 óT   — t        j                  | j                  j                  «      S r5   )r   r$   r-   r   r6   s    r   Úpoly_imag_partr;   N   r9   r   )Ú__doc__Ú
__future__r   r   Ú	itertoolsr   Únumpyr   Ú	misctoolsr   r   r!   r%   r   r   r8   r;   r	   r   r   Ú<module>rA      sD   ðÙ J÷ 1Ý "Û õ ð !©Nó Gò4Oò
2òòò'ó
'r   