+
    ‹°³j¡-  ã                   ób  € R t ^ RIHtHtHt ^ RIHt ^ RIHtH	t	 ^ RI
HtHt ^ RIHtHt ^ RIHtHt ^ RIHt RR ltRR
 ltRR lt]P                   ]n         RR ltR tR t]P                   ]n         RR ltR tR t]P                   ]n         R tRR ltRR lt ]P                   ] n         R	# )zd
Discrete Fourier Transform, Number Theoretic Transform,
Walsh Hadamard Transform, Mobius Transform
)ÚSÚSymbolÚsympify)Ú
expand_mul)ÚpiÚI)ÚsinÚcos)ÚisprimeÚprimitive_root)ÚibinÚiterable)Úas_intc           	     ó  € \        V 4      '       g   \        R4      hV  Uu. uF  p\        V4      NK  	  pp\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \	        R4      h\        V4      pV^8  d   V# VP                  4       ^,
          pWU^,
          ,          '       d   V^,          p^V,          pV\        P                  .V\        V4      ,
          ,          ,          p\        ^V4       FA  p\        \        WvRR7      RRR1,          ^4      pWx8  g   K,  WH,          WG,          uWG&   WH&   KC  	  V'       d   R	\        ,          V,          M^\        ,          V,          p	Ve   V	P                  V^,           4      p	\        V^,          4       Uu. uF5  p\        W—,          4      \        \!        W—,          4      ,          ,           NK7  	  p
p^pWµ8:  d¬   V^,          W[,          rÜ\        ^ W[4       F€  p\        V4       Fn  pWGV,           ,          \#        WGV,           V,           ,          W­V,          ,          ,          4      rþWï,           Wï,
          uWGV,           &   WGV,           V,           &   Kp  	  K‚  	  V^,          pK±  V'       dF   Ve)   V Uu. uF  pVV,          P                  V4      NK  	  upMV Uu. uF  pVV,          NK  	  uppV# u upi u upi u upi u upi )
z3Utility function for the Discrete Fourier TransformzAExpected a sequence of numeric coefficients for Fourier Transformc              3   óJ   "  € T F  qP                  \        4      x € K  	  R # 5i©N)Úhasr   )Ú.0Úxs   & ÚZ/home/luca/screen-checking/.venv/lib/python3.14/site-packages/sympy/discrete/transforms.pyÚ	<genexpr>Ú%_fourier_transform.<locals>.<genexpr>   s   é € Ð
$¡!˜Q�5‰5”�=ˆ=£!ùs   ‚!#TFz"Expected non-symbolic coefficients©ÚstrNéÿÿÿÿéþÿÿÿ)r   Ú	TypeErrorr   ÚanyÚ
ValueErrorÚlenÚ
bit_lengthr   ÚZeroÚrangeÚintr   r   Úevalfr	   r   r   r   )ÚseqÚdpsÚinverseÚargÚaÚnÚbÚiÚjÚangÚwÚhÚhfÚutÚuÚvr   s   &&&              r   Ú_fourier_transformr5      sS  € ô �C�=Š=Üð 0ó 1ð 	1ñ "%Ó%¡˜#Œ�Ž¡€AÐ%ß
ƒsÑ
$¡!Ó
$‡s‡s‚sÑ
$¡!Ó
$×$Ò$ÜÐ=Ó>Ð>äˆA‹€AØˆ1„uØˆà	�‰‹˜Õ€AØˆa�%‡y„yØ	ˆQ�ˆØˆq�DˆàŒ!�&‰&ˆ�1”s˜1“v•:Õ	Õ€AÜ�1�aŽ[ˆÜ”�Q˜tÔ$¡T r TÕ*¨AÓ.ˆØŽ5Ø�˜q�tˆJˆA‰D�!“$ñ ÷
 ˆ"ŒR�%�Ž' !¤B¥$ q¥&€Cà
‚Ø�i‰i˜˜a�Ó ˆä,1°!°qµ&¬MÓ:©M qŒˆS�U‹”aœ˜C�E›
•l×	"Ð	"©M€AÐ:à	€AØ
Œ&Ø�a•˜�ˆBÜ�q˜!–ˆAÜ˜2–Y�Ø˜Q�•x¤¨A°!­e°b­j­M¸!À½F½)Õ,CÓ!D�1Ø*+­%°µÐ'��a•%‘˜! �E B�J›-ó ñ  ð 	
ˆQ�ŠçØ-0ª_¡qÓ)¡q !ˆa��c�[‰[˜Ö¡qÒ)Ù/0Ó!1©q¨! ! A§# #©qÑ!1ð 	
ð €HùòO 	&ùò0 	;ùò *ùÚ!1s   ¡K-Æ.;K2Ê.!K7ËK<Nc                ó   € \        WR7      # )añ  
Performs the Discrete Fourier Transform (**DFT**) in the complex domain.

The sequence is automatically padded to the right with zeros, as the
*radix-2 FFT* requires the number of sample points to be a power of 2.

This method should be used with default arguments only for short sequences
as the complexity of expressions increases with the size of the sequence.

Parameters
==========

seq : iterable
    The sequence on which **DFT** is to be applied.
dps : Integer
    Specifies the number of decimal digits for precision.

Examples
========

>>> from sympy import fft, ifft

>>> fft([1, 2, 3, 4])
[10, -2 - 2*I, -2, -2 + 2*I]
>>> ifft(_)
[1, 2, 3, 4]

>>> ifft([1, 2, 3, 4])
[5/2, -1/2 + I/2, -1/2, -1/2 - I/2]
>>> fft(_)
[1, 2, 3, 4]

>>> ifft([1, 7, 3, 4], dps=15)
[3.75, -0.5 - 0.75*I, -1.75, -0.5 + 0.75*I]
>>> fft(_)
[1.0, 7.0, 3.0, 4.0]

References
==========

.. [1] https://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm
.. [2] https://mathworld.wolfram.com/FastFourierTransform.html

)r&   ©r5   ©r%   r&   s   &&r   Úfftr9   F   s   € ô\ ˜cÔ+Ð+ó    c                 ó   € \        WR R7      # )T)r&   r'   r7   r8   s   &&r   Úifftr<   w   s   € Ü˜c°DÔ9Ð9r:   c           	     ó¨  € \        V 4      '       g   \        R4      h\        V4      p\        V4      '       g   \	        R4      hV  Uu. uF  p\        V4      V,          NK  	  pp\        V4      pV^8  d   V# VP                  4       ^,
          pWf^,
          ,          '       d   V^,          p^V,          pV^,
          V,          '       d   \	        R4      hV^ .V\        V4      ,
          ,          ,          p\        ^V4       FA  p\        \        W‡RR7      RRR1,          ^4      p	W‰8  g   K,  WY,          WX,          uWX&   WY&   KC  	  \        V4      p
\        W£^,
          V,          V4      pV'       d   \        W³^,
          V4      p^.V^,          ,          p\        ^V^,          4       F"  pWÈ^,
          ,          V,          V,          WÈ&   K$  	  ^pWÖ8:  d´   V^,          Wm,          rþ\        ^ Wm4       Fˆ  p\        V4       Fv  p	WXV	,           ,          WXV	,           V,           ,          WÏV	,          ,          ,          ppVV,           V,          VV,
          V,          uWXV	,           &   WXV	,           V,           &   Kx  	  KŠ  	  V^,          pK¹  V'       d2   \        Wc^,
          V4      pV Uu. uF  qDV,          V,          NK  	  ppV# u upi u upi )z3Utility function for the Number Theoretic TransformzJExpected a sequence of integer coefficients for Number Theoretic Transformz5Expected prime modulus for Number Theoretic Transformz/Expected prime modulus of the form (m*2**k + 1)Tr   Nr   )r   r   r   r
   r   r   r    r"   r#   r   r   Úpow)r%   Úprimer'   Úpr   r)   r*   r+   r,   r-   ÚprÚrtr/   r0   r1   r2   r3   r4   Úrvs   &&&                r   Ú_number_theoretic_transformrD   ƒ   s[  € ô �C�=Š=Üð 9ó :ð 	:ô 	ˆu‹€AÜ�1�:Š:Üð 5ó 6ð 	6ñ !$Ó$¡˜1Œ�‹�Q�ˆ¡€AÐ$äˆA‹€AØˆ1„uØˆà	�‰‹˜Õ€AØˆa�%‡y„yØ	ˆQ�ˆØˆq�Dˆà	ˆA��‡{„{ÜÐJÓKÐKàˆ!ˆˆa”#�a“&�jÕ	Õ€AÜ�1�aŽ[ˆÜ”�Q˜tÔ$¡T r TÕ*¨AÓ.ˆØŽ5Ø�˜q�tˆJˆA‰D�!“$ñ ô
 
˜Ó	€Bä	ˆR�a•%˜A•˜qÓ	!€BßÜ�˜•U˜AÓˆà	
ˆˆQ�!�V�€AÜ�1�a˜1•fÖˆØ�Q•�x˜�{˜Q�ˆ‹ñ ð 	
€AØ
Œ&Ø�a•˜�ˆBÜ�q˜!–ˆAÜ˜2–Y�Ø˜Q�•x  q¥5¨2¥:¥¨q°aµ­yÕ!8�1�Ø+,¨q­5°A­+¸¸A½Àµ{Ð'��a•%‘˜! �E B�J›-ó ñ  ð 	
ˆQ�ŠçÜ�˜•E˜1ÓˆÙ Ó!™q˜!ˆr�T�A�XˆX™qˆÐ!à€HùòW 	%ùòR "s   ÁK
Ê.Kc                ó   € \        WR7      # )aÞ  
Performs the Number Theoretic Transform (**NTT**), which specializes the
Discrete Fourier Transform (**DFT**) over quotient ring `Z/pZ` for prime
`p` instead of complex numbers `C`.

The sequence is automatically padded to the right with zeros, as the
*radix-2 NTT* requires the number of sample points to be a power of 2.

Parameters
==========

seq : iterable
    The sequence on which **DFT** is to be applied.
prime : Integer
    Prime modulus of the form `(m 2^k + 1)` to be used for performing
    **NTT** on the sequence.

Examples
========

>>> from sympy import ntt, intt
>>> ntt([1, 2, 3, 4], prime=3*2**8 + 1)
[10, 643, 767, 122]
>>> intt(_, 3*2**8 + 1)
[1, 2, 3, 4]
>>> intt([1, 2, 3, 4], prime=3*2**8 + 1)
[387, 415, 384, 353]
>>> ntt(_, prime=3*2**8 + 1)
[1, 2, 3, 4]

References
==========

.. [1] http://www.apfloat.org/ntt.html
.. [2] https://mathworld.wolfram.com/NumberTheoreticTransform.html
.. [3] https://en.wikipedia.org/wiki/Discrete_Fourier_transform_(general%29

)r?   ©rD   ©r%   r?   s   &&r   ÚnttrH   ½   s   € ôP ' sÔ8Ð8r:   c                 ó   € \        WR R7      # )T)r?   r'   rF   rG   s   &&r   ÚinttrJ   è   s   € Ü& sÀÔFÐFr:   c                óÀ  € \        V 4      '       g   \        R4      hV  Uu. uF  p\        V4      NK  	  pp\        V4      pV^8  d   V# WD^,
          ,          '       d   ^VP	                  4       ,          pV\
        P                  .V\        V4      ,
          ,          ,          p^pWT8:  dˆ   V^,          p\        ^ WE4       Fc  p\        V4       FQ  pW7V,           ,          W7V,           V,           ,          r©Wš,           Wš,
          uW7V,           &   W7V,           V,           &   KS  	  Ke  	  V^,          pK�  V'       d   V Uu. uF  q»V,          NK  	  ppV# u upi u upi )z1Utility function for the Walsh Hadamard Transformz@Expected a sequence of coefficients for Walsh Hadamard Transform©r   r   r   r   r    r   r!   r"   )r%   r'   r(   r)   r*   r0   r1   r,   r-   r3   r4   r   s   &&          r   Ú_walsh_hadamard_transformrM   ô   s#  € ô �C�=Š=Üð 7ó 8ð 	8ñ "%Ó%¡˜#Œ�Ž¡€AÐ%ÜˆA‹€AØˆ1„uØˆàˆa�%‡y„yØˆq�|‰|‹~ÕˆàŒ!�&‰&ˆ�1”s˜1“v•:Õ	Õ€AØ	€AØ
Œ&Ø�!�VˆÜ�q˜!–ˆAÜ˜2–Y�Ø˜Q�•x  q¥5¨2¥:¥�1Ø*+­%°µÐ'��a•%‘˜! �E B�J›-ó ñ  ð 	
ˆQ�ŠçÙÓ™!�Qˆq�SˆS™!ˆÐà€Hùò+ 	&ùò& s   ¡EÅEc                ó   € \        V 4      # )aî  
Performs the Walsh Hadamard Transform (**WHT**), and uses Hadamard
ordering for the sequence.

The sequence is automatically padded to the right with zeros, as the
*radix-2 FWHT* requires the number of sample points to be a power of 2.

Parameters
==========

seq : iterable
    The sequence on which WHT is to be applied.

Examples
========

>>> from sympy import fwht, ifwht
>>> fwht([4, 2, 2, 0, 0, 2, -2, 0])
[8, 0, 8, 0, 8, 8, 0, 0]
>>> ifwht(_)
[4, 2, 2, 0, 0, 2, -2, 0]

>>> ifwht([19, -1, 11, -9, -7, 13, -15, 5])
[2, 0, 4, 0, 3, 10, 0, 0]
>>> fwht(_)
[19, -1, 11, -9, -7, 13, -15, 5]

References
==========

.. [1] https://en.wikipedia.org/wiki/Hadamard_transform
.. [2] https://en.wikipedia.org/wiki/Fast_Walsh%E2%80%93Hadamard_transform

©rM   ©r%   s   &r   ÚfwhtrQ     s   € ôH % SÓ)Ð)r:   c                 ó   € \        V R R7      # )T)r'   rO   rP   s   &r   ÚifwhtrS   :  s   € Ü$ S°$Ô7Ð7r:   c                óà  € \        V 4      '       g   \        R4      hV  Uu. uF  p\        V4      NK  	  pp\        V4      pV^8  d   V# WU^,
          ,          '       d   ^VP	                  4       ,          pV\
        P                  .V\        V4      ,
          ,          ,          pV'       d`   ^pWe8  dU   \        V4       F:  pWv,          '       g   K  WG;;,          WWv,          ,          ,          ,          uu&   K<  	  V^,          pKZ   V# ^pWe8  dU   \        V4       F:  pWv,          '       d   K  WG;;,          WWv,          ,          ,          ,          uu&   K<  	  V^,          pKZ  V# u upi )zXUtility function for performing Mobius Transform using
Yate's Dynamic Programming methodz#Expected a sequence of coefficientsrL   )r%   ÚsgnÚsubsetr(   r)   r*   r,   r-   s   &&&     r   Ú_mobius_transformrW   F  s  € ô �C�=Š=ÜÐ=Ó>Ð>á!$Ó%¡˜#Œ�Ž¡€AÐ%äˆA‹€AØˆ1„uØˆàˆa�%‡y„yØˆq�|‰|‹~ÕˆàŒ!�&‰&ˆ�1”s˜1“v•:Õ	Õ€AçØˆØŒeÜ˜1–X�Ø—5–5Ø—D˜C !¥%¥�LÕ(•Dñ ð ��FŠAð	 ð €Hð ˆØŒeÜ˜1–X�Ø—5”5ÙØ—˜˜a�e�H�Õ$•ñ ð ��FŠAà€Hùò9 	&s   ¡E+c                ó   € \        V ^VR7      # )af  
Performs the Mobius Transform for subset lattice with indices of
sequence as bitmasks.

The indices of each argument, considered as bit strings, correspond
to subsets of a finite set.

The sequence is automatically padded to the right with zeros, as the
definition of subset/superset based on bitmasks (indices) requires
the size of sequence to be a power of 2.

Parameters
==========

seq : iterable
    The sequence on which Mobius Transform is to be applied.
subset : bool
    Specifies if Mobius Transform is applied by enumerating subsets
    or supersets of the given set.

Examples
========

>>> from sympy import symbols
>>> from sympy import mobius_transform, inverse_mobius_transform
>>> x, y, z = symbols('x y z')

>>> mobius_transform([x, y, z])
[x, x + y, x + z, x + y + z]
>>> inverse_mobius_transform(_)
[x, y, z, 0]

>>> mobius_transform([x, y, z], subset=False)
[x + y + z, y, z, 0]
>>> inverse_mobius_transform(_, subset=False)
[x, y, z, 0]

>>> mobius_transform([1, 2, 3, 4])
[1, 3, 4, 10]
>>> inverse_mobius_transform(_)
[1, 2, 3, 4]
>>> mobius_transform([1, 2, 3, 4], subset=False)
[10, 6, 7, 4]
>>> inverse_mobius_transform(_, subset=False)
[1, 2, 3, 4]

References
==========

.. [1] https://en.wikipedia.org/wiki/M%C3%B6bius_inversion_formula
.. [2] https://people.csail.mit.edu/rrw/presentations/subset-conv.pdf
.. [3] https://arxiv.org/pdf/1211.0189.pdf

©rU   rV   ©rW   ©r%   rV   s   &&r   Úmobius_transformr\   l  s   € ôp ˜S b°Ô8Ð8r:   c                 ó   € \        V RVR7      # )é   rY   r   rZ   r[   s   &&r   Úinverse_mobius_transformr_   ¦  s   € Ü˜S b°Ô8Ð8r:   )Fr   )T)!Ú__doc__Ú
sympy.corer   r   r   Úsympy.core.functionr   Úsympy.core.numbersr   r   Ú(sympy.functions.elementary.trigonometricr   r	   Úsympy.ntheoryr
   r   Úsympy.utilities.iterablesr   r   Úsympy.utilities.miscr   r5   r9   r<   rD   rH   rJ   rM   rQ   rS   rW   r\   r_   © r:   r   Ú<module>ri      s    ðñ÷
 *Ñ )Ý *ß $ß =ß 1ß 4Ý 'ô.ôb.,ôb:ð �{‰{€„ô7òt(9òVGð �{‰{€„ôò>$*òN8ð —‘€„ò#ôL89ôt9ð $4×#;Ñ#;Ð Ö  r:   