o
    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   
_check_dimsuper__new__)clsnobj	__class__ X/var/www/html/ai/venv/lib/python3.10/site-packages/sympy/matrices/expressions/fourier.pyr   *   s   
zDFT.__new__c                 C   s
   | j d S )Nr   )argsselfr   r   r   <lambda>1   s   
 zDFT.<lambda>c                 C   s   | j | j fS r	   )r   r   r   r   r   r   2   s    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   
   t | jS r	   )IDFTr   r   r   r   r   _eval_inverse8      
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   r"   r	   )r   r   r   r   r   r   r$   Z   r%   zIDFT._eval_inverseN)r&   r'   r(   r)   r!   r$   r   r   r   r   r#   <   s    r#   N)sympy.core.sympifyr   sympy.matrices.expressionsr   sympy.core.numbersr   sympy.core.singletonr   &sympy.functions.elementary.exponentialr   (sympy.functions.elementary.miscellaneousr   r   r#   r   r   r   r   <module>   s    3