
    Khw                         S r SSKJrJrJrJrJr  SSKJrJ	r	  / SQr
\\4rSS jr\" \SS9SS	 j5       r\" \SS9SS
 j5       r\	" S5      SS j5       r\	" S5      SS j5       rg)z+
Discrete Fourier Transforms - _helper.py

    )integeremptyarangeasarrayroll)array_function_dispatch
set_module)fftshift	ifftshiftfftfreqrfftfreqNc                     U 4$ N )xaxess     C/var/www/html/env/lib/python3.13/site-packages/numpy/fft/_helper.py_fftshift_dispatcherr      s	    4K    z	numpy.fft)modulec                 V   [        U 5      n Uc=  [        [        U R                  5      5      nU R                   Vs/ s H  o"S-  PM	     nnOI[        U[        5      (       a  U R                  U   S-  nO!U Vs/ s H  o@R                  U   S-  PM     nn[        XU5      $ s  snf s  snf )a  
Shift the zero-frequency component to the center of the spectrum.

This function swaps half-spaces for all axes listed (defaults to all).
Note that ``y[0]`` is the Nyquist component only if ``len(x)`` is even.

Parameters
----------
x : array_like
    Input array.
axes : int or shape tuple, optional
    Axes over which to shift.  Default is None, which shifts all axes.

Returns
-------
y : ndarray
    The shifted array.

See Also
--------
ifftshift : The inverse of `fftshift`.

Examples
--------
>>> import numpy as np
>>> freqs = np.fft.fftfreq(10, 0.1)
>>> freqs
array([ 0.,  1.,  2., ..., -3., -2., -1.])
>>> np.fft.fftshift(freqs)
array([-5., -4., -3., -2., -1.,  0.,  1.,  2.,  3.,  4.])

Shift the zero-frequency component only along the second axis:

>>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3)
>>> freqs
array([[ 0.,  1.,  2.],
       [ 3.,  4., -4.],
       [-3., -2., -1.]])
>>> np.fft.fftshift(freqs, axes=(1,))
array([[ 2.,  0.,  1.],
       [-4.,  3.,  4.],
       [-1., -3., -2.]])

   r   tuplerangendimshape
isinstanceinteger_typesr   r   r   dimshiftaxs        r   r
   r
      s    \ 	
A|U166]#%&WW-WcW-	D-	(	(",01Db!D1$ . 2s   B!8B&c                 \   [        U 5      n Uc>  [        [        U R                  5      5      nU R                   Vs/ s H  o"S-  * PM
     nnOK[        U[        5      (       a  U R                  U   S-  * nO"U Vs/ s H  o@R                  U   S-  * PM     nn[        XU5      $ s  snf s  snf )a  
The inverse of `fftshift`. Although identical for even-length `x`, the
functions differ by one sample for odd-length `x`.

Parameters
----------
x : array_like
    Input array.
axes : int or shape tuple, optional
    Axes over which to calculate.  Defaults to None, which shifts all axes.

Returns
-------
y : ndarray
    The shifted array.

See Also
--------
fftshift : Shift zero-frequency component to the center of the spectrum.

Examples
--------
>>> import numpy as np
>>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3)
>>> freqs
array([[ 0.,  1.,  2.],
       [ 3.,  4., -4.],
       [-3., -2., -1.]])
>>> np.fft.ifftshift(np.fft.fftshift(freqs))
array([[ 0.,  1.,  2.],
       [ 3.,  4., -4.],
       [-3., -2., -1.]])

r   r   r    s        r   r   r   M   s    H 	
A|U166]#()0!80	D-	(	(''$-1$%/34t772;!#$t4$ 1 5s   B$:B)c                     [        U [        5      (       d  [        S5      eSX-  -  n[        U [        US9nU S-
  S-  S-   n[        SU[        US9nXdSU& [        U S-  * S[        US9nXtUS& XC-  $ )	a  
Return the Discrete Fourier Transform sample frequencies.

The returned float array `f` contains the frequency bin centers in cycles
per unit of the sample spacing (with zero at the start).  For instance, if
the sample spacing is in seconds, then the frequency unit is cycles/second.

Given a window length `n` and a sample spacing `d`::

  f = [0, 1, ...,   n/2-1,     -n/2, ..., -1] / (d*n)   if n is even
  f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n)   if n is odd

Parameters
----------
n : int
    Window length.
d : scalar, optional
    Sample spacing (inverse of the sampling rate). Defaults to 1.
device : str, optional
    The device on which to place the created array. Default: ``None``.
    For Array-API interoperability only, so must be ``"cpu"`` if passed.

    .. versionadded:: 2.0.0

Returns
-------
f : ndarray
    Array of length `n` containing the sample frequencies.

Examples
--------
>>> import numpy as np
>>> signal = np.array([-2, 8, 6, 4, 1, 0, 3, 5], dtype=float)
>>> fourier = np.fft.fft(signal)
>>> n = signal.size
>>> timestep = 0.1
>>> freq = np.fft.fftfreq(n, d=timestep)
>>> freq
array([ 0.  ,  1.25,  2.5 , ..., -3.75, -2.5 , -1.25])

n should be an integer      ?)device   r   r   dtyper(   N)r   r   
ValueErrorr   intr   )ndr(   valresultsNp1p2s           r   r   r   }   s    V a''122
-CAs6*G	
1q1A	1C	/BBQK	!Q$#f	5BABK=r   c                     [        U [        5      (       d  [        S5      eSX-  -  nU S-  S-   n[        SU[        US9nXS-  $ )a  
Return the Discrete Fourier Transform sample frequencies
(for usage with rfft, irfft).

The returned float array `f` contains the frequency bin centers in cycles
per unit of the sample spacing (with zero at the start).  For instance, if
the sample spacing is in seconds, then the frequency unit is cycles/second.

Given a window length `n` and a sample spacing `d`::

  f = [0, 1, ...,     n/2-1,     n/2] / (d*n)   if n is even
  f = [0, 1, ..., (n-1)/2-1, (n-1)/2] / (d*n)   if n is odd

Unlike `fftfreq` (but like `scipy.fftpack.rfftfreq`)
the Nyquist frequency component is considered to be positive.

Parameters
----------
n : int
    Window length.
d : scalar, optional
    Sample spacing (inverse of the sampling rate). Defaults to 1.
device : str, optional
    The device on which to place the created array. Default: ``None``.
    For Array-API interoperability only, so must be ``"cpu"`` if passed.

    .. versionadded:: 2.0.0

Returns
-------
f : ndarray
    Array of length ``n//2 + 1`` containing the sample frequencies.

Examples
--------
>>> import numpy as np
>>> signal = np.array([-2, 8, 6, 4, 1, 0, 3, 5, -3, 4], dtype=float)
>>> fourier = np.fft.rfft(signal)
>>> n = signal.size
>>> sample_rate = 100
>>> freq = np.fft.fftfreq(n, d=1./sample_rate)
>>> freq
array([  0.,  10.,  20., ..., -30., -20., -10.])
>>> freq = np.fft.rfftfreq(n, d=1./sample_rate)
>>> freq
array([  0.,  10.,  20.,  30.,  40.,  50.])

r&   r'   r   r)   r   r*   )r   r   r,   r   r-   )r.   r/   r(   r0   r2   r1   s         r   r   r      sN    d a''122
qs)C	1qAQV4G=r   r   )r'   N)__doc__numpy._corer   r   r   r   r   numpy._core.overridesr   r	   __all__r-   r   r   r
   r   r   r   r   r   r   <module>r:      s    > = E ;g -kB6  C6 r -kB,  C, ^ K3 3l K6 6r   