+
    
þÎjt6  ã                   óÔ   € ^ RI Ht ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ R	IHtHtHtHtHt R
R.t ! R R
]4      tR tR t ! R R]4      tR tR tR tR# )é    )ÚExpr)ÚSymbol)Úsympify)ÚMatrix)Ú
prettyForm)ÚTuple)Úis_sequence)ÚDagger)Únumpy_ndarrayÚscipy_sparse_matrixÚto_sympyÚto_numpyÚto_scipy_sparseÚQuantumErrorÚQExprc                   ó   € ] tR t^tRtR# )r   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    ÚQ/opt/data/home/.local/lib/python3.14/site-packages/sympy/physics/quantum/qexpr.pyr   r      s   † Ûr   c                ó*   € \        \        V 4      4      # )af  Convert elements of a sequence to standard form.

This is like sympify, but it performs special logic for arguments passed
to QExpr. The following conversions are done:

* (list, tuple, Tuple) => _qsympify_sequence each element and convert
  sequence to a Tuple.
* basestring => Symbol
* Matrix => Matrix
* other => sympify

Strings are passed to Symbol, not sympify to make sure that variables like
'pi' are kept as Symbols, not the SymPy built-in number subclasses.

Examples
========

>>> from sympy.physics.quantum.qexpr import _qsympify_sequence
>>> _qsympify_sequence((1,2,[3,4,[1,]]))
(1, 2, (3, 4, (1,)))

)ÚtupleÚ__qsympify_sequence_helper)Úseqs   &r   Ú_qsympify_sequencer      s   € ô0 Ô+¨CÓ0Ó1Ð1r   c                ó,  € \        V 4      '       gE   \        V \        4      '       d   V # \        V \        4      '       d   \	        V 4      # \        V 4      # \        V \        4      '       d   V # V  Uu. uF  p\        V4      NK  	  pp\        V!  # u upi )zL
Helper function for _qsympify_sequence
This function does the actual work.
)	r	   Ú
isinstancer   Ústrr   r   r   r   r   )r   ÚitemÚresults   &  r   r   r   8   s‚   € ô �s×ÒÜ�cœ6×"Ò"ØˆJÜ˜œS×!Ò!Ü˜#“;Ðä˜3“<Ðô �#”u×ÒØˆ
ñ <?Ó?¹3°4Ô(¨Ö.¹3€FÐ?ä�&‰>Ðùò @s   Á2Bc                   ó  a € ] tR t^Ut o RtR"tRtRtR t]	R 4       t
]R 4       t]R 4       t]	R 4       tR	 t]	R
 4       t]	R 4       tR tR tR tR tR#R ltR tR tR tR tR tR tR tR tR tR t R t!R t"RR/R lt#R  t$R!t%V t&R# )$r   z>A base class for all quantum object like operators and states.FÚ c                óü   € V P                   ! V3/ VB p\        V4      ^ 8X  d+   V P                   ! \        V P                  4       4      3/ VB p\        P
                  ! V .VO5!  pV P                  V4      Vn        V# )a’  Construct a new quantum object.

Parameters
==========

args : tuple
    The list of numbers or parameters that uniquely specify the
    quantum object. For a state, this will be its symbol or its
    set of quantum numbers.

Examples
========

>>> from sympy.physics.quantum.qexpr import QExpr
>>> q = QExpr(0)
>>> q
0
>>> q.label
(0,)
>>> q.hilbert_space
H
>>> q.args
(0,)
>>> q.is_commutative
False
)Ú
_eval_argsÚlenr   Údefault_argsr   Ú__new__Ú_eval_hilbert_spaceÚhilbert_space)ÚclsÚargsÚkwargsÚinsts   &*, r   r+   ÚQExpr.__new__d   sn   € ð: �~Š~˜dÑ- fÑ-ˆÜˆt‹9˜Œ>Ø—>’>¤%¨×(8Ñ(8Ó(:Ó";ÑF¸vÑFˆDÜ�|Š|˜CÐ' $Ó'ˆà ×4Ñ4°TÓ:ˆÔØˆr   c                óF   € \         P                  ! V .VO5/ VB pWn        V# )ad  Create new instance of this class with hilbert_space and args.

This is used to bypass the more complex logic in the ``__new__``
method in cases where you already have the exact ``hilbert_space``
and ``args``. This should be used when you are positive these
arguments are valid, in their final, proper form and want to optimize
the creation of the object.
)r   r+   r-   )r.   r-   r/   Úold_assumptionsÚobjs   &&*, r   Ú_new_rawargsÚQExpr._new_rawargs‰   s'   € ô �lŠl˜3Ð9 Ò9¨Ñ9ˆØ)ÔØˆ
r   c                óž   € \        V P                  4      ^ 8X  d)   V P                  \        V P	                  4       4      4      # V P                  # )zåThe label is the unique set of identifiers for the object.

Usually, this will include all of the information about the state
*except* the time (in the case of time-dependent objects).

This must be a tuple, rather than a Tuple.
)r)   r/   r(   Úlistr*   ©Úselfs   &r   ÚlabelÚQExpr.labelœ   s;   € ô ˆt�y‰y‹>˜QÔØ—?‘?¤4¨×(9Ñ(9Ó(;Ó#<Ó=Ð=à—9‘9Ðr   c                ó   € R # )Tr   r:   s   &r   Úis_symbolicÚQExpr.is_symbolicª   s   € ár   c                ó   € \        R4      h)a  If no arguments are specified, then this will return a default set
of arguments to be run through the constructor.

NOTE: Any classes that override this MUST return a tuple of arguments.
Should be overridden by subclasses to specify the default arguments for kets and operators
z$No default arguments for this class!©ÚNotImplementedErrorr:   s   &r   r*   ÚQExpr.default_args®   s   € ô "Ð"HÓIÐIr   c                ó¾   € \         P                  ! V 4      pVf   \         P                  ! \        V 4      p\	        V\
        4      '       d   V P                  Vn        V# ©N)r   Ú_eval_adjointr+   r
   r!   r   r-   )r;   r5   s   & r   rG   ÚQExpr._eval_adjoint¼   sG   € Ü× Ò  Ó&ˆØŠ;Ü—,’,œv tÓ,ˆCÜ�cœ5×!Ò!Ø $× 2Ñ 2ˆCÔØˆ
r   c                ó   € \        V4      # )zbProcess the args passed to the __new__ method.

This simply runs args through _qsympify_sequence.
)r   )r.   r/   s   &&r   r(   ÚQExpr._eval_argsÄ   s   € ô " $Ó'Ð'r   c                ó   € ^ RI Hp V! 4       # )z:Compute the Hilbert space instance from the args.
        )ÚHilbertSpace)Úsympy.physics.quantum.hilbertrL   )r.   r/   rL   s   && r   r,   ÚQExpr._eval_hilbert_spaceÌ   s   € õ 	?Ù‹~Ðr   c                ó€   € . pV F&  pVP                  VP                  ! V.VO5!  4       K(  	  VP                  V4      # rF   )ÚappendÚ_printÚjoin)r;   r   ÚsepÚprinterr/   r$   r#   s   &&&&*  r   Ú_print_sequenceÚQExpr._print_sequenceÙ   s:   € ØˆÛˆDØ�M‰M˜'Ÿ.š.¨Ð5°Ó5Ö6ñ à�x‰x˜ÓÐr   c           	     óà   € VP                   ! V^ ,          .VO5!  pVR,           FE  p\        VP                  V4      !  p\        VP                  VP                   ! V.VO5!  4      !  pKG  	  V# )r   :é   NN)rQ   r   Úright)r;   r   rS   rT   r/   Úpformr#   s   &&&&*  r   Ú_print_sequence_prettyÚQExpr._print_sequence_prettyß   sd   € Ø—’˜s 1�vÐ-¨Ó-ˆØ˜—G�GˆDÜ §¡¨CÓ 0Ñ1ˆEÜ §¡¨G¯NªN¸4Ð,GÀ$Ó,GÓ HÑIŠEñ ð ˆr   c                ó  € \        VP                  R VP                  4       ,          4      !  p\        VP                  R VP                  4       ,          4      !  p\        VP	                  V4      R\         P
                  / # )Ú Úbinding)r   ÚleftÚwidthrY   ÚbelowÚPOW)r;   ÚaÚbÚtopÚbots   &&&  r   Ú_print_subscript_prettyÚQExpr._print_subscript_prettyè   sX   € Ü˜!Ÿ&™&  Q§W¡W£Y¥Ó/Ñ0ˆÜ˜!Ÿ'™' # a§g¡g£i¥-Ó0Ñ1ˆÜ°3·9±9¸S³>ÐB¤*§.¡.ÑBÐBr   c                ó   € W,          # rF   r   )r;   rd   re   s   &&&r   Ú_print_superscript_prettyÚQExpr._print_superscript_prettyí   s	   € Ø�tˆr   c                ó4   € \        VP                  W#R 7      !  # ))r`   rY   )r   Úparens)r;   rZ   r`   rY   s   &&&&r   Ú_print_parens_prettyÚQExpr._print_parens_prettyð   s   € Ü˜5Ÿ<™<¨T˜<Ó?Ñ@Ð@r   c                óV   € V P                   ! V P                  V P                  V.VO5!  # )zÙPrints the label of the QExpr

This method prints self.label, using self._label_separator to separate
the elements. This method should not be overridden, instead, override
_print_contents to change printing behavior.
©rU   r<   Ú_label_separator©r;   rT   r/   s   &&*r   Ú_print_labelÚQExpr._print_labelõ   s0   € ð ×#Ò#Ø�J‰J˜×-Ñ-¨wð
Ø9=ó
ð 	
r   c                óB   € V P                   ! V P                  R V.VO5!  # )Ú,)rU   r<   rt   s   &&*r   Ú_print_label_reprÚQExpr._print_label_repr   s(   € Ø×#Ò#Ø�J‰J˜˜Wð
Ø'+ó
ð 	
r   c                óV   € V P                   ! V P                  V P                  V.VO5!  # rF   )r[   r<   rs   rt   s   &&*r   Ú_print_label_prettyÚQExpr._print_label_pretty  s.   € Ø×*Ò*Ø�J‰J˜×-Ñ-¨wð
Ø9=ó
ð 	
r   c                óV   € V P                   ! V P                  V P                  V.VO5!  # rF   rr   rt   s   &&*r   Ú_print_label_latexÚQExpr._print_label_latex
  s.   € Ø×#Ò#Ø�J‰J˜×-Ñ-¨wð
Ø9=ó
ð 	
r   c                ó*   € V P                   ! V.VO5!  # )a+  Printer for contents of QExpr

Handles the printing of any unique identifying contents of a QExpr to
print as its contents, such as any variables or quantum numbers. The
default is to print the label, which is almost always the args. This
should not include printing of any brackets or parentheses.
)ru   rt   s   &&*r   Ú_print_contentsÚQExpr._print_contents  s   € ð × Ò  Ð0¨4Ó0Ð0r   c                ó*   € V P                   ! V.VO5!  # rF   )r|   rt   s   &&*r   Ú_print_contents_prettyÚQExpr._print_contents_pretty  s   € Ø×'Ò'¨Ð7°$Ó7Ð7r   c                ó*   € V P                   ! V.VO5!  # rF   )r   rt   s   &&*r   Ú_print_contents_latexÚQExpr._print_contents_latex  s   € Ø×&Ò& wÐ6°Ó6Ð6r   c                ó*   € V P                   ! V.VO5!  # )aŸ  Default printing behavior of QExpr objects

Handles the default printing of a QExpr. To add other things to the
printing of the object, such as an operator name to operators or
brackets to states, the class should override the _print/_pretty/_latex
functions directly and make calls to _print_contents where appropriate.
This allows things like InnerProduct to easily control its printing the
printing of contents.
)r‚   rt   s   &&*r   Ú	_sympystrÚQExpr._sympystr#  s   € ð ×#Ò# GÐ3¨dÓ3Ð3r   c                ój   € V P                   P                  pV P                  ! V.VO5!  pV: R V: R2# ©Ú(Ú))Ú	__class__r   ry   )r;   rT   r/   Ú	classnamer<   s   &&*  r   Ú
_sympyreprÚQExpr._sympyrepr/  s1   € Ø—N‘N×+Ñ+ˆ	Ø×&Ò& wÐ6°Ó6ˆÛ$£eÐ,Ð,r   c                ó.   € V P                   ! V.VO5!  pV# rF   )r…   )r;   rT   r/   rZ   s   &&* r   Ú_prettyÚQExpr._pretty4  s   € Ø×+Ò+¨GÐ;°dÓ;ˆØˆr   c                ó*   € V P                   ! V.VO5!  # rF   )rˆ   rt   s   &&*r   Ú_latexÚQExpr._latex8  s   € Ø×)Ò)¨'Ð9°DÓ9Ð9r   c                ó   € \        R 4      h)z)This object does not have a default basisrB   )r;   Úoptionss   &,r   Ú_represent_default_basisÚQExpr._represent_default_basis?  s   € Ü!Ð"MÓNÐNr   ÚbasisNc               ó–   € Vf   V P                   ! R/ VB pM\        V RV3/ VB pVP                  RR4      pV P                  W44      pV# )a   Represent this object in a given basis.

This method dispatches to the actual methods that perform the
representation. Subclases of QExpr should define various methods to
determine how the object will be represented in various bases. The
format of these methods is::

    def _represent_BasisName(self, basis, **options):

Thus to define how a quantum object is represented in the basis of
the operator Position, you would define::

    def _represent_Position(self, basis, **options):

Usually, basis object will be instances of Operator subclasses, but
there is a chance we will relax this in the future to accommodate other
types of basis sets that are not associated with an operator.

If the ``format`` option is given it can be ("sympy", "numpy",
"scipy.sparse"). This will ensure that any matrices that result from
representing the object are returned in the appropriate matrix format.

Parameters
==========

basis : Operator
    The Operator whose basis functions will be used as the basis for
    representation.
options : dict
    A dictionary of key/value pairs that give options and hints for
    the representation, such as the number of basis functions to
    be used.
Ú
_representÚformatÚsympyr   )r�   Údispatch_methodÚgetÚ_format_represent)r;   rŸ   rœ   r$   r¢   s   &$,  r   r¡   ÚQExpr._representB  sW   € ðD Š=Ø×2Ò2Ñ=°WÑ=‰Fä$ T¨<¸ÑJÀ'ÑJˆFð —‘˜X wÓ/ˆØ×'Ñ'¨Ó7ˆØˆr   c                óö   € VR 8X  d"   \        V\        4      '       g   \        V4      # VR8X  d"   \        V\        4      '       g   \	        V4      # VR8X  d"   \        V\
        4      '       g   \        V4      # V# )r£   Únumpyzscipy.sparse)r!   r   r   r   r   r   r   )r;   r$   r¢   s   &&&r   r¦   ÚQExpr._format_representn  sf   € Ø�WÔ¤Z°¼×%?Ò%?Ü˜FÓ#Ð#Ø�wÔ¤z°&¼-×'HÒ'HÜ˜FÓ#Ð#Ø�~Ô%Ü˜vÔ':×;Ò;Ü" 6Ó*Ð*àˆr   r   )r-   rŽ   )'r   r   r   r   Ú__doc__Ú	__slots__Úis_commutativers   r+   Úclassmethodr6   Úpropertyr<   r?   r*   rG   r(   r,   rU   r[   rh   rk   ro   ru   ry   r|   r   r‚   r…   rˆ   r‹   r“   r–   r™   r�   r¡   r¦   r   Ú__classdictcell__)Ú__classdict__s   @r   r   r   U   s  ø‡ € ÙHð $€Ià€Nð Ðò#ðJ ñó ðð$ ñó ðð ñó ðð ñJó ðJòð ñ(ó ð(ð ñó ðò òòCò
ôAò
	
ò
ò

ò

ò1ò8ò7ò

4ò-ò
ò:òOð* $ô *÷X	ð 	r   c                óB   € V P                  4       w  r\        V4      pW3# )z1Split into commutative and non-commutative parts.)Úargs_cncr9   )ÚeÚc_partÚnc_parts   &  r   Úsplit_commutative_partsr·   z  s    € à—j‘j“l�O€FÜ�&‹\€FØˆ?Ðr   c                óª   € . p. pV P                    F=  p\        V\        4      '       g   VP                  V4       K,  VP                  V4       K?  	  W3# )z=Split an expression into Expr and noncommutative QExpr parts.)r/   r!   r   rP   )r´   Ú	expr_partÚ
qexpr_partÚargs   &   r   Úsplit_qexpr_partsr¼   �  sN   € à€IØ€JØ�vŒvˆÜ˜#œu×%Ò%Ø×Ñ˜SÖ!à×Ñ˜cÖ"ñ	 ð
 Ð Ð r   c                óæ   € V: RVP                   P                  : 2p\        W4      '       d   \        W4      pV! V3/ VB pVe   V# \	        V P                   P                  : RV: RV: 24      h)z)Dispatch a method to the proper handlers.Ú_Ú.z cannot handle: )r‘   r   ÚhasattrÚgetattrrC   )r;   Úbasenamer»   rœ   Úmethod_nameÚfr$   s   &&&,   r   r¤   r¤   �  sh   € ã% s§}¡}×'=Ó'=Ð>€KÜˆt×!Ò!Ü�DÓ&ˆá�3Ñ"˜'Ñ"ˆØÒØˆMÜ
à	�‰×	 Ô	 £(ªCð	1óð r   N)Úsympy.core.exprr   Úsympy.core.symbolr   Úsympy.core.sympifyr   Úsympy.matrices.denser   Ú sympy.printing.pretty.stringpictr   Úsympy.core.containersr   Úsympy.utilities.iterablesr	   Úsympy.physics.quantum.daggerr
   Ú!sympy.physics.quantum.matrixutilsr   r   r   r   r   Ú__all__Ú	Exceptionr   r   r   r   r·   r¼   r¤   r   r   r   Ú<module>rÐ      sj   ðÝ  Ý $Ý &Ý 'Ý 7Ý 'Ý 1å /÷õ ð Øð€ô	�9ô 	ò2ò6ô:bˆDô bòJ	ò	!ôr   