From d21125069c37b03cd07f3e2893a41797843210a8 Mon Sep 17 00:00:00 2001 From: Kotani-UT Date: Fri, 9 Aug 2024 14:06:44 +0900 Subject: [PATCH] fix some bugs --- qdd/qdd_backend.py | 4 ++-- src/dd.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qdd/qdd_backend.py b/qdd/qdd_backend.py index aee87ff..88536d3 100644 --- a/qdd/qdd_backend.py +++ b/qdd/qdd_backend.py @@ -420,7 +420,7 @@ def merge_circuit(self, circ:QiskitCircuit, gc_freq=20): matrix = _qiskit_gates_2q_0param[qiskit_gate_type]() elif qiskit_gate_type in _qiskit_gates_2q_1param: matrix = _qiskit_gates_2q_1param[qiskit_gate_type](i.params[0]) - gate = pyQDD.makeTwoQubitGate(n_qubit, matrix, self.get_qID(qargs[-2]), self.get_qID(qargs[-1]), controls) + gate = pyQDD.makeTwoQubitGate(n_qubit, matrix, self.get_qID(qargs[-1]), self.get_qID(qargs[-2]), controls) current = pyQDD.mm_multiply(gate, current) elif qiskit_gate_type in _qiskit_gates_large: matrix = i.to_matrix() @@ -624,7 +624,7 @@ def _evaluate_circuit(self, circ: QiskitCircuit, circ_prop: CircuitProperty, opt matrix = _qiskit_gates_2q_0param[qiskit_gate_type]() elif qiskit_gate_type in _qiskit_gates_2q_1param: matrix = _qiskit_gates_2q_1param[qiskit_gate_type](i.params[0]) - gate = pyQDD.makeTwoQubitGate(n_qubit, matrix, map_after_swap[self.get_qID(qargs[-2])], map_after_swap[self.get_qID(qargs[-1])], controls) + gate = pyQDD.makeTwoQubitGate(n_qubit, matrix, map_after_swap[self.get_qID(qargs[-1])], map_after_swap[self.get_qID(qargs[-2])], controls) current = pyQDD.mv_multiply(gate, current) if use_mpi ==False else pyQDD.mv_multiply_MPI(gate, current, n_qubit, max([map_after_swap[self.get_qID(i)] for i in qargs])) if use_bcast==False else pyQDD.mv_multiply_MPI_bcast(gate, current, n_qubit, max([map_after_swap[self.get_qID(i)] for i in qargs])) elif qiskit_gate_type in _qiskit_gates_unitary: matrix = i.to_matrix() diff --git a/src/dd.cpp b/src/dd.cpp index ec63237..a2d4f3f 100644 --- a/src/dd.cpp +++ b/src/dd.cpp @@ -521,7 +521,7 @@ mEdge makeLargeGate(const ComplexMatrix &g){ mEdge makeLargeGate(const ComplexMatrix &g, const Qubit level, const std::size_t rowStart, const std::size_t rowEnd, const std::size_t colStart, const std::size_t colEnd){ if (level == 0){ assert (rowEnd - rowStart == 2 && colEnd - colStart == 2); - return makeMEdge(2, {mEdge{{g[rowStart][colStart].real(), g[rowStart][colStart].imag()}, mNode::terminal}, + return makeMEdge(0, {mEdge{{g[rowStart][colStart].real(), g[rowStart][colStart].imag()}, mNode::terminal}, mEdge{{g[rowStart][colStart+1].real(), g[rowStart][colStart+1].imag()}, mNode::terminal}, mEdge{{g[rowStart+1][colStart].real(), g[rowStart+1][colStart].imag()}, mNode::terminal}, mEdge{{g[rowStart+1][colStart+1].real(), g[rowStart+1][colStart+1].imag()}, mNode::terminal}});