B
    [,                 @   sr   d Z ddlmZmZ ddlmZmZmZmZ ddl	m
Z
 ddlmZ dd Zdd	 ZdddZedZdd ZdS )z!Known matrices related to physics    )print_functiondivision)MatrixIpisqrt)exp)rangec             C   sH   | dkrd}n2| dkr*dt  ft dff}n| dkr8d}ntdt|S )a  Returns a Pauli matrix `\sigma_i` with `i=1,2,3`

    References
    ==========

    .. [1] http://en.wikipedia.org/wiki/Pauli_matrices

    Examples
    ========

    >>> from sympy.physics.matrices import msigma
    >>> msigma(1)
    Matrix([
    [0, 1],
    [1, 0]])
       ))r   r
   )r
   r      r      ))r
   r   )r   zInvalid Pauli index)r   
IndexErrorr   )imat r   5lib/python3.7/site-packages/sympy/physics/matrices.pymsigma
   s    r   c             C   sj   | | }| | }| | }|d }|d }|d }	||	 ||f|||	 |f|||| ff}
| t |
 S )a  Returns the Parallel Axis Theorem matrix to translate the inertia
    matrix a distance of `(dx, dy, dz)` for a body of mass m.

    Examples
    ========

    To translate a body having a mass of 2 units a distance of 1 unit along
    the `x`-axis we get:

    >>> from sympy.physics.matrices import pat_matrix
    >>> pat_matrix(2, 1, 0, 0)
    Matrix([
    [0, 0, 0],
    [0, 2, 0],
    [0, 0, 2]])

    r   )r   )mZdxZdyZdzZdxdyZdydzZdzdxZdxdxZdydyZdzdzr   r   r   r   
pat_matrix/   s    


r   Fc             C   s   | dkrt d| dkrd}nb| dkr,d}nT| dkrfdddt fddtdfdtddft dddff}n| dkrtd	}n| d
krd}t|}|r| dkr| }|S )an  Returns a Dirac gamma matrix `\gamma^\mu` in the standard
    (Dirac) representation.

    If you want `\gamma_\mu`, use ``gamma(mu, True)``.

    We use a convention:

    `\gamma^5 = i \cdot \gamma^0 \cdot \gamma^1 \cdot \gamma^2 \cdot \gamma^3`

    `\gamma_5 = i \cdot \gamma_0 \cdot \gamma_1 \cdot \gamma_2 \cdot \gamma_3 = - \gamma^5`

    References
    ==========

    .. [1] http://en.wikipedia.org/wiki/Gamma_matrices

    Examples
    ========

    >>> from sympy.physics.matrices import mgamma
    >>> mgamma(1)
    Matrix([
    [ 0,  0, 0, 1],
    [ 0,  0, 1, 0],
    [ 0, -1, 0, 0],
    [-1,  0, 0, 0]])
    )r   r
   r   r      zInvalid Dirac indexr   ))r
   r   r   r   )r   r
   r   r   )r   r   r   r   )r   r   r   r   r
   ))r   r   r   r
   )r   r   r
   r   )r   r   r   r   )r   r   r   r   r   r   ))r   r   r
   r   )r   r   r   r   )r   r   r   r   )r   r
   r   r   r   ))r   r   r
   r   )r   r   r   r
   )r
   r   r   r   )r   r
   r   r   )r
   r   r   r   )r   r   r   )Zmulowerr   r   r   r   r   mgammaM   s(    

r   ))r
   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   c                s    fddt  D }tdt t   }dg  |d< xt  D ]}d|| d< qBW xFt d D ]8}x2t | D ]$}|||   || |< || |< qrW qbW dt  t| S )a  
    Returns an expression of a discrete Fourier transform as a matrix multiplication.
    It is an n X n matrix.

    References
    ==========

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

    Examples
    ========

    >>> from sympy.physics.matrices import mdft
    >>> mdft(3)
    Matrix([
    [sqrt(3)/3,                sqrt(3)/3,                sqrt(3)/3],
    [sqrt(3)/3, sqrt(3)*exp(-2*I*pi/3)/3, sqrt(3)*exp(-4*I*pi/3)/3],
    [sqrt(3)/3, sqrt(3)*exp(-4*I*pi/3)/3, sqrt(3)*exp(-8*I*pi/3)/3]])
    c                s   g | ]}d d t  D qS )c             S   s   g | ]}d qS )Nr   ).0xr   r   r   
<listcomp>   s    z#mdft.<locals>.<listcomp>.<listcomp>)r	   )r   y)nr   r   r      s    zmdft.<locals>.<listcomp>r
   r   )r	   r   r   r   r   r   )r   r   baser   jr   )r   r   mdft   s    (r!   N)F)__doc__Z
__future__r   r   Zsympyr   r   r   r   Zsympy.functionsr   Zsympy.core.compatibilityr	   r   r   r   Zminkowski_tensorr!   r   r   r   r   <module>   s   %
I