Skip to content

Commit

Permalink
add reset to standard_gate_instruction (Qiskit#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseclectic authored and gadial committed Apr 22, 2019
1 parent 2451bff commit 9453879
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions qiskit/providers/aer/noise/errors/errorutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,30 @@ def standard_gate_instruction(instruction, ignore_phase=True):
Returns:
list: a list of qobj instructions equivalent to in input instruction.
"""
if instruction.get("name", None) not in ["mat", "unitary"]:
return [instruction]

name = instruction.get("name", None)
if name not in ["mat", "unitary", "kraus"]:
return [instruction]
qubits = instruction["qubits"]
mat_dagger = np.conj(instruction["params"])
params = instruction["params"]

# Check for single-qubit reset Kraus
if name == "kraus":
if len(qubits) == 1:
superop = SuperOp(Kraus(params))
# Check if reset to |0>
reset0 = reset_superop(1)
if superop == reset0:
return [{"name": "reset", "qubits": qubits}]
# Check if reset to |1>
reset1 = reset0.compose(Operator(standard_gate_unitary('x')))
if superop == reset1:
return [{"name": "reset", "qubits": qubits}, {"name": "x", "qubits": qubits}]
# otherwise just return the kraus instruction
return [instruction]

# Check single qubit gates
mat_dagger = np.conj(params)
if len(qubits) == 1:
# Check clifford gates
for j in range(24):
Expand Down

0 comments on commit 9453879

Please sign in to comment.