K i\dZddlmZddlZddlmZddlmZddlm Z ddl m Z m Z ddl mZdd l mZdd lmZdd lmZdd lmZdd lmZddlmZmZddlmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z%m&Z&m'Z'ddl(m)Z)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0gdZ1da2dZ3dZ4dZ5dZ6Gdde%Z7Gd d!e7Z8Gd"d#e8Z9Gd$d%e7Z:Gd&d'e7Z;Gd(d)e7Z<Gd*d+e;Z=Gd,d-e'e;Z>Gd.d/e'e;Z?Gd0d1e'e;Z@Gd2d3e'e;ZAGd4d5e;ZBGd6d7e;ZCe>ZDe?ZEe@ZFeAZGeCZHeBxZIZGd8d9e'e8e<ZJGd:d;e<ZKeJZLeKZMd<ZNdCd=ZOd>ZPd?ZQeEeFeGeeHeDeLeMffd@ZRdCdAZSdCdBZTy)DaAn implementation of gates that act on qubits. Gates are unitary operators that act on the space of qubits. Medium Term Todo: * Optimize Gate._apply_operators_Qubit to remove the creation of many intermediate Qubit objects. * Add commutation relationships to all operators and use this in gate_sort. * Fix gate_sort and gate_simp. * Get multi-target UGates plotting properly. * Get UGate to work with either sympy/numpy matrices and output either format. This should also use the matrix slots. )chainN)Add)Tuple)Mul)IInteger)Pow)Number)S)default_sort_key)_sympify)sqrt) prettyForm stringPict)AntiCommutator) Commutator) QuantumError) ComplexSpace)UnitaryOperatorOperatorHermitianOperator)matrix_tensor_product matrix_eye) matrix_cache) MatrixBase) is_sequence)GateCGateUGate OneQubitGate TwoQubitGate IdentityGate HadamardGateXGateYGateZGateTGate PhaseGateSwapGateCNotGateCNOTSWAPHXYZTr Phase normalized gate_sort gate_simprandom_circuitCPHASECGateSTc2d|vr t|d<t|i|SNkey)r maxargskwargss `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/physics/quantum/gate.py_maxrAT# F(u   c2d|vr t|d<t|i|Sr:)r minr=s r@_minrFZrBrCc|ay)aSet flag controlling normalization of Hadamard gates by `1/\sqrt{2}`. This is a global setting that can be used to simplify the look of various expressions, by leaving off the leading `1/\sqrt{2}` of the Hadamard gate. Parameters ---------- normalize : bool Should the Hadamard gate include the `1/\sqrt{2}` normalization factor? When True, the Hadamard gate will have the `1/\sqrt{2}`. When False, the Hadamard gate will not have this factor. N) _normalized) normalizes r@r3r3`s KrCct|}|D],}|jr|jrtd||zt t |t |k7r t dy)NzInteger expected, got: %rz4Target/control qubits in a gate cannot be duplicated)list is_Integer is_Symbol TypeErrorlensetr)tandcbits r@_validate_targets_controlsrSqsi KEF~~cmm7%*DE EF 3u:#e*$ B  %rCceZdZdZdZdZdZedZedZ e dZ e dZ e dZ e d Zdd Zd Zd Zd ZdZdZdZdZdZy)ra8Non-controlled unitary gate operator that acts on qubits. This is a general abstract gate that needs to be subclassed to do anything useful. Parameters ---------- label : tuple, int A list of the target qubits (as ints) that the gate will apply to. Examples ======== ,GcRttj|}t||SN)rr _eval_argsrSclsr>s r@rYzGate._eval_argss$o0067"4( rCc6tdt|dzzS1This returns the smallest possible Hilbert space.rrArZs r@_eval_hilbert_spacezGate._eval_hilbert_spaceAda00rCc,t|jSzThe total number of qubits this gate acts on. For controlled gate subclasses this includes both target and control qubits, so that, for examples the CNOT gate acts on 2 qubits. )rOtargetsselfs r@nqubitsz Gate.nqubitss4<<  rCc2t|jdzSz7The minimum number of qubits this gate needs to act on.r`)rArfrgs r@ min_qubitszGate.min_qubitssDLL!A%%rCc|jSA tuple of target qubits.labelrgs r@rfz Gate.targetsszzrCc d|jzS)Nz$%s$)gate_name_latexrgs r@gate_name_plotzGate.gate_name_plots----rCctd)zThe matrix representation of the target part of the gate. Parameters ---------- format : str The format string ('sympy','numpy', etc.) z-get_target_matrix is not implemented in Gate.NotImplementedErrorrhformats r@get_target_matrixzGate.get_target_matrixs" ;= =rCc (|j|fi|S)z(Redirect an apply from IntQubit to Qubit)_apply_operator_Qubitrhqubitsoptionss r@_apply_operator_IntQubitzGate._apply_operator_IntQubits)t))& enumerateflip) rhr~rrf target_matrix column_indexntargetcolumnresultindex new_qubitrRs r@r|zGate._apply_operator_QubitsJ >>DOO +&..2  dE "%%f- ,,..g.>   F AfVn, ,LQA q#l"3346;;' .E )((&++6I(1 7 VV$#(:: )v 6I 7 fUmI- -F . rCc &|jdi|S)NrX)_represent_ZGate)rhrs r@_represent_default_basiszGate._represent_default_basiss$t$$5W55rCc >|jdd}|jdd}|dk(r td||jkrtd|z|j|}|j}t |t r |j}ng}t|||||}|S)Nryrrirz.The number of qubits must be given as nqubits.z2The number of qubits %r is too small for the gate.) getrrlrzrfrrcontrolsrepresent_zbasis) rhbasisrryrirrfrms r@rzGate._represent_ZGatesXw/++i+ a<@B B T__ $DwN ..v6 ,, dE "}}HH  g}gv rCcL|j|g|}|jd|dS)N()) _print_label gate_namerhprinterr>rqs r@ _sympystrzGate._sympystr#s(!!!'1D1>>511rCcvt|j}|j|g|}|j||SrX)rr_print_label_pretty_print_subscript_pretty)rhrr>abs r@_prettyz Gate._pretty's: t~~ & $D $ $W 4t 4++Aq11rCcL|j|g|}|jd|dS)N_{})rrsrs r@_latexz Gate._latex,s*!!!'1D1 00%88rCctd)Nzplot_gate is not implemented.rv)rhaxesgate_idx gate_grid wire_grids r@ plot_gatezGate.plot_gate0s!"ABBrCNr)__name__ __module__ __qualname____doc___label_separatorrrs classmethodrYrbpropertyrirlrfrtrzrr|rrrrrrrCr@rr~s IO  11!!&&.. ==)^6822 9CrCrceZdZdZdZdZejZdZ e dZ e dZ e dZe dZe dZe d Ze d Zdd Zd Zd ZdZdZdZdZdZdZdZy)raA general unitary gate with control qubits. A general control gate applies a target gate to a set of targets if all of the control qubits have a particular values (set by ``CGate.control_value``). Parameters ---------- label : tuple The label in this case has the form (controls, gate), where controls is a tuple/list of control qubits (as ints) and gate is a ``Gate`` instance that is the target operator. Examples ======== CFc|d}|d}t|s|f}tj|}tt ||j t ||fS)Nrr`)rrrYrSrrfr)r[r>rgates r@rYzCGate._eval_argsSsX7Aw8$ {H"--h7"54<<#@Ax $''rCcjtdtt|ddz|djzSr^r_rr`)rrArlrZs r@rbzCGate._eval_hilbert_space^s1AT$q']Q%6Q8J8J KKKrCcXt|jt|jzSre)rOrfrrgs r@riz CGate.nqubitsgs!4<< 3t}}#555rCcltt|jt|jdzSrk)rArrfrgs r@rlzCGate.min_qubitsps(D'dll);z&CGate.eval_controls..s M5:!3!33Ms)allr)rhrs``r@rzCGate.eval_controlssMt}}MMMrCc t|jdk(r|jd}|jjd}t |jt r8t |}t||}t |}t|}||z|z|zSt |jtr*t|}t||}t|}||z|zSy|S)z@Decompose the controlled gate into CNOT and single qubits gates.r`rN) rOrrrfrr%r(r*r&r#)rhrctg1g2g3g4s r@ decomposezCGate.decomposes t}}  " a A !!!$A$))U+q\a^q\1X"uRx{"$))U+!!_a^!!_"uRx , KrCc|j|jd|g|}|j|jg|}d|d|S)NrUrz),)_print_sequencer_printrrhrr>rrs r@rzCGate._print_labelsE'4'' sGKdKw~~dii/$/$d++rCc|j|jd|g|}|j|j}t |j }|j ||}|j|}t|j|}|SNrU) _print_sequence_prettyrrrrrr_print_parens_prettyrright)rhrr>rrrfirstfinals r@rz CGate._prettys.4.. MM30*.0~~dii(t~~. ,,YA((.EKK-. rCc|j|jd|g|}|j|jg|}|jd|d|dS)NrUrz}{\left(z\right)})rrrrrsrs r@rz CGate._latexsQ'4'' sGKdKw~~dii/$/  ! !8T3 3rCcttt|j|j}tt t|j|j}|j ||||jD]}|j|t||jr|jjdk(r|jj||y|jjdk(r |j||jdy|jj||y|jj||y)z Plot the controlled gate. If *simplify_cgate* is true, simplify C-X and C-Z gates into their more familiar forms. r.r0rN) rrFrrrfrA control_line control_pointsimplify_cgaterrplot_gate_plusr)rh circ_plotrmin_wiremax_wirers r@rzCGate.plot_gates tE$-->?@tE$-->?@x8< 6A  # #Hc!f 5 6   yy""c) ((H=$$+''$,,q/B ##Ix8 II   8 4rCcdt|jtr|Stj |SrX)rrrr _eval_daggerrgs r@rzCGate._eval_daggers' dii!2 3K$$T* *rCcdt|jtr|Stj |SrX)rrrr _eval_inversergs r@rzCGate._eval_inverses' dii!2 3K%%d+ +rCct|jtrF|dk(rtj ||St |dzdk(r|tj |zS|Stj ||S)Nr_r)rrrr _eval_powerabsr)rhexps r@rzCGate._eval_powersi dii!2 3by''c22SA"T//566 ##D#. .rCNr)rrrrrrs_SOnerrrrYrbrrirlrfrrrzrrrrrrrrrrrCr@rr4s$IOFFMN ((LL66AA!!$$3N., 3 50+ , /rCrceZdZdZdZy)r8zpVersion of CGate that allows gate simplifications. I.e. cnot looks like an oplus, cphase has dots, etc. TN)rrrrrrrCr@r8r8sNrCr8cbeZdZdZdZdZedZedZe dZ d dZ dZ dZ d Zy ) raGeneral gate specified by a set of targets and a target matrix. Parameters ---------- label : tuple A tuple of the form (targets, U), where targets is a tuple of the target qubits and U is a unitary matrix with dimension of len(targets). UcH|d}t|s|f}tj|}t||d}t |t st d|zt|}dt|ztfd|jDstd|d|||fS)Nrr`zMatrix expected, got: %rr_c3(K|] }|k( ywrXr)rshapedims r@rz#UGate._eval_args..s7E3%<7sz.Number of targets must match the matrix size:  ) rrrYrSrrrNr rOrr IndexError)r[r>rfmatrs @r@rYzUGate._eval_argssq'7#jG//'*"7+1g#z*6<= =smWo7SYY77# ~rCc<tdt|ddzzSrrarZs r@rbzUGate._eval_hilbert_spaces Ad1g!233rCc2t|jdS)rorrrgs r@rfz UGate.targetsrrCc |jdS)zThe matrix rep. of the target part of the gate. Parameters ---------- format : str The format string ('sympy','numpy', etc.) r`rprxs r@rzzUGate.get_target_matrix(szz!}rCc|j|jd|g|}t|j}|j ||Sr)rrfrrr)rhrr>rfrs r@rz UGate._pretty5sH-$-- LL#w/)-/t~~. ++Iw??rCcd|j|jd|g|}|jd|dS)NrUrr)rrfrs)rhrr>rfs r@rz UGate._latex;s2&$&&t||S'IDI!117;;rCcj|j|j|t|jdyNr one_qubit_boxrtrrfrhrrs r@rzUGate.plot_gate?+    c$,,q/* rCNr)rrrrrrsrrYrbrrfrzrrrrrCr@rrsdIO &44$$@ < rCrc:eZdZdZej ZdZdZdZ y)r z'A single qubit unitary gate base class.cj|j|j|t|jdyrrrs r@rzOneQubitGate.plot_gateKrrCc t|trB|j|jk7s|j|jk(rtj St j||fi|SrX)rr rfrrZeror_eval_commutatorrhotherhintss r@rzOneQubitGate._eval_commutatorQsL e\ *||u}},%//0Qww((u>>>rCc t|trC|j|jk7s|j|jk(rt d|z|zSt j ||fi|SNr_)rr rfrrr_eval_anticommutatorrs r@rz!OneQubitGate._eval_anticommutatorWsV e\ *||u}},%//0Qqz$u,,,,T5BEBBrCN) rrrrrrrirrrrrCr@r r Fs1ffG ? CrCr c eZdZdZedZy)r!z$A two qubit unitary gate base class.r_N)rrrrrrirrCr@r!r!^s.ajGrCr!c6eZdZdZdZdZdZdZd dZdZ dZ y) r"zThe single qubit identity gate. Parameters ---------- target : int The target qubit this gate will apply to. Examples ======== T1c |j|jkr%td|jd|j|S)Nrr)rirlrr}s r@r|z"IdentityGate._apply_operator_Qubitys8 >>DOO +&..2  rCc.tjd|S)Neye2r get_matrixrxs r@rzzIdentityGate.get_target_matrix&&vv66rCc "tjSrXrrrs r@rzIdentityGate._eval_commutator wwrCc td|zSr)rrs r@rz!IdentityGate._eval_anticommutatorsqz%rCNr) rrrr is_hermitianrrsr|rzrrrrCr@r"r"hs, LIO7 rCr"cDeZdZdZdZdZd dZdZdZdZ dZ dZ d Z y ) r#azThe single qubit Hadamard gate. Parameters ---------- target : int The target qubit this gate will apply to. Examples ======== >>> from sympy import sqrt >>> from sympy.physics.quantum.qubit import Qubit >>> from sympy.physics.quantum.gate import HadamardGate >>> from sympy.physics.quantum.qapply import qapply >>> qapply(HadamardGate(0)*Qubit('1')) sqrt(2)*|0>/2 - sqrt(2)*|1>/2 >>> # Hadamard on bell state, applied on 2 qubits. >>> psi = 1/sqrt(2)*(Qubit('00')+Qubit('11')) >>> qapply(HadamardGate(0)*HadamardGate(1)*psi) sqrt(2)*|00>/2 + sqrt(2)*|11>/2 r-cftrtjd|Stjd|S)Nr-Hsqrt2)rHrr&rxs r@rzzHadamardGate.get_target_matrixs+ **37 7**8V< `` and does nothing if the state is ``|0>``. Parameters ---------- target : int The target qubit this gate will apply to. Examples ======== Fr c.tjd|S)Nr r%rxs r@rzzPhaseGate.get_target_matrix.rBrCc "tjSrXr)rs r@r7z PhaseGate._eval_commutator_ZGate1r*rCc "tjSrXr)rs r@_eval_commutator_TGatez PhaseGate._eval_commutator_TGate4r*rCNr) rrrrr,rrsrzr7rZrrCr@r(r(s' LIO4rCr(c0eZdZdZdZdZdZddZdZdZ y) r'aThe single qubit pi/8 gate. This gate rotates the phase of the state by pi/4 if the state is ``|1>`` and does nothing if the state is ``|0>``. Parameters ---------- target : int The target qubit this gate will apply to. Examples ======== Fr1c.tjd|S)Nr1r%rxs r@rzzTGate.get_target_matrixKrBrCc "tjSrXr)rs r@r7zTGate._eval_commutator_ZGateNr*rCc "tjSrXr)rs r@_eval_commutator_PhaseGatez TGate._eval_commutator_PhaseGateQr*rCNr) rrrrr,rrsrzr7r_rrCr@r'r'8s' LIO4rCr'ceZdZdZdZdZdZedZedZ e dZ e dZ e d Z e d Zd Zd Zd ZdZdZdZdZdZy)r*aTwo qubit controlled-NOT. This gate performs the NOT or X gate on the target qubit if the control qubits all have the value 1. Parameters ---------- label : tuple A tuple of the form (control, target). Examples ======== >>> from sympy.physics.quantum.gate import CNOT >>> from sympy.physics.quantum.qapply import qapply >>> from sympy.physics.quantum.qubit import Qubit >>> c = CNOT(1,0) >>> qapply(c*Qubit('10')) # note that qubits are indexed from right to left |11> r+z \text{CNOT}Tc0tj|}|SrX)rrYrZs r@rYzCNotGate._eval_argsst$ rCc6tdt|dzzSr]rarZs r@rbzCNotGate._eval_hilbert_spacercrCc2t|jdzSrk)rArqrgs r@rlzCNotGate.min_qubitssDJJ!##rCc"|jdfS)ror`rprgs r@rfzCNotGate.targets 1 rCc"|jdfSrrprgs r@rzCNotGate.controlsrerCc2t|jdSr)r$rqrgs r@rz CNotGate.gaterrCc0tj||g|SrX)rrrhrr>s r@rzCNotGate._print_labels  w666rCc0tj||g|SrX)rrris r@rzCNotGate._prettys||D'1D11rCc0tj||g|SrX)rrris r@rzCNotGate._latexs{{40400rCc ||jd|jdk(rtjSt d|z)z[CNOT(i, j), Z(i)] == 0.rCommutator not implemented: %r)rrfrrrwrs r@r7zCNotGate._eval_commutator_ZGates6 == u}}Q/ /77N%&F&NO OrCc (|j|fi|S)z[CNOT(i, j), T(i)] == 0.r7rs r@rZzCNotGate._eval_commutator_TGate*t**5:E::rCc (|j|fi|S)z[CNOT(i, j), S(i)] == 0.rors r@r_z#CNotGate._eval_commutator_PhaseGaterprCc ||jd|jdk(rtjStd|z)z[CNOT(i, j), X(j)] == 0.rrm)rfrrrwrs r@r3zCNotGate._eval_commutator_XGates5 <<?emmA. .77N%&F&NO OrCc ||jd|jdk(rtjStd|z)z[CNOT(i, j), CNOT(i,k)] == 0.rrm)rrrrwrs r@_eval_commutator_CNotGatez"CNotGate._eval_commutator_CNotGates6 == u~~a0 077N%&F&NO OrCN)rrrrrrsrrrYrbrrlrfrrrrrr7rZr_r3rtrrCr@r*r*cs*I$ON 11$$    $$721P;;PPrCr*c6eZdZdZdZdZdZd dZdZdZ dZ y ) r)zTwo qubit SWAP gate. This gate swap the values of the two qubits. Parameters ---------- label : tuple A tuple of the form (target1, target2). Examples ======== Tr,z \text{SWAP}c.tjd|S)Nr,r%rxs r@rzzSwapGate.get_target_matrixr'rCc ~|jd|jd}}t||}t||}||z|zS)z(Decompose the SWAP gate into CNOT gates.rr`)rfr*)rhrijrrs r@rzSwapGate.decomposes>||A Q1 a^ a^"uRxrCctt|j}tt|j}|j ||||j |||j ||yrX)rrFrfrAr swap_point)rhrrrrs r@rzSwapGate.plot_gatesZtDLL)*tDLL)*x8<Xx0Xx0rCc D|jdd}|jDcgc] }t|}}t|}t |}|jd|j }t jd|} t jd|} t jd|} t jd|} t jd|} d }| | f| | f| | f| | ffD]3\}}|| gz}||||z d z <||||z d z <t|}||}/||z}5|Scc}w) zRepresent the SWAP gate in the computational basis. The following representation is used to compute this: SWAP = |1><1|x|1><1| + |0><0|x|0><0| + |1><0|x|0><1| + |0><1|x|1><0| ryrriop01op10op11op00r$Nr`) rrfrrFrArlrr&r)rhrrryrrf min_target max_targetrir}r~rrr$rrxryproduct new_results r@rzSwapGate._represent_ZGates=Xw/#'<<0a3q600'] '] ++i9&&vv6&&vv6&&vv6&&vv6&&vv6D\D$<$d|L -DAqtfnG01GGj(1, -01GGj(1, -.8J~#*, - -1sDNr) rrrrr,rrsrzrrrrrCr@r)r)s, LI$O71rCr)c.t|ft|SrX)r8r0)rrs r@r7r7stAaD))rCc$|Dcgc] }t|}}|Dcgc] }t|}}t|}tjd|}tjd|}t|dk(rt|dk(rqg}|d} | |dz k7r%|j t d|| z dz z||j || dk7r|j t d| z|t |St|dk(rzt|dk\rl|d} g} t|D]} | j t d| |D] } || |dz | z <||z | |dz | z <t d|z|t | zStdcc}wcc}w)aRepresent a gate with controls, targets and target_matrix. This function does the low-level work of representing gates as matrices in the standard computational basis (ZGate). Currently, we support two main cases: 1. One target qubit and no control qubits. 2. One target qubits and multiple control qubits. For the base of multiple controls, we use the following expression [1]: 1_{2**n} + (|1><1|)^{(n-1)} x (target-matrix - 1_{2}) Parameters ---------- controls : list, tuple A sequence of control qubits. targets : list, tuple A sequence of target qubits. target_matrix : sympy.Matrix, numpy.matrix, scipy.sparse The matrix form of the transformation to be performed on the target qubits. The format of this matrix must match that passed into the `format` argument. nqubits : int The total number of qubits used for the representation. format : str The format of the final matrix ('sympy', 'numpy', 'scipy.sparse'). Examples ======== References ---------- [1] http://www.johnlapeyre.com/qinf/qinf_html/node6.html. rr$rr`r_rzKThe representation of multi-target, multi-control gates is not implemented.) rrr&rOappendrrrrw)rrfrriryxrr$rrRrproduct2rxcontrols r@rr$sH!))1A)H)&'!s1v'G''lG  " "66 2D  " "66 2D 8}c'la/aj 'A+  NN:a'C-!*;&.6A9Q<6Nr_r`r)r4rrsumr>rr as_base_expr5rrObaser#r$r%r&rr r(rr')circuit circuit_argsrerxnewargss r@r5r5ys G '36666 GS !|| GS !""$1!! a) 3|$ %) l1os +,q/..ueU35"<?#6#6?(+'?//,q/2E2E2IJLM'A/0$CM28 N7LO00)<'r*!U<?+?+?+D+DQ+G%Ha,,Q./&12>q/2F2Fa$$q(3*%++"LQ$88#CM2 NLO00%8&r*"Y|A/C/C/H/H/K%L Q++A-.&/0.rrTFr`rNr_)rrrr>r r4rrrrrrOrcomparerdoitrr NegativeOne) rchanges circ_arrayrx first_base first_exp second_base second_expnew_argssigns r@r4r4s'36666'3& 33 GT " gs #G \\ s:*+ A*Q-$5z!a%04+>(21 (A(A(C% I*4QU*;*G*G*I' Z %%k2Q6!*k:??AQF$+LL!$4 QU8K7M$M$+LLO#5%68? QUV8L%M"%x."&%j+>CCEJ$+LL!$4 QU8K7M$M$+LLO#5%68? QUV8L%M!~~ *0DE"&sH~"5"&1  8 NrCc.t|}g}t|D]s}tj|}|tk(s |tk(rtj |d}||}ntj|}||}|j |ut|S)aReturn a random circuit of ngates and nqubits. This uses an equally weighted sample of (X, Y, Z, S, T, H, CNOT, SWAP) gates. Parameters ---------- ngates : int The number of gates in the circuit. nqubits : int The number of qubits in the circuit. gate_space : tuple A tuple of the gate classes that will be used in the circuit. Repeating gate classes multiple times in this tuple will increase the frequency they appear in the random circuit. r_)rrandomchoicer*r)samplerr) ngatesri gate_space qubit_spacerrxgr~rs r@r6r6s".K F 6] MM* % =AM]];2F6 AMM+.E%A a <rCc.tjd|S)z(Transformation matrix from Z to X basis.ZXr%rxs r@zx_basis_transformr  " "4 00rCc.tjd|S)z(Transformation matrix from Z to Y basis.ZYr%rxs r@zy_basis_transformrrrCr)Ur itertoolsrrsympy.core.addrsympy.core.containersrsympy.core.mulrsympy.core.numbersrrsympy.core.powerr r sympy.core.singletonr rsympy.core.sortingr sympy.core.sympifyr (sympy.functions.elementary.miscellaneousr sympy.printing.pretty.stringpictrr$sympy.physics.quantum.anticommutatorr sympy.physics.quantum.commutatorrsympy.physics.quantum.qexprrsympy.physics.quantum.hilbertrsympy.physics.quantum.operatorrrr!sympy.physics.quantum.matrixutilsrr!sympy.physics.quantum.matrixcachersympy.matrices.matrixbasersympy.utilities.iterablesr__all__rHrArFr3rSrrr8rr r!r"r#r$r%r&r(r'r-r.r/r0r1r2r*r)r+r,r7rr5r4r6rrrrCr@rs  '+ %(/'9C?746??O:01 J   "  sC?sClt/Dt/lUR DR jC4C04! <! H05$l05f$ |$N |8 |2 :L<     oP %oPdA|AJ)M jBJ1r121aAq$/M>1 1rC