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

All Samples(12)  |  Call(9)  |  Derive(0)  |  Import(3)

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()
 
    psi = superposition_basis(nqubits)
    print('psi:')
    pprint(psi)
    print('On a 3 Qubit system, it requires 2 iterations to achieve')
    print('|1> with high enough probability')
    psi = superposition_basis(nqubits)
    print('psi:')
    pprint(psi)

src/s/y/sympy-HEAD/examples/advanced/dense_coding_example.py   sympy(Download)
from sympy.physics.quantum.qubit import Qubit
from sympy.physics.quantum.circuitplot import circuit_plot
from sympy.physics.quantum.grover import superposition_basis
 
 
def main():
    psi = superposition_basis(2)

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_superposition_basis():
    nbits = 2
    first_half_state = IntQubit(0, nbits)/2 + IntQubit(1, nbits)/2
    second_half_state = IntQubit(2, nbits)/2 + IntQubit(3, nbits)/2
    assert first_half_state + second_half_state == superposition_basis(nbits)
    thirdq = (1/sqrt(8))*IntQubit(4, nbits) + (1/sqrt(8))*IntQubit(5, nbits)
    fourthq = (1/sqrt(8))*IntQubit(6, nbits) + (1/sqrt(8))*IntQubit(7, nbits)
    assert firstq + secondq + thirdq + fourthq == superposition_basis(nbits)
 
 
def test_WGate():
    nqubits = 2
    basis_states = superposition_basis(nqubits)
    assert qapply(WGate(nqubits)*basis_states) == basis_states
 
def test_grover_iteration_1():
    numqubits = 2
    basis_states = superposition_basis(numqubits)
    v = OracleGate(numqubits, return_one_on_one)
    expected = IntQubit(1, numqubits)