Exemple #1
0
MS = AbstractGate("MS", [float, int], arity=lambda theta, nb_qbits: nb_qbits,
                  circuit_generator=_gen_ms)


GATE_DIC = {
    "h": H,
    "x": X,
    "y": Y,
    "z": Z,
    "swap": SWAP,
    "i": I,
    "id": I,
    "s": S,
    "sdg": S.dag(),
    "t": T,
    "tdg": T.dag(),
    "rx": RX,
    "ry": RY,
    "rz": RZ,
    "rxx": RXX,
    "rzz": RZZ,
    "p": RZ,
    "r": R,
    "ms": MS,
    "u": U3,
    # below: deprecated
    "u0": I,
    "U": U,
    "xbase": X,
    "iden": I,
    "u1": RZ,
Exemple #2
0
from qiskit import QuantumRegister, QuantumCircuit, ClassicalRegister, Aer
from qiskit.circuit import Parameter

LOGGER = logging.getLogger()
# Set level to logging.DEBUG in order to see more information
LOGGER.setLevel(logging.WARNING)

# redirects log writing to terminal
STREAM_HANDLER = logging.StreamHandler()
STREAM_HANDLER.setLevel(logging.DEBUG)
LOGGER.addHandler(STREAM_HANDLER)

PYGATES_1QB = [
    X, Y, Z, I, S, T,
    S.dag(),
    T.dag(), H,
    RX(3.14),
    RY(3.14),
    RZ(3.14),
    U2(3.14, 3.14),
    R(3.14, 3.14),
    U3(3.14, 3.14, 3.14)
]
PYGATES_2QB = [
    SWAP, CNOT,
    Y.ctrl(),
    Z.ctrl(),
    H.ctrl(),
    RZ(3.14).ctrl(),
    RXX(3.14),
    RZZ(3.14)
    gates_1qb_1prm = [ocirc.rx, ocirc.ry, ocirc.rz, ocirc.p]
    gates_2qb_1prm = [ocirc.crz, ocirc.rxx, ocirc.rzz]
    gates_3qb_0prm = [ocirc.cswap, ocirc.ccx]
    return (
        gates_1qb_0prm,
        gates_1qb_1prm,
        gates_2qb_0prm,
        gates_2qb_1prm,
        gates_3qb_0prm,
    )


PYGATES_1QB = [
    X, Y, Z, I, S, T, H,
    S.dag(),
    T.dag(),
    RX(3.14),
    RY(3.14),
    RZ(3.14),
    RZ(3.14)
]

PYGATES_2QB = [H.ctrl(), CNOT, SWAP, RZ(3.14).ctrl(), RXX(3.14), RZZ(3.14)]


class TestQiskit2QLMConversion(unittest.TestCase):
    """
    Tests the function converting a qiskit circuit
    to a qlm circuit.
    """
    @unittest.skipIf(running_python310(), "Test not supported")