From 8230ba2f5918fb69306815f990572beeb112f625 Mon Sep 17 00:00:00 2001 From: minwook Date: Fri, 29 Sep 2023 12:10:22 +0900 Subject: [PATCH] Add feature to show the direction of CX gate example : (1, ['cx_{q0, q1}']) --- .../converters/quantum_circuit_to_matrix.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qiskit_class_converter/converters/quantum_circuit_to_matrix.py b/qiskit_class_converter/converters/quantum_circuit_to_matrix.py index d86b379..34e4acc 100644 --- a/qiskit_class_converter/converters/quantum_circuit_to_matrix.py +++ b/qiskit_class_converter/converters/quantum_circuit_to_matrix.py @@ -43,7 +43,10 @@ def actual_convert_action(self): for layer in dag.layers(): circuit = self.qiskit.converters.dag_to_circuit(layer['graph']) matrix_list["gate"].append(self.qiskit.quantum_info.Operator(circuit).to_matrix()) - matrix_list["name"].append((layer_index, [_inst[0].name for _inst in circuit.data])) + matrix_list["name"].append((layer_index, [_inst[0].name + "_{q" + str(_inst.qubits[0].index) + ", q" + + str(_inst.qubits[1].index) + "}" + if _inst[0].name == "cx" + else _inst[0].name for _inst in circuit.data])) layer_index += 1 matrix_list["result"] = self.qiskit.quantum_info.Operator(self.input_value).to_matrix() if self.option.get("print", False) == "raw":