Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(7)  |  Call(4)  |  Derive(0)  |  Import(3)
General n qubit W Gate in Grover's algorithm.

The gate performs the operation ``2|phi><phi| - 1`` on some qubits.
``|phi> = (tensor product of n Hadamards)*(|0> with n qubits)``

Parameters
==========

nqubits : int
    The number of qubits to operate on

src/s/y/sympy-HEAD/examples/advanced/grover_example.py   sympy(Download)
from sympy.physics.quantum import qapply
from sympy.physics.quantum.qubit import IntQubit
from sympy.physics.quantum.grover import (OracleGate, superposition_basis,
        WGate, grover_iteration)
 
    print()
 
    w = WGate(nqubits)
    print('WGate or w = WGate(%r)' % nqubits)
    print('On a 2 Qubit system like psi, 1 iteration is enough to yield |1>')

src/s/y/sympy-HEAD/sympy/physics/quantum/tests/test_grover.py   sympy(Download)
from sympy import sqrt
from sympy.physics.quantum.qapply import qapply
from sympy.physics.quantum.qubit import IntQubit
from sympy.physics.quantum.grover import (apply_grover, superposition_basis,
        OracleGate, grover_iteration, WGate)
def test_WGate():
    nqubits = 2
    basis_states = superposition_basis(nqubits)
    assert qapply(WGate(nqubits)*basis_states) == basis_states
 
    expected = ((2/sqrt(pow(2, nqubits)))*basis_states) - IntQubit(1, nqubits)
    assert qapply(WGate(nqubits)*IntQubit(1, nqubits)) == expected

src/s/y/sympy-HEAD/sympy/core/tests/test_args.py   sympy(Download)
def test_sympy__physics__quantum__grover__WGate():
    from sympy.physics.quantum.grover import WGate
    assert _test_args(WGate(1))