How to use the qutip.qip.circuit.Gate function in qutip

To help you get started, we’ve selected a few qutip examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qutip / qutip / qutip / qip / models / cqed.py View on Github external
Returns QubitCircuit of resolved gates for the qubit circuit in the
            desired basis.
        """
        qc = QubitCircuit(qc1.N, qc1.reverse_states)

        for gate in qc1.gates:
            qc.gates.append(gate)
            if rwa:
                if gate.name == "SQRTISWAP":
                    qc.gates.append(Gate("RZ", [gate.targets[0]], None,
                                         arg_value=-np.pi / 4,
                                         arg_label=r"-\pi/4"))
                    qc.gates.append(Gate("RZ", [gate.targets[1]], None,
                                         arg_value=-np.pi / 4,
                                         arg_label=r"-\pi/4"))
                    qc.gates.append(Gate("GLOBALPHASE", None, None,
                                         arg_value=-np.pi / 4,
                                         arg_label=r"-\pi/4"))
                elif gate.name == "ISWAP":
                    qc.gates.append(Gate("RZ", [gate.targets[0]], None,
                                         arg_value=-np.pi / 2,
                                         arg_label=r"-\pi/2"))
                    qc.gates.append(Gate("RZ", [gate.targets[1]], None,
                                         arg_value=-np.pi / 2,
                                         arg_label=r"-\pi/2"))
                    qc.gates.append(Gate("GLOBALPHASE", None, None,
                                         arg_value=-np.pi / 2,
                                         arg_label=r"-\pi/2"))

        return qc
github qutip / qutip / qutip / qip / circuit.py View on Github external
def _gate_SNOT(self, gate, temp_resolved):
        half_pi = np.pi / 2
        temp_resolved.append(Gate("GLOBALPHASE", None, None,
                                  arg_value=half_pi,
                                  arg_label=r"\pi/2"))
        temp_resolved.append(Gate("RY", gate.targets, None,
                                  arg_value=half_pi,
                                  arg_label=r"\pi/2"))
        temp_resolved.append(Gate("RX", gate.targets, None,
                                  arg_value=np.pi, arg_label=r"\pi"))
github qutip / qutip / qutip / qip / circuit.py View on Github external
def _basis_CSIGN(self, qc_temp, temp_resolved):
        half_pi = np.pi / 2
        for gate in temp_resolved:
            if gate.name == "CNOT":
                qc_temp.gates.append(Gate("RY", gate.targets, None,
                                          arg_value=-half_pi,
                                          arg_label=r"-\pi/2"))
                qc_temp.gates.append(Gate("CSIGN", gate.targets,
                                          gate.controls))
                qc_temp.gates.append(Gate("RY", gate.targets, None,
                                          arg_value=half_pi,
                                          arg_label=r"\pi/2"))
            else:
                qc_temp.gates.append(gate)
github qutip / qutip / qutip / qip / circuit.py View on Github external
arg_label=r"\pi/2"))
            elif gate.name == "SWAP":
                qc_temp.gates.append(Gate("GLOBALPHASE", None, None,
                                          arg_value=quarter_pi,
                                          arg_label=r"\pi/4"))
                qc_temp.gates.append(Gate("ISWAP", gate.targets, None))
                qc_temp.gates.append(Gate("RX", gate.targets[0], None,
                                          arg_value=-half_pi,
                                          arg_label=r"-\pi/2"))
                qc_temp.gates.append(Gate("ISWAP", gate.targets, None))
                qc_temp.gates.append(Gate("RX", gate.targets[1], None,
                                          arg_value=-half_pi,
                                          arg_label=r"-\pi/2"))
                qc_temp.gates.append(Gate("ISWAP", [gate.targets[1],
                                          gate.targets[0]], None))
                qc_temp.gates.append(Gate("RX", gate.targets[0], None,
                                          arg_value=-half_pi,
                                          arg_label=r"-\pi/2"))
            else:
                qc_temp.gates.append(gate)
github qutip / qutip / qutip / qip / circuit.py View on Github external
arg_value=half_pi,
                                              arg_label=r"\pi/2"))
                elif gate.name == "RY" and "RY" not in basis_1q:
                    qc_temp.gates.append(Gate("RZ", gate.targets, None,
                                              arg_value=-half_pi,
                                              arg_label=r"-\pi/2"))
                    qc_temp.gates.append(Gate("RX", gate.targets, None,
                                              gate.arg_value, gate.arg_label))
                    qc_temp.gates.append(Gate("RZ", gate.targets, None,
                                              arg_value=half_pi,
                                              arg_label=r"\pi/2"))
                elif gate.name == "RZ" and "RZ" not in basis_1q:
                    qc_temp.gates.append(Gate("RX", gate.targets, None,
                                              arg_value=-half_pi,
                                              arg_label=r"-\pi/2"))
                    qc_temp.gates.append(Gate("RY", gate.targets, None,
                                              gate.arg_value, gate.arg_label))
                    qc_temp.gates.append(Gate("RX", gate.targets, None,
                                              arg_value=half_pi,
                                              arg_label=r"\pi/2"))
                else:
                    qc_temp.gates.append(gate)

        qc_temp.gates = deepcopy(qc_temp.gates)

        return qc_temp
github qutip / qutip / qutip / qip / circuit.py View on Github external
break
        if not match:
            qc_temp.gates = temp_resolved

        if len(basis_1q) == 2:
            temp_resolved = qc_temp.gates
            qc_temp.gates = []
            half_pi = np.pi / 2
            for gate in temp_resolved:
                if gate.name == "RX" and "RX" not in basis_1q:
                    qc_temp.gates.append(Gate("RY", gate.targets, None,
                                              arg_value=-half_pi,
                                              arg_label=r"-\pi/2"))
                    qc_temp.gates.append(Gate("RZ", gate.targets, None,
                                              gate.arg_value, gate.arg_label))
                    qc_temp.gates.append(Gate("RY", gate.targets, None,
                                              arg_value=half_pi,
                                              arg_label=r"\pi/2"))
                elif gate.name == "RY" and "RY" not in basis_1q:
                    qc_temp.gates.append(Gate("RZ", gate.targets, None,
                                              arg_value=-half_pi,
                                              arg_label=r"-\pi/2"))
                    qc_temp.gates.append(Gate("RX", gate.targets, None,
                                              gate.arg_value, gate.arg_label))
                    qc_temp.gates.append(Gate("RZ", gate.targets, None,
                                              arg_value=half_pi,
                                              arg_label=r"\pi/2"))
                elif gate.name == "RZ" and "RZ" not in basis_1q:
                    qc_temp.gates.append(Gate("RX", gate.targets, None,
                                              arg_value=-half_pi,
                                              arg_label=r"-\pi/2"))
                    qc_temp.gates.append(Gate("RY", gate.targets, None,
github qutip / qutip / qutip / qip / circuit.py View on Github external
gate.controls))
        temp_resolved.append(Gate("RZ", gate.targets[1], None,
                                  arg_value=-eigth_pi,
                                  arg_label=r"-\pi/8"))
        temp_resolved.append(Gate("CNOT", gate.targets[1],
                                  gate.targets[0]))
        temp_resolved.append(Gate("GLOBALPHASE", None, None,
                                  arg_value=half_pi,
                                  arg_label=r"\pi/2"))
        temp_resolved.append(Gate("RY", gate.targets[1], None,
                                  arg_value=half_pi,
                                  arg_label=r"\pi/2"))
        temp_resolved.append(Gate("RY", gate.targets, None,
                                  arg_value=-half_pi,
                                  arg_label=r"-\pi/2"))
        temp_resolved.append(Gate("RZ", gate.targets, None,
                                  arg_value=np.pi, arg_label=r"\pi"))
        temp_resolved.append(Gate("RY", gate.targets, None,
                                  arg_value=half_pi,
                                  arg_label=r"\pi/2"))
        temp_resolved.append(Gate("CNOT", gate.targets[0],
                                  gate.targets[1]))
github qutip / qutip / qutip / qip / circuit.py View on Github external
arg_label=r"-\pi/2"))
                qc_temp.gates.append(Gate("RX", gate.controls, None,
                                          arg_value=half_pi,
                                          arg_label=r"\pi/2"))
                qc_temp.gates.append(Gate("RX", gate.targets, None,
                                          arg_value=-half_pi,
                                          arg_label=r"-\pi/2"))
                qc_temp.gates.append(Gate("SQRTISWAP", [gate.controls[0],
                                          gate.targets[0]],
                                          None))
                qc_temp.gates.append(Gate("RX", gate.controls, None,
                                          arg_value=np.pi,
                                          arg_label=r"\pi"))
                qc_temp.gates.append(Gate("SQRTISWAP", [gate.controls[0],
                                          gate.targets[0]], None))
                qc_temp.gates.append(Gate("RY", gate.controls, None,
                                          arg_value=half_pi,
                                          arg_label=r"\pi/2"))
                qc_temp.gates.append(Gate("GLOBALPHASE", None, None,
                                          arg_value=quarter_pi,
                                          arg_label=r"\pi/4"))
                qc_temp.gates.append(Gate("RZ", gate.controls, None,
                                          arg_value=np.pi,
                                          arg_label=r"\pi"))
                qc_temp.gates.append(Gate("GLOBALPHASE", None, None,
                                          arg_value=3 * half_pi,
                                          arg_label=r"3\pi/2"))
            else:
                qc_temp.gates.append(gate)
github qutip / qutip / qutip / qip / circuit.py View on Github external
def _basis_CSIGN(self, qc_temp, temp_resolved):
        half_pi = np.pi / 2
        for gate in temp_resolved:
            if gate.name == "CNOT":
                qc_temp.gates.append(Gate("RY", gate.targets, None,
                                          arg_value=-half_pi,
                                          arg_label=r"-\pi/2"))
                qc_temp.gates.append(Gate("CSIGN", gate.targets,
                                          gate.controls))
                qc_temp.gates.append(Gate("RY", gate.targets, None,
                                          arg_value=half_pi,
                                          arg_label=r"\pi/2"))
            else:
                qc_temp.gates.append(gate)
github qutip / qutip / qutip / qip / circuit.py View on Github external
if len(basis_1q) == 2:
            temp_resolved = qc_temp.gates
            qc_temp.gates = []
            half_pi = np.pi / 2
            for gate in temp_resolved:
                if gate.name == "RX" and "RX" not in basis_1q:
                    qc_temp.gates.append(Gate("RY", gate.targets, None,
                                              arg_value=-half_pi,
                                              arg_label=r"-\pi/2"))
                    qc_temp.gates.append(Gate("RZ", gate.targets, None,
                                              gate.arg_value, gate.arg_label))
                    qc_temp.gates.append(Gate("RY", gate.targets, None,
                                              arg_value=half_pi,
                                              arg_label=r"\pi/2"))
                elif gate.name == "RY" and "RY" not in basis_1q:
                    qc_temp.gates.append(Gate("RZ", gate.targets, None,
                                              arg_value=-half_pi,
                                              arg_label=r"-\pi/2"))
                    qc_temp.gates.append(Gate("RX", gate.targets, None,
                                              gate.arg_value, gate.arg_label))
                    qc_temp.gates.append(Gate("RZ", gate.targets, None,
                                              arg_value=half_pi,
                                              arg_label=r"\pi/2"))
                elif gate.name == "RZ" and "RZ" not in basis_1q:
                    qc_temp.gates.append(Gate("RX", gate.targets, None,
                                              arg_value=-half_pi,
                                              arg_label=r"-\pi/2"))
                    qc_temp.gates.append(Gate("RY", gate.targets, None,
                                              gate.arg_value, gate.arg_label))
                    qc_temp.gates.append(Gate("RX", gate.targets, None,
                                              arg_value=half_pi,
                                              arg_label=r"\pi/2"))