예제 #1
0
        False,
        "opaque":
        False,
        "n_args":
        3,
        "n_bits":
        1,
        "args": ["theta", "phi", "lambda"],
        "bits": ["q"],
        # gate u3(theta,phi,lambda) q { U(theta,phi,lambda) q; }
        "body":
        node.GateBody([
            node.UniversalUnitary([
                node.ExpressionList([
                    node.Id("theta", 0, ""),
                    node.Id("phi", 0, ""),
                    node.Id("lambda", 0, "")
                ]),
                node.Id("q", 0, "")
            ])
        ])
    }

    # 2-parameter 1-pulse single qubit gate
    QuantumCircuit.definitions["u2"] = {
        "print":
        False,
        "opaque":
        False,
        "n_args":
        2,
        "n_bits":
예제 #2
0
# these circuits, so we may need to modify the algorithm.
# It can happen that a swap in a deeper layer can be removed by permuting
# qubits in the layout. We don't do this.
# It can happen that initial swaps can be removed or partly simplified
# because the initial state is zero. We don't do this.

cx_data = {
    "opaque": False,
    "n_args": 0,
    "n_bits": 2,
    "args": [],
    "bits": ["c", "t"],
    # gate cx c,t { CX c,t; }
    "body": node.GateBody([
        node.Cnot([
            node.Id("c", 0, ""),
            node.Id("t", 0, "")
        ])
    ])
}

swap_data = {
    "opaque": False,
    "n_args": 0,
    "n_bits": 2,
    "args": [],
    "bits": ["a", "b"],
    # gate swap a,b { cx a,b; cx b,a; cx a,b; }
    "body": node.GateBody([
        node.CustomUnitary([
            node.Id("cx", 0, ""),
            node.PrimaryList([
예제 #3
0
        """Reapply this gate to corresponding qubits in circ."""
        self._modifiers(circ.wait(self.param[0], self.arg[0]))


def wait(self, t, q):
    """Apply wait for time t to q."""
    if isinstance(q, QuantumRegister):
        gs = InstructionSet()
        for j in range(q.size):
            gs.add(self.wait(t, (q, j)))
        return gs
    self._check_qubit(q)
    return self._attach(WaitGate(t, q, self))


# Add to QuantumCircuit and CompositeGate classes
QuantumCircuit.wait = wait
CompositeGate.wait = wait

# idle for time t (identity)
QuantumCircuit.definitions["wait"] = {
    "print": False,
    "opaque": False,
    "n_args": 1,
    "n_bits": 1,
    "args": ["t"],
    "bits": ["a"],
    # gate wait(t) a { }
    "body": node.GateBody([])
}
예제 #4
0
파일: rzz.py 프로젝트: atilag/qiskit-terra
    "print":
    True,
    "opaque":
    False,
    "n_args":
    1,
    "n_bits":
    2,
    "args": ["theta"],
    "bits": ["a", "b"],
    # gate rzz(theta) a, b { cx a, b; u1(theta) b; cx a, b; }
    "body":
    node.GateBody([
        node.CustomUnitary([
            node.Id("cx", 0, ""),
            node.PrimaryList([node.Id("a", 0, ""),
                              node.Id("b", 0, "")])
        ]),
        node.CustomUnitary([
            node.Id("u1", 0, ""),
            node.ExpressionList([node.Id("theta", 0, "")]),
            node.PrimaryList([node.Id("b", 0, "")])
        ]),
        node.CustomUnitary([
            node.Id("cx", 0, ""),
            node.PrimaryList([node.Id("a", 0, ""),
                              node.Id("b", 0, "")])
        ])
    ])
}