
    Ed|	                     f    d Z ddlmZmZ ddlmZ dgZ G d de          Zde_        d e_	        dS )zHermitian conjugation.    )ExprMul)adjointDaggerc                       e Zd ZdZd Z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                 
   t          |d          r|                                }nFt          |d          r6t          |d          r&|                                                                }||S t	          j        | |          S )Nr   	conjugate	transpose)hasattrr   r	   r
   r   __new__)clsargobjs      <lib/python3.11/site-packages/sympy/physics/quantum/dagger.pyr   zDagger.__new__P   s~    3	"" 	.++--CCS+&& 	.73+D+D 	.--//++--C 	J|C%%%    c                 R    ddl m} t          ||          r| S t          | |          S )Nr   )IdentityOperator)sympy.physics.quantumr   
isinstancer   )selfotherr   s      r   __mul__zDagger.__mul__Y   s<    ::::::e-.. 	K4r   N)__name__
__module____qualname____doc__r   r    r   r   r   r      s?        B BH& & &         r   c                 H    d|                     | j        d                   z  S )Nz
Dagger(%s)r   )_printargs)abs     r   <lambda>r#   a   s    ,!&)1D1D"D r   N)
r   
sympy.corer   r   $sympy.functions.elementary.complexesr   __all__r   r   
_sympyreprr   r   r   <module>r(      s                      8 8 8 8 8 8 
S  S  S  S  S W S  S  S j  DD   r   