+
    i8                         ^ 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 tR tR	 tR
 tR tR tR tR tR# )    )sqrt)Matrix)	represent)qapplyIntQubit)apply_groversuperposition_basis
OracleGategrover_iterationWGatec                 4    V \        ^V P                  4      8H  # )   r   nqubitsqubitss   &e/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/physics/quantum/tests/test_grover.pyreturn_one_on_twor   
   s    Xa000    c                 6    V \        ^V P                  R7      8H  # )   r   r   r   s   &r   return_one_on_oner      s    Xa888r   c                     ^p \        ^ V R7      ^,          \        ^V R7      ^,          ,           p\        ^V 4      ^,          \        ^V 4      ^,          ,           pW,           \        V 4      8X  g   Q h^p ^\        ^4      ,          \        ^ V R7      ,          ^\        ^4      ,          \        ^V R7      ,          ,           p^\        ^4      ,          \        ^V 4      ,          ^\        ^4      ,          \        ^V 4      ,          ,           p^\        ^4      ,          \        ^V 4      ,          ^\        ^4      ,          \        ^V 4      ,          ,           p^\        ^4      ,          \        ^V 4      ,          ^\        ^4      ,          \        ^V 4      ,          ,           pW4,           V,           V,           \        V 4      8X  g   Q hR# r   r   N)r   r
   r   )nbitsfirst_half_statesecond_half_statefirstqsecondqthirdqfourthqs          r   test_superposition_basisr$      sT   E51!3hq%6PQR6RR E*1,x5/A!/CC/3Fu3MMMMEQi!U33qay(1V[B\6\\Fay(1e,,$q'	8Au;M/MMGQi!U++qay(1e:L.LLFay(1e,,$q'	8Au;M/MMGf$w.2Ee2LLLLr   c                     \        ^R 4      p \        V \        ^ 4      ,          4      \        ^ 4      ) 8X  g   Q h\        V \        ^4      ,          4      \        ^4      8X  g   Q h^p\        ^\        4      p \        V \        ^ V4      ,          4      \        ^ VR7      8X  g   Q h\        V \        ^V4      ,          4      \        ^VR7      8X  g   Q h\        V \        ^V4      ,          4      \        ^V4      ) 8X  g   Q h\        V \        ^V4      ,          4      \        ^V4      8X  g   Q h\	        \        ^R 4      ^R7      \        R^ .^ ^..4      8X  g   Q h\	        V ^R7      \        . RO. RO. RO. R	O.4      8X  g   Q hR# )
r   c                     V \        ^ 4      8H  # r   r   r   s   &r   <lambda>!test_OracleGate.<locals>.<lambda>!   s    Vx{%:r   r   c                     V \        ^ 4      8H  # r'   r   r   s   &r   r(   r)   ,   s    &HQK2Gr   N)r   r   r   r   )r   r   r   r   )r   r   r+   r   )r   r   r   r   )r   r   r   r   r   r   )vr   s     r   test_OracleGater-       sW   1:;A!HQK- Xa[L000!HQK- HQK///E1'(A!HQ&&'8Au+EEEE!HQ&&'8Au+EEEE!HQ&&'HQ,>+>>>>!HQ&&'8Au+====Z#GHRSTB7QF#$% % %Q"flL-Ye-f&ggggr   c                  (   ^p \        V 4      p\        \        V 4      V,          4      V8X  g   Q h^\        \	        ^V 4      4      ,          V,          \        ^V R7      ,
          p\        \        V 4      \        ^V R7      ,          4      V8X  g   Q hR# r   )r
   r   r   r   powr   r   basis_statesexpecteds      r   
test_WGater3   1   sv    G&w/L%.-.,>>>4Aw((,6(1g:VVH%.!W!==>(JJJr   c                      ^p \        V 4      p\        V \        4      p\        ^V R7      p\	        \        W4      4      V8X  g   Q hR# r   )r
   r   r   r   r   r   )	numqubitsr1   r,   r2   s       r   test_grover_iteration_1r6   :   sC    I&y1L9/0A9-H"<34@@@r   c                  F   ^p \        V 4      p\        V \        4      p\        W4      p\	        V4      p\        W24      p\	        V4      p\        W24      p\	        V4      pRV,          ^@,          R\        ^V 4      ,          R,          ,           p\	        V4      V8X  g   Q hR# )        N)r
   r   r   r   r   r   )r5   r1   r,   iteratedr2   s        r   test_grover_iteration_2r=   B   s    I&y1L9/0A  0HhH,HhH,HhH L "$s8Ay+A'A#'EEH(x'''r   c                     ^p \        \        V 4      \        ^V R7      8X  g   Q h^p \        V 4      pRV,          ^@,          R\        ^V 4      ,          R,          ,           p\        \        ^4      \        V4      8X  g   Q hR# )r   r   r9   r:   Nr;   )r	   r   r   r
   r   r   r0   s      r   test_groverr?   U   ss    G)73x77SSSSG&w/LL "$s8Aw+?'?'CCH)1-1AAAAr   N)(sympy.functions.elementary.miscellaneousr   sympy.matrices.denser   sympy.physics.quantum.representr   sympy.physics.quantum.qapplyr   sympy.physics.quantum.qubitr   sympy.physics.quantum.groverr	   r
   r   r   r   r   r   r$   r-   r3   r6   r=   r?    r   r   <module>rG      sK    9 ' 5 / 0- -19Mh"KA(&Br   