
    Ed.                         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dS )    )_sympify)
MatrixExpr)I)S)exp)sqrtc                   ^     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          |          }|                     |           t                                          | |          }|S N)r   
_check_dimsuper__new__)clsnobj	__class__s      Blib/python3.11/site-packages/sympy/matrices/expressions/fourier.pyr   zDFT.__new__*   s<    QKKqggooc1%%
    c                     | j         d         S )Nr   )argsselfs    r   <lambda>zDFT.<lambda>1   s    dil r   c                     | j         | j         fS r   )r   r   s    r   r   zDFT.<lambda>2   s    4646"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;    14	$& !!1Q3x$tv,,&&r   c                 *    t          | j                  S r   )IDFTr   r   s    r   _eval_inversezDFT._eval_inverse8   s    DF||r   )__name__
__module____qualname____doc__r   propertyr   shaper&   r)   __classcell__)r   s   @r   r
   r
   	   s         @     	**++AH2233E' ' '      r   r
   c                       e Zd ZdZd Z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                     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=    14	$& !!A2a4y4<<''r   c                 *    t          | j                  S r   )r
   r   r   s    r   r)   zIDFT._eval_inverseZ   s    46{{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;      s    ' ' ' ' ' ' 1 1 1 1 1 1             " " " " " " 6 6 6 6 6 6 9 9 9 9 9 90 0 0 0 0* 0 0 0f    3     r   