File: //opt/alt/python37/lib64/python3.7/site-packages/numpy/fft/__pycache__/helper.cpython-37.opt-1.pyc
B
    <�Fd3%  �               @   s�   d Z ddlmZmZmZ ddlZddlZddlmZ ddl	m
Z
mZmZm
Z
mZmZ dddd	gZeef Zdd
d�Zddd�Zdd
d�Zddd	�ZG dd� de�ZdS )z*
Discrete Fourier Transforms - helper.py
�    )�division�absolute_import�print_functionN)�
integer_types)�asarray�concatenate�arange�take�integer�empty�fftshift�	ifftshift�fftfreq�rfftfreqc       	      C   s�   t | �}|j}|dkr$tt|��}nt|t�r4|f}|}xD|D ]<}|j| }|d d }tt||�t|�f�}t	|||�}q>W |S )as  
    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
    --------
    >>> freqs = np.fft.fftfreq(10, 0.1)
    >>> freqs
    array([ 0.,  1.,  2.,  3.,  4., -5., -4., -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.]])
    N�   �   )
r   �ndim�list�range�
isinstancer   �shaper   r   r	   )	�x�axes�tmpr   �y�k�n�p2�mylist� r   �C/opt/alt/python37/lib64/python3.7/site-packages/numpy/fft/helper.pyr      s    ,
c       	      C   s�   t | �}|j}|dkr$tt|��}nt|t�r4|f}|}xH|D ]@}|j| }||d d  }tt||�t|�f�}t	|||�}q>W |S )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
    --------
    >>> 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.]])
    Nr   r   )
r   r   r   r   r   r   r   r   r   r	   )	r   r   r   r   r   r   r   r   r   r   r   r    r
   Q   s    "
�      �?c             C   sz   t | t�std��d| |  }t| t�}| d d d }td|td�}||d|�<