Ë
    âQ(h@>  ã                   óð   — d Z g d¢ZddlZddlmZmZmZmZmZm	Z	m
Z
mZ ddlmZ ddlmZ  ej                   «       Zddefd„Zdefd	„Zdefd
„Zefd„Zefd„Zdefd„Zdefd„Zdefd„Zdefd„Zdefd„Zy)z1
Differential and pseudo-differential operators.
)
ÚdiffÚtilbertÚitilbertÚhilbertÚihilbertÚcs_diffÚcc_diffÚsc_diffÚss_diffÚshifté    N)ÚpiÚasarrayÚsinÚcosÚsinhÚcoshÚtanhÚiscomplexobjé   )Úconvolve)Ú_datacopiedc                 ó^  — t        |t        j                  «      rt        |d«      si |_        |j                  }t        | «      }|dk(  r|S t        |«      r4t        |j                  |||«      dt        |j                  |||«      z  z   S |�dt        z  |z  }nd}t        | «      }|j                  |||f«      }|€Jt        |«      dkD  r|r|j                  «        |rŒ||fd„}t        j                  |||d¬	«      }|||||f<   t!        || «      }	t        j                  |||dz  |	¬
«      S )a*  
    Return kth derivative (or integral) of a periodic sequence x.

    If x_j and y_j are Fourier coefficients of periodic functions x
    and y, respectively, then::

      y_j = pow(sqrt(-1)*j*2*pi/period, order) * x_j
      y_0 = 0 if order is not 0.

    Parameters
    ----------
    x : array_like
        Input array.
    order : int, optional
        The order of differentiation. Default order is 1. If order is
        negative, then integration is carried out under the assumption
        that ``x_0 == 0``.
    period : float, optional
        The assumed period of the sequence. Default is ``2*pi``.

    Notes
    -----
    If ``sum(x, axis=0) = 0`` then ``diff(diff(x, k), -k) == x`` (within
    numerical accuracy).

    For odd order and even ``len(x)``, the Nyquist mode is taken zero.

    Ú
diff_cacher   ù              ð?é   ç      ð?é   c                 ó&   — | rt        || z  |«      S y©Nr   )Úpow)ÚkÚorderÚcs      úY/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/scipy/fftpack/_pseudo_diffs.pyÚkernelzdiff.<locals>.kernelI   s   € ÙÜ˜1˜Q™3˜u“~Ð%Øó    r   ©ÚdÚzero_nyquist©Úswap_real_imagÚoverwrite_x)Ú
isinstanceÚ	threadingÚlocalÚhasattrr   r   r   r   ÚrealÚimagr   ÚlenÚgetÚpopitemr   Úinit_convolution_kernelr   )
Úxr"   ÚperiodÚ_cacheÚtmpr#   ÚnÚomegar%   r,   s
             r$   r   r      s?  € ô: �&œ)Ÿ/™/Ô*Ü�v˜|Ô,Ø "ˆFÔØ×"Ñ"ˆä
�!‹*€CØ�‚zØˆ
Ü�CÔÜ�C—H‘H˜e V¨VÓ4°R¼Ø�H‰H�e˜V Vó9-ñ 6-ñ -ð 	-àÐØŒb‰D�‰K‰àˆÜˆA‹€AØ�J‰J˜˜% �{Ó#€EØ€}Üˆv‹;˜ÒÙØ—‘Ô ò ð ! 1ó 	ô ×0Ñ0°°6¸EØ>?ôAˆà#ˆ��%˜ˆ{ÑÜ˜c 1Ó%€KÜ×Ñ˜S °e¸a±iØ)4ô6ð 6r&   c                 óB  — t        |t        j                  «      rt        |d«      si |_        |j                  }t        | «      }t        |«      r4t        |j                  |||«      dt        |j                  |||«      z  z   S |�|dz  t        z  |z  }t        | «      }|j                  ||f«      }|€Gt        |«      dkD  r|r|j                  «        |rŒ|fd„}t        j                  ||d¬«      }||||f<   t!        || «      }t        j                  ||d|¬«      S )	a�  
    Return h-Tilbert transform of a periodic sequence x.

    If x_j and y_j are Fourier coefficients of periodic functions x
    and y, respectively, then::

        y_j = sqrt(-1)*coth(j*h*2*pi/period) * x_j
        y_0 = 0

    Parameters
    ----------
    x : array_like
        The input array to transform.
    h : float
        Defines the parameter of the Tilbert transform.
    period : float, optional
        The assumed period of the sequence. Default period is ``2*pi``.

    Returns
    -------
    tilbert : ndarray
        The result of the transform.

    Notes
    -----
    If ``sum(x, axis=0) == 0`` and ``n = len(x)`` is odd, then
    ``tilbert(itilbert(x)) == x``.

    If ``2 * pi * h / period`` is approximately 10 or larger, then
    numerically ``tilbert == hilbert``
    (theoretically oo-Tilbert == Hilbert).

    For even ``len(x)``, the Nyquist mode of ``x`` is taken zero.

    Útilbert_cacher   r   r   c                 ó*   — | rdt        || z  «      z  S y)Nr   r   ©r   ©r!   Úhs     r$   r%   ztilbert.<locals>.kernel�   s   € ÙØœ4  !¡›9‘}Ð$àr&   r   ©r(   r*   )r-   r.   r/   r0   r>   r   r   r   r1   r2   r   r3   r4   r5   r   r6   r   ©	r7   rB   r8   r9   r:   r;   r<   r%   r,   s	            r$   r   r   U   s  € ôH �&œ)Ÿ/™/Ô*Ü�v˜Ô/Ø#%ˆFÔ Ø×%Ñ%ˆä
�!‹*€CÜ�CÔÜ�s—x‘x  F¨FÓ3Ø”G˜CŸH™H a¨°Ó8Ñ8ñ9ð 	9ð ÐØ�‰E”B‰J˜ÑˆäˆA‹€AØ�J‰J˜˜1�vÓ€EØ€}Üˆv‹;˜ÒÙØ—‘Ô ò ð ó 	ô ×0Ñ0°°F¸aÔ@ˆØˆ��!ˆu‰ä˜c 1Ó%€KÜ×Ñ˜S °aÀKÔPÐPr&   c                 óB  — t        |t        j                  «      rt        |d«      si |_        |j                  }t        | «      }t        |«      r4t        |j                  |||«      dt        |j                  |||«      z  z   S |�|dz  t        z  |z  }t        | «      }|j                  ||f«      }|€Gt        |«      dkD  r|r|j                  «        |rŒ|fd„}t        j                  ||d¬«      }||||f<   t!        || «      }t        j                  ||d|¬«      S )	a  
    Return inverse h-Tilbert transform of a periodic sequence x.

    If ``x_j`` and ``y_j`` are Fourier coefficients of periodic functions x
    and y, respectively, then::

      y_j = -sqrt(-1)*tanh(j*h*2*pi/period) * x_j
      y_0 = 0

    For more details, see `tilbert`.

    Úitilbert_cacher   r   r   c                 ó&   — | rt        || z  «       S yr   r@   rA   s     r$   r%   zitilbert.<locals>.kernel¹   s   € ÙÜ˜Q˜q™S›	�zÐ!Ør&   r   rC   r*   )r-   r.   r/   r0   rF   r   r   r   r1   r2   r   r3   r4   r5   r   r6   r   rD   s	            r$   r   r   š   s  € ô �&œ)Ÿ/™/Ô*Ü�vÐ/Ô0Ø$&ˆFÔ!Ø×&Ñ&ˆä
�!‹*€CÜ�CÔÜ˜Ÿ™ ! V¨VÓ4Ø”(˜3Ÿ8™8 Q¨°Ó7Ñ7ñ8ð 	8àÐØˆa‰C”‰F�6‰MˆÜˆA‹€AØ�J‰J˜˜!�uÓ€EØ€}Üˆv‹;˜ÒÙØ—‘Ô ò ð ó 	ô ×0Ñ0°°6¸AÔ>ˆØˆ��!ˆu‰Ü˜c 1Ó%€KÜ×Ñ˜S °aÀKÔPÐPr&   c                 ó  — t        |t        j                  «      rt        |d«      si |_        |j                  }t        | «      }t        |«      r0t        |j                  |«      dt        |j                  |«      z  z   S t        | «      }|j                  |«      }|€Ct        |«      dkD  r|r|j                  «        |rŒd„ }t        j                  ||d¬«      }|||<   t        || «      }t        j                  ||d|¬«      S )aú  
    Return Hilbert transform of a periodic sequence x.

    If x_j and y_j are Fourier coefficients of periodic functions x
    and y, respectively, then::

      y_j = sqrt(-1)*sign(j) * x_j
      y_0 = 0

    Parameters
    ----------
    x : array_like
        The input array, should be periodic.
    _cache : dict, optional
        Dictionary that contains the kernel used to do a convolution with.

    Returns
    -------
    y : ndarray
        The transformed input.

    See Also
    --------
    scipy.signal.hilbert : Compute the analytic signal, using the Hilbert
                           transform.

    Notes
    -----
    If ``sum(x, axis=0) == 0`` then ``hilbert(ihilbert(x)) == x``.

    For even len(x), the Nyquist mode of x is taken zero.

    The sign of the returned transform does not have a factor -1 that is more
    often than not found in the definition of the Hilbert transform. Note also
    that `scipy.signal.hilbert` does have an extra -1 factor compared to this
    function.

    Úhilbert_cacher   r   c                 ó   — | dkD  ry| dk  ryy)Nr   r   g      ð¿g        © )r!   s    r$   r%   zhilbert.<locals>.kernelù   s   € Ø�1ŠuØØ�Q’ØØr&   r   rC   r*   )r-   r.   r/   r0   rI   r   r   r   r1   r2   r3   r4   r5   r   r6   r   )r7   r9   r:   r;   r<   r%   r,   s          r$   r   r   Ã   sç   € ôN �&œ)Ÿ/™/Ô*Ü�v˜Ô/Ø#%ˆFÔ Ø×%Ñ%ˆä
�!‹*€CÜ�CÔÜ�s—x‘x Ó(¨2´¸¿¹À&Ó0IÑ+IÑIÐIÜˆA‹€AØ�J‰J�q‹M€EØ€}Üˆv‹;˜ÒÙØ—‘Ô ò ò	ô ×0Ñ0°°6¸AÔ>ˆØˆˆq‰	Ü˜c 1Ó%€KÜ×Ñ˜S °aÀKÔPÐPr&   c                 óŽ   — t        |t        j                  «      rt        |d«      si |_        |j                  }t        | |«       S )zå
    Return inverse Hilbert transform of a periodic sequence x.

    If ``x_j`` and ``y_j`` are Fourier coefficients of periodic functions x
    and y, respectively, then::

      y_j = -sqrt(-1)*sign(j) * x_j
      y_0 = 0

    Úihilbert_cache)r-   r.   r/   r0   rM   r   )r7   r9   s     r$   r   r     s@   € ô �&œ)Ÿ/™/Ô*Ü�vÐ/Ô0Ø$&ˆFÔ!Ø×&Ñ&ˆÜ�A�vÓÐÐr&   c           	      ój  — t        |t        j                  «      rt        |d«      si |_        |j                  }t        | «      }t        |«      r6t        |j                  ||||«      dt        |j                  ||||«      z  z   S |�|dz  t        z  |z  }|dz  t        z  |z  }t        | «      }|j                  |||f«      }|€It        |«      dkD  r|r|j                  «        |rŒ||fd„}t        j                  ||d¬«      }|||||f<   t!        || «      }	t        j                  ||d|	¬«      S )	aô  
    Return (a,b)-cosh/sinh pseudo-derivative of a periodic sequence.

    If ``x_j`` and ``y_j`` are Fourier coefficients of periodic functions x
    and y, respectively, then::

      y_j = -sqrt(-1)*cosh(j*a*2*pi/period)/sinh(j*b*2*pi/period) * x_j
      y_0 = 0

    Parameters
    ----------
    x : array_like
        The array to take the pseudo-derivative from.
    a, b : float
        Defines the parameters of the cosh/sinh pseudo-differential
        operator.
    period : float, optional
        The period of the sequence. Default period is ``2*pi``.

    Returns
    -------
    cs_diff : ndarray
        Pseudo-derivative of periodic sequence `x`.

    Notes
    -----
    For even len(`x`), the Nyquist mode of `x` is taken as zero.

    Úcs_diff_cacher   r   r   c                 óD   — | rt        || z  «       t        || z  «      z  S yr   )r   r   ©r!   ÚaÚbs      r$   r%   zcs_diff.<locals>.kernelH  s%   € ÙÜ˜Q˜q™S›	�z¤$ q¨¡s£)Ñ+Ð+Ør&   r   rC   r*   )r-   r.   r/   r0   rO   r   r   r   r1   r2   r   r3   r4   r5   r   r6   r   ©
r7   rR   rS   r8   r9   r:   r;   r<   r%   r,   s
             r$   r   r     s3  € ô< �&œ)Ÿ/™/Ô*Ü�v˜Ô/Ø#%ˆFÔ Ø×%Ñ%ˆä
�!‹*€CÜ�CÔÜ�s—x‘x  A v¨vÓ6Ø”'˜#Ÿ(™( A q¨&°&Ó9Ñ9ñ:ð 	:àÐØˆa‰C”‰F�6‰MˆØˆa‰C”‰F�6‰MˆÜˆA‹€AØ�J‰J˜˜!˜A�wÓ€EØ€}Üˆv‹;˜ÒÙØ—‘Ô ò ð ˜1ó 	ô ×0Ñ0°°6¸AÔ>ˆØˆ��!�Aˆw‰Ü˜c 1Ó%€KÜ×Ñ˜S °aÀKÔPÐPr&   c           	      ój  — t        |t        j                  «      rt        |d«      si |_        |j                  }t        | «      }t        |«      r6t        |j                  ||||«      dt        |j                  ||||«      z  z   S |�|dz  t        z  |z  }|dz  t        z  |z  }t        | «      }|j                  |||f«      }|€It        |«      dkD  r|r|j                  «        |rŒ||fd„}t        j                  ||d¬«      }|||||f<   t!        || «      }	t        j                  ||d|	¬«      S )	aˆ  
    Return (a,b)-sinh/cosh pseudo-derivative of a periodic sequence x.

    If x_j and y_j are Fourier coefficients of periodic functions x
    and y, respectively, then::

      y_j = sqrt(-1)*sinh(j*a*2*pi/period)/cosh(j*b*2*pi/period) * x_j
      y_0 = 0

    Parameters
    ----------
    x : array_like
        Input array.
    a,b : float
        Defines the parameters of the sinh/cosh pseudo-differential
        operator.
    period : float, optional
        The period of the sequence x. Default is 2*pi.

    Notes
    -----
    ``sc_diff(cs_diff(x,a,b),b,a) == x``
    For even ``len(x)``, the Nyquist mode of x is taken as zero.

    Úsc_diff_cacher   r   r   c                 óB   — | rt        || z  «      t        || z  «      z  S yr   )r   r   rQ   s      r$   r%   zsc_diff.<locals>.kernel  s#   € ÙÜ˜A˜a™C“y¤ a¨¡c£Ñ*Ð*Ør&   r   rC   r*   )r-   r.   r/   r0   rV   r   r   r	   r1   r2   r   r3   r4   r5   r   r6   r   rT   s
             r$   r	   r	   R  s3  € ô4 �&œ)Ÿ/™/Ô*Ü�v˜Ô/Ø#%ˆFÔ Ø×%Ñ%ˆä
�!‹*€CÜ�CÔÜ�s—x‘x  A v¨vÓ6Ø”G˜CŸH™H a¨¨F°FÓ;Ñ;ñ<ð 	<àÐØˆa‰C”‰F�6‰MˆØˆa‰C”‰F�6‰MˆÜˆA‹€AØ�J‰J˜˜!˜A�wÓ€EØ€}Üˆv‹;˜ÒÙØ—‘Ô ò ð ˜1ó 	ô ×0Ñ0°°6¸AÔ>ˆØˆ��!�Aˆw‰Ü˜c 1Ó%€KÜ×Ñ˜S °aÀKÔPÐPr&   c           	      ód  — t        |t        j                  «      rt        |d«      si |_        |j                  }t        | «      }t        |«      r6t        |j                  ||||«      dt        |j                  ||||«      z  z   S |�|dz  t        z  |z  }|dz  t        z  |z  }t        | «      }|j                  |||f«      }|€Gt        |«      dkD  r|r|j                  «        |rŒ||fd„}t        j                  ||«      }|||||f<   t!        || «      }	t        j                  |||	¬«      S )ac  
    Return (a,b)-sinh/sinh pseudo-derivative of a periodic sequence x.

    If x_j and y_j are Fourier coefficients of periodic functions x
    and y, respectively, then::

      y_j = sinh(j*a*2*pi/period)/sinh(j*b*2*pi/period) * x_j
      y_0 = a/b * x_0

    Parameters
    ----------
    x : array_like
        The array to take the pseudo-derivative from.
    a,b
        Defines the parameters of the sinh/sinh pseudo-differential
        operator.
    period : float, optional
        The period of the sequence x. Default is ``2*pi``.

    Notes
    -----
    ``ss_diff(ss_diff(x,a,b),b,a) == x``

    Úss_diff_cacher   r   r   c                 ó\   — | rt        || z  «      t        || z  «      z  S t        |«      |z  S ©N)r   ÚfloatrQ   s      r$   r%   zss_diff.<locals>.kernelµ  s.   € ÙÜ˜A˜a™C“y¤ a¨¡c£Ñ*Ð*Ü˜“8˜A‘:Ðr&   ©r,   )r-   r.   r/   r0   rY   r   r   r
   r1   r2   r   r3   r4   r5   r   r6   r   rT   s
             r$   r
   r
   ‰  s/  € ô2 �&œ)Ÿ/™/Ô*Ü�v˜Ô/Ø#%ˆFÔ Ø×%Ñ%ˆä
�!‹*€CÜ�CÔÜ�s—x‘x  A v¨vÓ6Ø”'˜#Ÿ(™( A q¨&°&Ó9Ñ9ñ:ð 	:àÐØˆa‰C”‰F�6‰MˆØˆa‰C”‰F�6‰MˆÜˆA‹€AØ�J‰J˜˜!˜A�wÓ€EØ€}Üˆv‹;˜ÒÙØ—‘Ô ò ð ˜1ó 	ô ×0Ñ0°°6Ó:ˆØˆ��!�Aˆw‰Ü˜c 1Ó%€KÜ×Ñ˜S °;Ô?Ð?r&   c           	      ód  — t        |t        j                  «      rt        |d«      si |_        |j                  }t        | «      }t        |«      r6t        |j                  ||||«      dt        |j                  ||||«      z  z   S |�|dz  t        z  |z  }|dz  t        z  |z  }t        | «      }|j                  |||f«      }|€Gt        |«      dkD  r|r|j                  «        |rŒ||fd„}t        j                  ||«      }|||||f<   t!        || «      }	t        j                  |||	¬«      S )a¶  
    Return (a,b)-cosh/cosh pseudo-derivative of a periodic sequence.

    If x_j and y_j are Fourier coefficients of periodic functions x
    and y, respectively, then::

      y_j = cosh(j*a*2*pi/period)/cosh(j*b*2*pi/period) * x_j

    Parameters
    ----------
    x : array_like
        The array to take the pseudo-derivative from.
    a,b : float
        Defines the parameters of the sinh/sinh pseudo-differential
        operator.
    period : float, optional
        The period of the sequence x. Default is ``2*pi``.

    Returns
    -------
    cc_diff : ndarray
        Pseudo-derivative of periodic sequence `x`.

    Notes
    -----
    ``cc_diff(cc_diff(x,a,b),b,a) == x``

    Úcc_diff_cacher   r   r   c                 ó<   — t        || z  «      t        || z  «      z  S r[   )r   rQ   s      r$   r%   zcc_diff.<locals>.kernelï  s   € Ü˜˜!™“9œT ! A¡#›YÑ&Ð&r&   r]   )r-   r.   r/   r0   r_   r   r   r   r1   r2   r   r3   r4   r5   r   r6   r   rT   s
             r$   r   r   ¿  s-  € ô: �&œ)Ÿ/™/Ô*Ü�v˜Ô/Ø#%ˆFÔ Ø×%Ñ%ˆä
�!‹*€CÜ�CÔÜ�s—x‘x  A v¨vÓ6Ø”G˜CŸH™H a¨¨F°FÓ;Ñ;ñ<ð 	<àÐØˆa‰C”‰F�6‰MˆØˆa‰C”‰F�6‰MˆÜˆA‹€AØ�J‰J˜˜!˜A�wÓ€EØ€}Üˆv‹;˜ÒÙØ—‘Ô ò ð ˜1ó 	'ä×0Ñ0°°6Ó:ˆØˆ��!�Aˆw‰Ü˜c 1Ó%€KÜ×Ñ˜S °;Ô?Ð?r&   c                 ó�  — t        |t        j                  «      rt        |d«      si |_        |j                  }t        | «      }t        |«      r4t        |j                  |||«      dt        |j                  |||«      z  z   S |�|dz  t        z  |z  }t        | «      }|j                  ||f«      }|€it        |«      dkD  r|r|j                  «        |rŒ|fd„}|fd„}t        j                  ||dd¬«      }	t        j                  ||d	d¬«      }
|	|
f|||f<   n|\  }	}
t!        || «      }t        j"                  ||	|
|¬
«      S )aò  
    Shift periodic sequence x by a: y(u) = x(u+a).

    If x_j and y_j are Fourier coefficients of periodic functions x
    and y, respectively, then::

          y_j = exp(j*a*2*pi/period*sqrt(-1)) * x_f

    Parameters
    ----------
    x : array_like
        The array to take the pseudo-derivative from.
    a : float
        Defines the parameters of the sinh/sinh pseudo-differential
    period : float, optional
        The period of the sequences x and y. Default period is ``2*pi``.
    Úshift_cacher   r   r   c                 ó   — t        || z  «      S r[   )r   ©r!   rR   s     r$   Úkernel_realzshift.<locals>.kernel_real  ó   € Ü�q˜‘s“8ˆOr&   c                 ó   — t        || z  «      S r[   )r   rd   s     r$   Úkernel_imagzshift.<locals>.kernel_imag  rf   r&   r   r'   r   r]   )r-   r.   r/   r0   rb   r   r   r   r1   r2   r   r3   r4   r5   r   r6   r   Ú
convolve_z)r7   rR   r8   r9   r:   r;   r<   re   rh   Ú
omega_realÚ
omega_imagr,   s               r$   r   r   ÷  sX  € ô$ �&œ)Ÿ/™/Ô*Ü�v˜}Ô-Ø!#ˆFÔØ×#Ñ#ˆä
�!‹*€CÜ�CÔÜ�S—X‘X˜q &¨&Ó1°B¼Ø�H‰H�a˜ ó:)ñ 5)ñ )ð 	)àÐØˆa‰C”‰F�6‰MˆÜˆA‹€AØ�J‰J˜˜!�uÓ€EØ€}Üˆv‹;˜ÒÙØ—‘Ô ò ð ó 	ð ó 	ä×5Ñ5°a¸ÀaØCDôFˆ
ä×5Ñ5°a¸ÀaØCDôFˆ
à" :Ð-ˆ��!ˆuŠà %Ñˆ
�:Ü˜c 1Ó%€KÜ×Ñ˜s :¨jØ+6ô8ð 8r&   )Ú__doc__Ú__all__r.   Únumpyr   r   r   r   r   r   r   r   Ú r   Úscipy.fft._pocketfft.helperr   r/   r9   r   r   r   r   r   r   r	   r
   r   r   rK   r&   r$   ú<module>rq      s»   ðñò
€ó
 ç G× GÓ GÝ å 3ð 
ˆ�‰Ó	€ð ˜$ vó <6ð~  fó BQðJ  Vó &QðR ó ?QðD ó ð$ !¨ó 8Qðv !¨ó 4Qðn !¨ó 3@ðl !¨ó 5@ðp  Fô 28r&   