§
    OŠtj[%  ã                   óT  — d Z ddlmZmZmZmZmZmZmZ ddl	m
Z
 ddlmZmZmZ ddlmZmZmZmZmZmZmZ ddgZe eeef¦  «        e eeef¦  «        e eeef¦  «        ee
e eeeef¦  «        eeeeiZd„ e                     ¦   «         D ¦   «         Zd	„ Zd
„ Zd„ Zd„ Zd„ Z d„ Z!dS )a   A module for mapping operators to their corresponding eigenstates
and vice versa

It contains a global dictionary with eigenstate-operator pairings.
If a new state-operator pair is created, this dictionary should be
updated as well.

It also contains functions operators_to_state and state_to_operators
for mapping between the two. These can handle both classes and
instances of operators and states. See the individual function
descriptions for details.

TODO List:
- Update the dictionary with a complete list of state-operator pairs
é    )ÚXOpÚYOpÚZOpÚXKetÚPxOpÚPxKetÚPositionKet3D)ÚOperator)Ú	StateBaseÚBraBaseÚKet)ÚJxOpÚJyOpÚJzOpÚJ2OpÚJxKetÚJyKetÚJzKetÚoperators_to_stateÚstate_to_operatorsc                 ó   — i | ]\  }}||“Œ	S © r   )Ú.0ÚkÚvs      ú_/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/physics/quantum/operatorset.pyú
<dictcomp>r   ,   s   € Ð5Ð5Ð5‘t�q˜!ˆa�Ð5Ð5Ð5ó    c                 ó˜  — t          | t          t          f¦  «        s$t          | t          ¦  «        st	          d¦  «        ‚t          | t          ¦  «        rë| D ];}t          |t          ¦  «        s$t          |t          ¦  «        st	          d¦  «        ‚Œ<t          | ¦  «        }|t          v rS	 d„ |D ¦   «         }t          t          |         t          |¦  «        fi |¤Ž}n# t          $ r t          |         }Y nw xY w|S d„ |D ¦   «         }t          |¦  «        }|t          v rt          t          |         |fi |¤Ž}nd}|S | t          v rD	  | ¦   «         }t          t          |          |fi |¤Ž}n# t          $ r t          |          }Y nw xY w|S t          | ¦  «        t          v r&t          t          t          | ¦  «                 | fi |¤ŽS dS )a.   Returns the eigenstate of the given operator or set of operators

    A global function for mapping operator classes to their associated
    states. It takes either an Operator or a set of operators and
    returns the state associated with these.

    This function can handle both instances of a given operator or
    just the class itself (i.e. both XOp() and XOp)

    There are multiple use cases to consider:

    1) A class or set of classes is passed: First, we try to
    instantiate default instances for these operators. If this fails,
    then the class is simply returned. If we succeed in instantiating
    default instances, then we try to call state._operators_to_state
    on the operator instances. If this fails, the class is returned.
    Otherwise, the instance returned by _operators_to_state is returned.

    2) An instance or set of instances is passed: In this case,
    state._operators_to_state is called on the instances passed. If
    this fails, a state class is returned. If the method returns an
    instance, that instance is returned.

    In both cases, if the operator class or set does not exist in the
    state_mapping dictionary, None is returned.

    Parameters
    ==========

    arg: Operator or set
         The class or instance of the operator or set of operators
         to be mapped to a state

    Examples
    ========

    >>> from sympy.physics.quantum.cartesian import XOp, PxOp
    >>> from sympy.physics.quantum.operatorset import operators_to_state
    >>> from sympy.physics.quantum.operator import Operator
    >>> operators_to_state(XOp)
    |x>
    >>> operators_to_state(XOp())
    |x>
    >>> operators_to_state(PxOp)
    |px>
    >>> operators_to_state(PxOp())
    |px>
    >>> operators_to_state(Operator)
    |psi>
    >>> operators_to_state(Operator())
    |psi>
    z%Argument is not an Operator or a set!zSet is not all Operators!c                 ó"   — g | ]} |¦   «         ‘ŒS r   r   )r   Úops     r   ú
<listcomp>z&operators_to_state.<locals>.<listcomp>t   s   € Ð3Ð3Ð3¨  ¡¤Ð3Ð3Ð3r   c                 ó,   — g | ]}t          |¦  «        ‘ŒS r   )Útype)r   Úos     r   r"   z&operators_to_state.<locals>.<listcomp>{   s   € Ð(Ð(Ð(˜q•4˜‘7”7Ð(Ð(Ð(r   N)	Ú
isinstancer
   ÚsetÚ
issubclassÚNotImplementedErrorÚ	frozensetÚ
op_mappingÚ
_get_stater$   )	Ú	operatorsÚoptionsÚsÚopsÚop_instancesÚretÚtmpÚclassesÚop_instances	            r   r   r   /   s  € õl �y¥8­S /Ñ2Ô2ð KµjÀÍHÑ6UÔ6Uð KÝ!Ð"IÑJÔJÐJå�)�SÑ!Ô!ð (Øð 	Gð 	GˆAÝ˜q¥(Ñ+Ô+ð GÝ  ¥HÑ-Ô-ðGå)Ð*EÑFÔFÐFøå˜	Ñ"Ô"ˆà•*ÐÐð&Ø3Ð3¨sÐ3Ñ3Ô3�Ý ¥¨C¤µ#°lÑ2CÔ2CÐOÐOÀwÐOÐO��øÝ&ð &ð &ð &Ý  ”o���ð&øøøð ˆJà(Ð( CÐ(Ñ(Ô(ˆCÝ ‘n”nˆGà�*Ð$Ð$Ý ¥¨GÔ!4°cÐEÐE¸WÐEÐE��à�àˆJà�
Ð"Ð"ð,Ø'˜i™kœk�Ý ¥¨IÔ!6¸ÐOÐOÀwÐOÐO��øÝ&ð ,ð ,ð ,Ý  Ô+���ð,øøøð ˆJÝ�)‰_Œ_¥
Ð*Ð*Ý�j­¨i©¬Ô9¸9ÐPÐPÈÐPÐPÐPà�4s$   Â-2C  Ã C:Ã9C:Å#E/ Å/F	ÆF	c           	      ó0  — t          | t          ¦  «        s$t          | t          ¦  «        st          d¦  «        ‚| t          v r]t          | ¦  «        }	 t          |t          t          |          ¦  «        fi |¤Ž}�nŽ# t          t          f$ r t          |          }Y �nmw xY wt          | ¦  «        t          v r5t          | t          t          t          | ¦  «                 ¦  «        fi |¤Ž}�nt          | t          ¦  «        rV|                      ¦   «         t          v r;t          | t          t          |                      ¦   «                  ¦  «        ¦  «        }n³t          | t          ¦  «        rœ|                      ¦   «         t          v r�t          | ¦  «        }	 t          |t          t          |                      ¦   «                  ¦  «        ¦  «        }n8# t          t          f$ r" t          |                      ¦   «                  }Y nw xY wd}t          |¦  «        S )a`   Returns the operator or set of operators corresponding to the
    given eigenstate

    A global function for mapping state classes to their associated
    operators or sets of operators. It takes either a state class
    or instance.

    This function can handle both instances of a given state or just
    the class itself (i.e. both XKet() and XKet)

    There are multiple use cases to consider:

    1) A state class is passed: In this case, we first try
    instantiating a default instance of the class. If this succeeds,
    then we try to call state._state_to_operators on that instance.
    If the creation of the default instance or if the calling of
    _state_to_operators fails, then either an operator class or set of
    operator classes is returned. Otherwise, the appropriate
    operator instances are returned.

    2) A state instance is returned: Here, state._state_to_operators
    is called for the instance. If this fails, then a class or set of
    operator classes is returned. Otherwise, the instances are returned.

    In either case, if the state's class does not exist in
    state_mapping, None is returned.

    Parameters
    ==========

    arg: StateBase class or instance (or subclasses)
         The class or instance of the state to be mapped to an
         operator or set of operators

    Examples
    ========

    >>> from sympy.physics.quantum.cartesian import XKet, PxKet, XBra, PxBra
    >>> from sympy.physics.quantum.operatorset import state_to_operators
    >>> from sympy.physics.quantum.state import Ket, Bra
    >>> state_to_operators(XKet)
    X
    >>> state_to_operators(XKet())
    X
    >>> state_to_operators(PxKet)
    Px
    >>> state_to_operators(PxKet())
    Px
    >>> state_to_operators(PxBra)
    Px
    >>> state_to_operators(XBra)
    X
    >>> state_to_operators(Ket)
    O
    >>> state_to_operators(Bra)
    O
    zArgument is not a state!N)r&   r   r(   r)   Ústate_mappingÚ_make_defaultÚ_get_opsÚ	_make_setÚ	TypeErrorr$   r   Ú
dual_class)Ústater.   Ú
state_instr2   s       r   r   r   “   s  € õv �u�iÑ(Ô(ð >­J°u½iÑ,HÔ,Hð >Ý!Ð"<Ñ=Ô=Ð=à•ÐÐÝ" 5Ñ)Ô)ˆ
ð	'Ý˜:Ý$¥]°5Ô%9Ñ:Ô:ðGð GØ>EðGð GˆC‰Cøå#¥YÐ/ð 	'ð 	'ð 	'Ý Ô&ˆCˆC‰Cð	'øøøå	ˆe‰Œ�Ð	%Ð	%Ý�uÝ ¥­t°E©{¬{Ô!;Ñ<Ô<ðIð IØ@GðIð Iˆ‰å	�E�7Ñ	#Ô	#ð ¨×(8Ò(8Ñ(:Ô(:½mÐ(KÐ(KÝ�uÝ ¥¨u×/?Ò/?Ñ/AÔ/AÔ!BÑCÔCñEô Eˆˆå	�E�7Ñ	#Ô	#ð ¨×(8Ò(8Ñ(:Ô(:½mÐ(KÐ(KÝ" 5Ñ)Ô)ˆ
ð	4Ý˜:Ý$¥]°5×3CÒ3CÑ3EÔ3EÔ%FÑGÔGñIô IˆCˆCøå#¥YÐ/ð 	4ð 	4ð 	4Ý × 0Ò 0Ñ 2Ô 2Ô3ˆCˆCˆCð	4øøøð ˆå�S‰>Œ>Ðs$   Á&A; Á;BÂBÆ:G Ç0HÈHc                 óB   — 	  | ¦   «         }n# t           $ r | }Y nw xY w|S ©N)r;   )Úexprr2   s     r   r8   r8   ë   s?   € ðØˆd‰fŒfˆˆøÝð ð ð Øˆˆˆðøøøð €Js   ‚
 �›c                 ód   — 	  | j         |fi |¤Ž}n# t          $ r t          | ¦  «        }Y nw xY w|S r@   )Ú_operators_to_stater)   r8   )Ústate_classr0   r.   r2   s       r   r,   r,   ÷   sV   € ð)Ø-ˆkÔ-¨cÐ=Ð=°WÐ=Ð=ˆˆøÝð )ð )ð )Ý˜KÑ(Ô(ˆˆˆð)øøøð €Js   ‚ ‘-¬-c                 ó<  — 	  | j         |fi |¤Ž}n[# t          $ rN t          |t          t          t
          f¦  «        rt	          d„ |D ¦   «         ¦  «        }nt          |¦  «        }Y nw xY wt          |t          ¦  «        rt          |¦  «        dk    r|d         S |S )Nc              3   ó4   K  — | ]}t          |¦  «        V — Œd S r@   )r8   )r   Úxs     r   ú	<genexpr>z_get_ops.<locals>.<genexpr>	  s*   è è € Ð=Ð=¨Q� aÑ(Ô(Ð=Ð=Ð=Ð=Ð=Ð=r   é   r   )Ú_state_to_operatorsr)   r&   r'   Útupler*   r8   Úlen)r>   Ú
op_classesr.   r2   s       r   r9   r9     s´   € ð,Ø,ˆjÔ,¨ZÐCÐC¸7ÐCÐCˆˆøÝð ,ð ,ð ,Ý�j¥3­­yÐ"9Ñ:Ô:ð 	,ÝÐ=Ð=°*Ð=Ñ=Ô=Ñ=Ô=ˆCˆCå 
Ñ+Ô+ˆCøøð	,øøøõ �#•sÑÔð ¥ C¡¤¨A¢ Ø�1Œvˆà€Js   ‚ ‘AA)Á(A)c                 óh   — t          | t          t          t          f¦  «        rt	          | ¦  «        S | S r@   )r&   rK   Úlistr*   r'   )r0   s    r   r:   r:     s+   € Ý�#��t¥YÐ/Ñ0Ô0ð Ý�3‰xŒxˆàˆ
r   N)"Ú__doc__Úsympy.physics.quantum.cartesianr   r   r   r   r   r   r	   Úsympy.physics.quantum.operatorr
   Úsympy.physics.quantum.stater   r   r   Úsympy.physics.quantum.spinr   r   r   r   r   r   r   Ú__all__r*   r7   Úitemsr+   r   r   r8   r,   r9   r:   r   r   r   ú<module>rW      sõ  ððð ð <ð <ð <ð <ð <ð <ð <ð <ð <ð <ð <ð <ð <ð <ð <ð <ð <ð <à 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?ð/ð /ð /ð /ð /ð /ð /ð /ð /ð /ð /ð /ð /ð /ð /ð /ð /ð /ð Øð€ð ˜˜ D¨$ <Ñ0Ô0Ø˜˜ D¨$ <Ñ0Ô0Ø˜˜ D¨$ <Ñ0Ô0Ø�xØ  ¨C°°c¨?Ñ!;Ô!;Ø˜Ø˜ð€ð 6Ð5˜}×2Ò2Ñ4Ô4Ð5Ñ5Ô5€
ðað að aðHUð Uð Uðp	ð 	ð 	ðð ð ðð ð ð"ð ð ð ð r   