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

All Samples(73)  |  Call(64)  |  Derive(0)  |  Import(9)
A 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

label : tuple
    The label in this case has the form (controls, gate), where controls(more...)

src/s/y/sympy-HEAD/sympy/physics/quantum/qft.py   sympy(Download)
from sympy.physics.quantum.tensorproduct import matrix_tensor_product
from sympy.physics.quantum.gate import (
    Gate, HadamardGate, SwapGate, OneQubitGate, CGate, PhaseGate, TGate, ZGate
            circuit = HadamardGate(level)*circuit
            for i in range(level - start):
                circuit = CGate(level - i - 1, RkGate(level, i + 2))*circuit
        for i in range((finish - start)//2):
            circuit = SwapGate(i + start, finish - i - 1)*circuit
        for level in range(start, finish):
            for i in reversed(range(level - start)):
                circuit = CGate(level - i - 1, RkGate(level, -i - 2))*circuit
            circuit = HadamardGate(level)*circuit
        return circuit

src/s/y/sympy-HEAD/sympy/physics/quantum/circuitplot.py   sympy(Download)
from sympy.core.compatibility import u
from sympy.external import import_module
from sympy.physics.quantum.gate import Gate,OneQubitGate,CGate,CGateS
__all__ = [

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,
from sympy.physics.quantum.identitysearch import bfs_identity_search
    h = H(0)
    cnot = CNOT(1, 0)
    cgate_z = CGate((0,), Z(1))
    # Standard cases
    cnot_10 = CNOT(1, 0)
    cnot_01 = CNOT(0, 1)
    cgate_z_10 = CGate(1, Z(0))
    cgate_z_01 = CGate(0, Z(1))
    expected = (X(i0), X(i1), Y(i0), Y(i1), Z(i0), Z(i1),
                H(i0), H(i1), CNOT(i1, i0), CNOT(i0, i1),
                CGate(i1, Z(i0)), CGate(i0, Z(i1)))

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 test_generate_gate_rules_1():
    # Test with tuples
    (x, y, z, h) = create_gate_sequence()
    ph = PhaseGate(0)
    cgate_t = CGate(0, TGate(1))
def test_generate_gate_rules_2():
    # Test with Muls
    (x, y, z, h) = create_gate_sequence()
    ph = PhaseGate(0)
    cgate_t = CGate(0, TGate(1))
    assert generate_equivalent_ids(gate_seq) == gate_ids
    cgate_y = CGate((1,), y)
    gate_seq = (y, cgate_y, y, cgate_y)
    gate_ids = set([(y, cgate_y, y, cgate_y), (cgate_y, y, cgate_y, y)])
    assert generate_equivalent_ids(gate_seq) == gate_ids
    cnot = CNOT(1, 0)
    cgate_z = CGate((0,), Z(1))

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,
    CNOTMatrix = Matrix(
        [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]])
    assert represent(CGate(1, XGate(0)), nqubits=2) == CNOTMatrix
    # Test multiple control bit functionality
    ToffoliGate = CGate((1, 2), XGate(0))
    [0, 0, 0, 0, 0, 0, 1, 0]])
    ToffoliGate = CGate((3, 0), XGate(1))
    assert qapply(ToffoliGate*Qubit('1001')) == \
        matrix_to_qubit(represent(ToffoliGate*Qubit('1001'), nqubits=4))
    assert qapply(ToffoliGate*Qubit('0000')) == \
        matrix_to_qubit(represent(ToffoliGate*Qubit('0000'), nqubits=4))
    CYGate = CGate(1, YGate(0))

src/s/y/sympy-HEAD/sympy/physics/quantum/tests/test_qft.py   sympy(Download)
from sympy import exp, I, Matrix, pi, sqrt, Symbol
from sympy.physics.quantum.qft import QFT, IQFT, RkGate
from sympy.physics.quantum.gate import (ZGate, SwapGate, HadamardGate, CGate,
                                        PhaseGate, TGate)
def test_quantum_fourier():
    assert QFT(0, 3).decompose() == \
        SwapGate(0, 2)*HadamardGate(0)*CGate((0,), PhaseGate(1)) * \
        HadamardGate(1)*CGate((0,), TGate(2))*CGate((1,), PhaseGate(2)) * \
    assert IQFT(0, 3).decompose() == \
        HadamardGate(2)*CGate((1,), RkGate(2, -2))*CGate((0,), RkGate(2, -3)) * \

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(SWAP(0,2)*H(0)* CGate((0,),S(1)) *H(1)*CGate((0,),T(2))\
    assert c.ngates == 7

src/s/y/sympy-HEAD/sympy/core/tests/test_args.py   sympy(Download)
def test_sympy__physics__quantum__gate__CGate():
    from sympy.physics.quantum.gate import CGate, Gate
    assert _test_args(CGate((0, 1), Gate(2)))

src/s/y/sympy-HEAD/sympy/physics/quantum/tests/test_printing.py   sympy(Download)
from sympy.physics.quantum.constants import hbar
from sympy.physics.quantum.dagger import Dagger
from sympy.physics.quantum.gate import CGate, CNotGate, IdentityGate, UGate, XGate
from sympy.physics.quantum.hilbert import ComplexSpace, FockSpace, HilbertSpace, L2
from sympy.physics.quantum.innerproduct import InnerProduct
    q = Qubit(1, 0, 1, 0, 1)
    g1 = IdentityGate(2)
    g2 = CGate((3, 0), XGate(1))
    g3 = CNotGate(1, 0)
    g4 = UGate((0,), uMat)