a
    ž¬<b.  ã                   @   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__© úr/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/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