U
    L?h.                     @   sl   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ G dd deZG d	d
 d
eZdS )    )_sympify)
MatrixExpr)I)S)exp)sqrtc                       sH   e Zd ZdZ fddZedd Zedd Zdd Zd	d
 Z	  Z
S )DFTa  
    Returns a discrete Fourier transform matrix. The matrix is scaled
    with :math:`\frac{1}{\sqrt{n}}` so that it is unitary.

    Parameters
    ==========

    n : integer or Symbol
        Size of the transform.

    Examples
    ========

    >>> from sympy.abc import n
    >>> from sympy.matrices.expressions.fourier import DFT
    >>> DFT(3)
    DFT(3)
    >>> DFT(3).as_explicit()
    Matrix([
    [sqrt(3)/3,                sqrt(3)/3,                sqrt(3)/3],
    [sqrt(3)/3, sqrt(3)*exp(-2*I*pi/3)/3,  sqrt(3)*exp(2*I*pi/3)/3],
    [sqrt(3)/3,  sqrt(3)*exp(2*I*pi/3)/3, sqrt(3)*exp(-2*I*pi/3)/3]])
    >>> DFT(n).shape
    (n, n)

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/DFT_matrix

    c                    s$   t |}| | t | |}|S N)r   Z
_check_dimsuper__new__)clsnobj	__class__ T/var/www/html/venv/lib/python3.8/site-packages/sympy/matrices/expressions/fourier.pyr   *   s    
zDFT.__new__c                 C   s
   | j d S )Nr   )argsselfr   r   r   <lambda>1       zDFT.<lambda>c                 C   s   | j | j fS r	   )r   r   r   r   r   r   2   r   c                 K   s.   t dtj t | j }|||  t| j S Nr   r   Pir   r   r   r   ijkwargswr   r   r   _entry4   s    z
DFT._entryc                 C   s
   t | jS r	   )IDFTr   r   r   r   r   _eval_inverse8   s    zDFT._eval_inverse)__name__
__module____qualname____doc__r   propertyr   shaper!   r#   __classcell__r   r   r   r   r   	   s    r   c                   @   s    e Zd ZdZdd Zdd ZdS )r"   a  
    Returns an inverse discrete Fourier transform matrix. The matrix is scaled
    with :math:`\frac{1}{\sqrt{n}}` so that it is unitary.

    Parameters
    ==========

    n : integer or Symbol
        Size of the transform

    Examples
    ========

    >>> from sympy.matrices.expressions.fourier import DFT, IDFT
    >>> IDFT(3)
    IDFT(3)
    >>> IDFT(4)*DFT(4)
    I

    See Also
    ========

    DFT

    c                 K   s0   t dtj t | j }|| |  t| j S r   r   r   r   r   r   r!   V   s    zIDFT._entryc                 C   s
   t | jS r	   )r   r   r   r   r   r   r#   Z   s    zIDFT._eval_inverseN)r$   r%   r&   r'   r!   r#   r   r   r   r   r"   <   s   r"   N)Zsympy.core.sympifyr   Zsympy.matrices.expressionsr   Zsympy.core.numbersr   Zsympy.core.singletonr   Z&sympy.functions.elementary.exponentialr   Z(sympy.functions.elementary.miscellaneousr   r   r"   r   r   r   r   <module>   s   3