QuantumCircuit.reverse_ops

QuantumCircuit.reverse_ops()[source]

Reverse the circuit by reversing the order of instructions.

This is done by recursively reversing all instructions. It does not invert (adjoint) any gate.

Returns

the reversed circuit.

Return type

QuantumCircuit

Examples

input:

┌───┐

q_0: ┤ H ├─────■──────

└───┘┌────┴─────┐

q_1: ─────┤ RX(1.57) ├

└──────────┘

output:

┌───┐

q_0: ─────■──────┤ H ├

┌────┴─────┐└───┘

q_1: ┤ RX(1.57) ├─────

└──────────┘