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

All Samples(51)  |  Call(44)  |  Derive(0)  |  Import(7)
The single qubit Hadamard gate.

Parameters
----------
target : int
    The target qubit this gate will apply to.

Examples
--------
(more...)

src/s/y/sympy-HEAD/examples/advanced/dense_coding_example.py   sympy(Download)
from sympy import sqrt, pprint
from sympy.physics.quantum import qapply
from sympy.physics.quantum.gate import H, X, Z, CNOT
from sympy.physics.quantum.qubit import Qubit
from sympy.physics.quantum.circuitplot import circuit_plot
    # To Send Bob the message |0>|0>
    print("To Send Bob the message |00>.")
    circuit = H(1)*CNOT(1, 0)
    result = qapply(circuit*psi)
    result
    pprint(result)
 
    # To send Bob the message |0>|1>
    print("To Send Bob the message |01>.")
    circuit = H(1)*CNOT(1, 0)*X(1)
    # To send Bob the message |1>|0>
    print("To Send Bob the message |10>.")
    circuit = H(1)*CNOT(1, 0)*Z(1)
    result = qapply(circuit*psi)
    result
    pprint(result)
 
    # To send Bob the message |1>|1>
    print("To Send Bob the message |11>.")
    circuit = H(1)*CNOT(1, 0)*Z(1)*X(1)

src/s/y/sympy-HEAD/sympy/physics/quantum/identitysearch.py   sympy(Download)
from sympy import Mul, Basic, Number, Pow, Integer
from sympy.matrices import Matrix, eye
from sympy.physics.quantum.gate import (Gate, X, Y, Z, H, S, T, CNOT,
        IdentityGate, gate_simp)
from sympy.physics.quantum.represent import represent

src/s/y/sympy-HEAD/sympy/physics/quantum/tests/test_gate.py   sympy(Download)
from sympy import exp, symbols, sqrt, I, pi, Mul, Integer, Wild
from sympy.matrices import Matrix
 
from sympy.physics.quantum.gate import (XGate, YGate, ZGate, random_circuit,
        CNOT, IdentityGate, H, X, Y, S, T, Z, SwapGate, gate_simp, gate_sort,
def test_gate_sort():
    """Test gate_sort."""
    for g in (X, Y, Z, H, S, T):
        assert gate_sort(g(2)*g(1)*g(0)) == g(0)*g(1)*g(2)
    e = gate_sort(X(1)*H(0)**2*CNOT(0, 1)*X(1)*X(0))
    assert e == H(0)**2*CNOT(0, 1)*X(0)*X(1)**2
    assert gate_sort(Z(0)*X(0)) == -X(0)*Z(0)
    assert gate_sort(Z(0)*X(0)**2) == X(0)**2*Z(0)
    assert gate_sort(Y(0)*H(0)) == -H(0)*Y(0)

src/s/y/sympy-HEAD/sympy/physics/quantum/tests/test_circuitutils.py   sympy(Download)
from sympy import Symbol, Integer, Mul
from sympy.utilities import numbered_symbols
from sympy.physics.quantum.gate import (X, Y, Z, H, S, T, CNOT,
        CGate)
from sympy.physics.quantum.identitysearch import bfs_identity_search
def create_gate_sequence(qubit=0):
    gates = (X(qubit), Y(qubit), Z(qubit), H(qubit))
    return gates
 
 
    y = Y(0)
    z = Z(0)
    h = H(0)
    word = (x, y, y, x, z)
    expected_table = [-1, 0, 0, 0, 1]
def test_find_subcircuit():
    x = X(0)
    y = Y(0)
    z = Z(0)
    h = H(0)
    y_i0 = Y(i0)
    z_i0 = Z(i0)
    h_i0 = H(i0)
 
    circuit = (x, y, z)

src/s/y/sympy-HEAD/sympy/physics/quantum/tests/test_identitysearch.py   sympy(Download)
from sympy.external import import_module
from sympy import Mul, Integer
from sympy.physics.quantum.dagger import Dagger
from sympy.physics.quantum.gate import (X, Y, Z, H, S, T, CNOT,
        IdentityGate, CGate, PhaseGate, TGate, gate_simp)
def create_gate_sequence(qubit=0):
    gates = (X(qubit), Y(qubit), Z(qubit), H(qubit))
    return gates
 
 
    assert actual is True
 
    h = H(0)
    hh_circuit = (h, h)
    actual = is_scalar_nonsparse_matrix(hh_circuit, numqubits, id_only)
    assert actual is True
 
    h1 = H(1)
    assert is_scalar_sparse_matrix(cnot_circuit, numqubits, id_only) is True
 
    h = H(0)
    hh_circuit = (h, h)
    assert is_scalar_sparse_matrix(hh_circuit, numqubits, id_only) is True

src/s/y/sympy-HEAD/sympy/physics/quantum/tests/test_circuitplot.py   sympy(Download)
from sympy.physics.quantum.circuitplot import labeller
from sympy.physics.quantum.gate import CNOT, H, X, Z, SWAP, CGate, S, T
from sympy.external import import_module
from sympy.utilities.pytest import skip
 
        from sympy.physics.quantum.circuitplot import CircuitPlot
 
    c = CircuitPlot(CNOT(1,0)*H(1),2,labels=labeller(2))
    assert c.ngates == 2
    assert c.nqubits == 2
        from sympy.physics.quantum.circuitplot import CircuitPlot
 
    c = CircuitPlot(SWAP(0,2)*H(0)* CGate((0,),S(1)) *H(1)*CGate((0,),T(2))\
                    *CGate((1,),S(2))*H(2),3,labels=labeller(3,'j'))
    assert c.ngates == 7

src/s/y/sympy-HEAD/sympy/physics/quantum/tests/test_qapply.py   sympy(Download)
from sympy.physics.quantum.constants import hbar
from sympy.physics.quantum.dagger import Dagger
from sympy.physics.quantum.gate import H
from sympy.physics.quantum.operator import Operator, UnitaryOperator
from sympy.physics.quantum.qapply import qapply
def test_dagger():
    lhs = Dagger(Qubit(0))*Dagger(H(0))
    rhs = Dagger(Qubit(1))/sqrt(2) + Dagger(Qubit(0))/sqrt(2)
    assert qapply(lhs, dagger=True) == rhs