Skip to content

Commit

Permalink
Add feature to show the direction of CCX gate
Browse files Browse the repository at this point in the history
example : (1, 'ccx_{q0, q1, q2}')
  • Loading branch information
minwook-shin committed Sep 29, 2023
1 parent 8230ba2 commit 2d8d172
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions qiskit_class_converter/converters/quantum_circuit_to_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,18 @@ 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 + "_{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]))
gate_name = ""
for _inst in circuit.data:
if _inst[0].name == "cx":
gate_name = (_inst[0].name +
"_{q" + str(_inst.qubits[0].index) + ", q" + str(_inst.qubits[1].index) + "}")
elif _inst[0].name == "ccx":
gate_name = (_inst[0].name +
"_{q" + str(_inst.qubits[0].index) + ", q" + str(_inst.qubits[1].index) +
", q" + str(_inst.qubits[2].index) + "}")
else:
gate_name = _inst[0].name
matrix_list["name"].append((layer_index, gate_name))
layer_index += 1
matrix_list["result"] = self.qiskit.quantum_info.Operator(self.input_value).to_matrix()
if self.option.get("print", False) == "raw":
Expand Down

0 comments on commit 2d8d172

Please sign in to comment.