U
    ˜9%e|	  ã                   @   sJ   d Z ddlmZmZ ddlmZ dgZG dd„ deƒZde_dd„ e_	dS )	zHermitian conjugation.é    )ÚExprÚMul)ÚadjointÚDaggerc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )r   ar  General Hermitian conjugate operation.

    Explanation
    ===========

    Take the Hermetian conjugate of an argument [1]_. For matrices this
    operation is equivalent to transpose and complex conjugate [2]_.

    Parameters
    ==========

    arg : Expr
        The SymPy expression that we want to take the dagger of.

    Examples
    ========

    Daggering various quantum objects:

        >>> from sympy.physics.quantum.dagger import Dagger
        >>> from sympy.physics.quantum.state import Ket, Bra
        >>> from sympy.physics.quantum.operator import Operator
        >>> Dagger(Ket('psi'))
        <psi|
        >>> Dagger(Bra('phi'))
        |phi>
        >>> Dagger(Operator('A'))
        Dagger(A)

    Inner and outer products::

        >>> from sympy.physics.quantum import InnerProduct, OuterProduct
        >>> Dagger(InnerProduct(Bra('a'), Ket('b')))
        <b|a>
        >>> Dagger(OuterProduct(Ket('a'), Bra('b')))
        |b><a|

    Powers, sums and products::

        >>> A = Operator('A')
        >>> B = Operator('B')
        >>> Dagger(A*B)
        Dagger(B)*Dagger(A)
        >>> Dagger(A+B)
        Dagger(A) + Dagger(B)
        >>> Dagger(A**2)
        Dagger(A)**2

    Dagger also seamlessly handles complex numbers and matrices::

        >>> from sympy import Matrix, I
        >>> m = Matrix([[1,I],[2,I]])
        >>> m
        Matrix([
        [1, I],
        [2, I]])
        >>> Dagger(m)
        Matrix([
        [ 1,  2],
        [-I, -I]])

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Hermitian_adjoint
    .. [2] https://en.wikipedia.org/wiki/Hermitian_transpose
    c                 C   sL   t |dƒr| ¡ }n t |dƒr4t |dƒr4| ¡  ¡ }|d k	r@|S t | |¡S )Nr   Ú	conjugateÚ	transpose)Úhasattrr   r   r   r   Ú__new__)ÚclsÚargÚobj© r   ú[/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/sympy/physics/quantum/dagger.pyr	   P   s    

zDagger.__new__c                 C   s$   ddl m} t||ƒr| S t| |ƒS )Nr   )ÚIdentityOperator)Zsympy.physics.quantumr   Ú
isinstancer   )ÚselfÚotherr   r   r   r   Ú__mul__Y   s    
zDagger.__mul__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   r   r   r   r      s   D	c                 C   s   d|  | jd ¡ S )Nz
Dagger(%s)r   )Z_printÚargs)ÚaÚbr   r   r   Ú<lambda>a   ó    r   N)
r   Z
sympy.corer   r   Z$sympy.functions.elementary.complexesr   Ú__all__r   r   Z
_sympyreprr   r   r   r   Ú<module>   s   ÿU