
    sg.                     x    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e      Z G d	 d
e      Zy)    )_sympify)
MatrixExpr)I)S)exp)sqrtc                   R     e Zd ZdZ fdZ ed       Z ed       Zd Zd Z	 x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                 `    t        |      }| j                  |       t        |   | |      }|S N)r   
_check_dimsuper__new__)clsnobj	__class__s      U/var/www/html/venv/lib/python3.12/site-packages/sympy/matrices/expressions/fourier.pyr   zDFT.__new__*   s-    QKqgoc1%
    c                      | j                   d   S )Nr   )argsselfs    r   <lambda>zDFT.<lambda>1   s    diil r   c                 2    | j                   | j                   fS r   )r   r   s    r   r   zDFT.<lambda>2   s    466466"2 r   c                     t        dt        j                  z  t        z  | j                  z        }|||z  z  t        | j                        z  S Nr   r   Pir   r   r   r   ijkwargsws        r   _entryz
DFT._entry4   s<    144	$&& !1Q3x$tvv,&&r   c                 ,    t        | j                        S r   )IDFTr   r   s    r   _eval_inversezDFT._eval_inverse8   s    DFF|r   )__name__
__module____qualname____doc__r   propertyr   shaper&   r)   __classcell__)r   s   @r   r
   r
   	   s0    @ 	*+A23E'r   r
   c                       e Zd ZdZd Zd Zy)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                     t        dt        j                  z  t        z  | j                  z        }|| |z  z  t        | j                        z  S r   r   r!   s        r   r&   zIDFT._entryV   s>    144	$&& !A2a4y4<''r   c                 ,    t        | j                        S r   )r
   r   r   s    r   r)   zIDFT._eval_inverseZ   s    466{r   N)r*   r+   r,   r-   r&   r)    r   r   r(   r(   <   s    2(r   r(   N)sympy.core.sympifyr   sympy.matrices.expressionsr   sympy.core.numbersr   sympy.core.singletonr   &sympy.functions.elementary.exponentialr   (sympy.functions.elementary.miscellaneousr   r
   r(   r4   r   r   <module>r;      s0    ' 1   " 6 90* 0f3 r   