Ë
    7^(hÏ  ã                   ó`   — d 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
 dgZ G d„ de«      Zy	)
zSymbolic inner product.é    )ÚExpr)Ú
NumberKind)Ú	conjugate)Ú
prettyForm)ÚDaggerÚInnerProductc                   ób   — e Zd ZdZeZdZd„ Zed„ «       Z	ed„ «       Z
d„ Zd„ Zd„ Zd	„ Zd
„ Zd„ Zy)r   aT  An unevaluated inner product between a Bra and a Ket [1].

    Parameters
    ==========

    bra : BraBase or subclass
        The bra on the left side of the inner product.
    ket : KetBase or subclass
        The ket on the right side of the inner product.

    Examples
    ========

    Create an InnerProduct and check its properties:

        >>> from sympy.physics.quantum import Bra, Ket
        >>> b = Bra('b')
        >>> k = Ket('k')
        >>> ip = b*k
        >>> ip
        <b|k>
        >>> ip.bra
        <b|
        >>> ip.ket
        |k>

    In quantum expressions, inner products will be automatically
    identified and created::

        >>> b*k
        <b|k>

    In more complex expressions, where there is ambiguity in whether inner or
    outer products should be created, inner products have high priority::

        >>> k*b*k*b
        <b|k>*|k><b|

    Notice how the inner product <b|k> moved to the left of the expression
    because inner products are commutative complex numbers.

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Inner_product
    Tc                 ó¬   — ddl m}m} t        ||«      st	        d|z  «      ‚t        ||«      st	        d|z  «      ‚t        j                  | ||«      }|S )Nr   )ÚKetBaseÚBraBasez"KetBase subclass expected, got: %rz"BraBase subclass expected, got: %r)Úsympy.physics.quantum.stater   r   Ú
isinstanceÚ	TypeErrorr   Ú__new__)ÚclsÚbraÚketr   r   Úobjs         ú`/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/physics/quantum/innerproduct.pyr   zInnerProduct.__new__J   sU   € ÷ 	AÜ˜#˜wÔ'ÜÐ@À3ÑFÓGÐGÜ˜#˜wÔ'ÜÐ@À3ÑFÓGÐGÜ�l‰l˜3  SÓ)ˆØˆ
ó    c                 ó    — | j                   d   S )Nr   ©Úargs©Úselfs    r   r   zInnerProduct.braU   ó   € à�y‰y˜‰|Ðr   c                 ó    — | j                   d   S )Né   r   r   s    r   r   zInnerProduct.ketY   r   r   c                 óf   — t        t        | j                  «      t        | j                  «      «      S ©N)r   r   r   r   r   s    r   Ú_eval_conjugatezInnerProduct._eval_conjugate]   s!   € ÜœF 4§8¡8Ó,¬f°T·X±XÓ.>Ó?Ð?r   c                 ó¬   — | j                   j                  ›d |j                  | j                  g|¢­Ž ›d |j                  | j                  g|¢­Ž ›d�S )Nú(ú,ú))Ú	__class__Ú__name__Ú_printr   r   )r   Úprinterr   s      r   Ú
_sympyreprzInnerProduct._sympyrepr`   sH   € Ø"Ÿn™n×5Ó5ØˆG�N‰N˜4Ÿ8™8Ð+ dÔ+¨^¨W¯^©^¸D¿H¹HÐ-LÀtÔ-LðNð 	Nr   c                 óˆ   — |j                  | j                  «      }|j                  | j                  «      }|d d ›d|dd  ›�S )Néÿÿÿÿú|r   )r(   r   r   )r   r)   r   ÚsbraÚskets        r   Ú	_sympystrzInnerProduct._sympystrd   s=   € Ø�~‰~˜dŸh™hÓ'ˆØ�~‰~˜dŸh™hÓ'ˆØ˜s š) T¨!¨"¡XÐ.Ð.r   c                 ó  —  | j                   j                  |g|¢­Ž } | j                  j                  |g|¢­Ž }t        |j	                  «       |j	                  «       «      }|j
                  }| j                   j                  ||«      \  }}| j                  j                  ||«      \  }	}
t        |j                  |«      Ž }t        |j                  |	«      Ž }t        |j                  |«      Ž }t        |j                  |
«      Ž }|S r    )
r   Ú_print_contents_prettyr   ÚmaxÚheightÚ_use_unicodeÚ_pretty_bracketsr   ÚleftÚright)r   r)   r   r   r   r4   Úuse_unicodeÚlbracketÚ_ÚcbracketÚrbracketÚpforms               r   Ú_prettyzInnerProduct._prettyi   sá   € à-ˆd�h‰h×-Ñ-¨gÐ=¸Ò=ˆØ-ˆd�h‰h×-Ñ-¨gÐ=¸Ò=ˆä�S—Z‘Z“\ 3§:¡:£<Ó0ˆØ×*Ñ*ˆØ—h‘h×/Ñ/°¸ÓD‰ˆ�!Ø!ŸX™X×6Ñ6°v¸{ÓKÑˆ�(ä˜CŸH™H XÓ.Ð/ˆÜ˜EŸK™K¨Ó1Ð2ˆÜ˜EŸK™K¨Ó,Ð-ˆÜ˜EŸK™K¨Ó1Ð2ˆØˆr   c                 ó†   —  | j                   j                  |g|¢­Ž } |j                  | j                  g|¢­Ž }d|›d|›�S )Nz\left\langle z	 \right. )r   Ú_print_contents_latexr(   r   )r   r)   r   Ú	bra_labelr   s        r   Ú_latexzInnerProduct._latexy   sA   € Ø2�D—H‘H×2Ñ2°7ÐB¸TÒBˆ	Øˆg�n‰n˜TŸX™XÐ-¨Ò-‰Ú09¹3Ð?Ð?r   c                 ó*  — 	  | j                   j                  | j                  fi |¤Ž}|�|S | S # t        $ rZ 	 t	         | j                  j
                  j                  | j                   j
                  fi |¤Ž«      }n# t        $ r d }Y nw xY wY Œhw xY wr    )r   Ú_eval_innerproductr   ÚNotImplementedErrorr   Údual)r   ÚhintsÚrs      r   ÚdoitzInnerProduct.doit~   s’   € ð	Ø+�—‘×+Ñ+¨D¯H©HÑ>¸Ñ>ˆAð ˆ=ØˆHØˆøô #ò 	ðÜØ4�D—H‘H—M‘M×4Ñ4°T·X±X·]±]ÑLÀeÑLó‘øô 'ò Ø’ðüð	ús3   ‚'/ ¯	B¹AA>Á=BÁ>BÂ	BÂBÂBÂBN)r'   Ú
__module__Ú__qualname__Ú__doc__r   ÚkindÚ
is_complexr   Úpropertyr   r   r!   r*   r0   r?   rC   rJ   © r   r   r   r      sb   „ ñ-ð^ €Dà€Jò	ð ñó ðð ñó ðò@òNò/ò
ò @ó
r   N)rM   Úsympy.core.exprr   Úsympy.core.kindr   Ú$sympy.functions.elementary.complexesr   Ú sympy.printing.pretty.stringpictr   Úsympy.physics.quantum.daggerr   Ú__all__r   rQ   r   r   ú<module>rX      s1   ðÙ å  Ý &Ý :Ý 7Ý /ð ð€ôt�4õ tr   