Permutation

class Permutation(num_qubits, pattern=None, seed=None)[source]

An n_qubit circuit that permutes qubits.

Return an n_qubit permutation circuit implemented using SWAPs.

Parameters
  • num_qubits (int) – circuit width.

  • pattern (Optional[List[int]]) – permutation pattern. If None, permute randomly.

  • seed (Optional[int]) – random seed in case a random permutation is requested.

Raises

CircuitError – if permutation pattern is malformed.

Reference Circuit:
../_images/qiskit.circuit.library.Permutation_0_0.png
Expanded Circuit:
../_images/qiskit.circuit.library.Permutation_1_0.png

Attributes

Permutation.clbits

Returns a list of classical bits in the order that the registers were added.

Permutation.data

Return the circuit data (instructions and context).

Permutation.extension_lib

Permutation.header

Permutation.instances

Permutation.n_qubits

Deprecated, use num_qubits instead.

Permutation.num_clbits

Return number of classical bits.

Permutation.num_parameters

Convenience function to get the number of parameter objects in the circuit.

Permutation.num_qubits

Return number of qubits.

Permutation.parameters

Convenience function to get the parameters defined in the parameter table.

Permutation.prefix

Permutation.qubits

Returns a list of quantum bits in the order that the registers were added.

Methods

Permutation.AND(qr_variables, qb_target, …)

Build a collective conjunction (AND) circuit in place using mct.

Permutation.OR(qr_variables, qb_target, …)

Build a collective disjunction (OR) circuit in place using mct.

Permutation.__getitem__(item)

Return indexed operation.

Permutation.__len__()

Return number of operations in circuit.

Permutation.add_register(*regs)

Add registers.

Permutation.append(instruction[, qargs, cargs])

Append one or more instructions to the end of the circuit, modifying the circuit in place.

Permutation.assign_parameters(param_dict[, …])

Assign parameters to new parameters or values.

Permutation.barrier(*qargs)

Apply Barrier.

Permutation.bind_parameters(value_dict)

Assign numeric parameters to values yielding a new circuit.

Permutation.cast(value, _type)

Best effort to cast value to type.

Permutation.cbit_argument_conversion(…)

Converts several classical bit representations (such as indexes, range, etc.) into a list of classical bits.

Permutation.ccx(control_qubit1, …[, ctl1, …])

Apply CCXGate.

Permutation.ch(control_qubit, target_qubit, *)

Apply CHGate.

Permutation.cls_instances()

Return the current number of instances of this class, useful for auto naming.

Permutation.cls_prefix()

Return the prefix to use for auto naming.

Permutation.cnot(control_qubit, target_qubit, *)

Apply CXGate.

Permutation.combine(rhs)

Append rhs to self if self contains compatible registers.

Permutation.compose(other[, qubits, clbits, …])

Compose circuit with other circuit or instruction, optionally permuting wires.

Permutation.copy([name])

Copy the circuit.

Permutation.count_ops()

Count each operation kind in the circuit.

Permutation.crx(theta, control_qubit, …[, …])

Apply CRXGate.

Permutation.cry(theta, control_qubit, …[, …])

Apply CRYGate.

Permutation.crz(theta, control_qubit, …[, …])

Apply CRZGate.

Permutation.cswap(control_qubit, …[, …])

Apply CSwapGate.

Permutation.cu1(theta, control_qubit, …[, …])

Apply CU1Gate.

Permutation.cu3(theta, phi, lam, …[, …])

Apply CU3Gate.

Permutation.cx(control_qubit, target_qubit, *)

Apply CXGate.

Permutation.cy(control_qubit, target_qubit, *)

Apply CYGate.

Permutation.cz(control_qubit, target_qubit, *)

Apply CZGate.

Permutation.dcx(qubit1, qubit2)

Apply DCXGate.

Permutation.decompose()

Call a decomposition pass on this circuit, to decompose one level (shallow decompose).

Permutation.depth()

Return circuit depth (i.e., length of critical path).

Permutation.diag_gate(diag, qubit)

Deprecated version of QuantumCircuit.diagonal.

Permutation.diagonal(diag, qubit)

Attach a diagonal gate to a circuit.

Permutation.draw([output, scale, filename, …])

Draw the quantum circuit.

Permutation.extend(rhs)

Append QuantumCircuit to the right hand side if it contains compatible registers.

Permutation.fredkin(control_qubit, …[, …])

Apply CSwapGate.

Permutation.from_qasm_file(path)

Take in a QASM file and generate a QuantumCircuit object.

Permutation.from_qasm_str(qasm_str)

Take in a QASM string and generate a QuantumCircuit object.

Permutation.h(qubit, *[, q])

Apply HGate.

Permutation.hamiltonian(operator, time, qubits)

Apply hamiltonian evolution to to qubits.

Permutation.has_register(register)

Test if this circuit has the register r.

Permutation.i(qubit, *[, q])

Apply IGate.

Permutation.id(qubit, *[, q])

Apply IGate.

Permutation.iden(qubit, *[, q])

Deprecated identity gate.

Permutation.initialize(params, qubits)

Apply initialize to circuit.

Permutation.inverse()

Invert this circuit.

Permutation.iso(isometry, q_input, …[, …])

Attach an arbitrary isometry from m to n qubits to a circuit.

Permutation.isometry(isometry, q_input, …)

Attach an arbitrary isometry from m to n qubits to a circuit.

Permutation.iswap(qubit1, qubit2)

Apply iSwapGate.

Permutation.mcmt(gate, control_qubits, …)

Apply a multi-control, multi-target using a generic gate.

Permutation.mcrx(theta, q_controls, q_target)

Apply Multiple-Controlled X rotation gate

Permutation.mcry(theta, q_controls, …[, …])

Apply Multiple-Controlled Y rotation gate

Permutation.mcrz(lam, q_controls, q_target)

Apply Multiple-Controlled Z rotation gate

Permutation.mct(control_qubits, target_qubit)

Apply MCXGate.

Permutation.mcu1(lam, control_qubits, …)

Apply MCU1Gate.

Permutation.mcx(control_qubits, target_qubit)

Apply MCXGate.

Permutation.measure(qubit, cbit)

Measure quantum bit into classical bit (tuples).

Permutation.measure_active([inplace])

Adds measurement to all non-idle qubits.

Permutation.measure_all([inplace])

Adds measurement to all qubits.

Permutation.mirror()

Mirror the circuit by reversing the instructions.

Permutation.ms(theta, qubits)

Apply MSGate.

Permutation.num_connected_components([…])

How many non-entangled subcircuits can the circuit be factored to.

Permutation.num_nonlocal_gates()

Return number of non-local gates (i.e.

Permutation.num_tensor_factors()

Computes the number of tensor factors in the unitary (quantum) part of the circuit only.

Permutation.num_unitary_factors()

Computes the number of tensor factors in the unitary (quantum) part of the circuit only.

Permutation.qasm([formatted, filename])

Return OpenQASM string.

Permutation.qbit_argument_conversion(…)

Converts several qubit representations (such as indexes, range, etc.) into a list of qubits.

Permutation.r(theta, phi, qubit, *[, q])

Apply RGate.

Permutation.rcccx(control_qubit1, …)

Apply RC3XGate.

Permutation.rccx(control_qubit1, …)

Apply RCCXGate.

Permutation.remove_final_measurements([inplace])

Removes final measurement on all qubits if they are present.

Permutation.reset(qubit)

Reset q.

Permutation.rx(theta, qubit, *[, label, q])

Apply RXGate.

Permutation.rxx(theta, qubit1, qubit2)

Apply RXXGate.

Permutation.ry(theta, qubit, *[, label, q])

Apply RYGate.

Permutation.ryy(theta, qubit1, qubit2)

Apply RYYGate.

Permutation.rz(phi, qubit, *[, q])

Apply RZGate.

Permutation.rzx(theta, qubit1, qubit2)

Apply RZXGate.

Permutation.rzz(theta, qubit1, qubit2)

Apply RZZGate.

Permutation.s(qubit, *[, q])

Apply SGate.

Permutation.sdg(qubit, *[, q])

Apply SdgGate.

Permutation.size()

Returns total number of gate operations in circuit.

Permutation.snapshot(label[, snapshot_type, …])

Take a statevector snapshot of the internal simulator representation.

Permutation.snapshot_density_matrix(label[, …])

Take a density matrix snapshot of simulator state.

Permutation.snapshot_expectation_value(…)

Take a snapshot of expectation value <O> of an Operator.

Permutation.snapshot_probabilities(label, qubits)

Take a probability snapshot of the simulator state.

Permutation.snapshot_stabilizer(label)

Take a stabilizer snapshot of the simulator state.

Permutation.snapshot_statevector(label)

Take a statevector snapshot of the simulator state.

Permutation.squ(unitary_matrix, qubit[, …])

Decompose an arbitrary 2*2 unitary into three rotation gates.

Permutation.swap(qubit1, qubit2)

Apply SwapGate.

Permutation.t(qubit, *[, q])

Apply TGate.

Permutation.tdg(qubit, *[, q])

Apply TdgGate.

Permutation.to_gate([parameter_map])

Create a Gate out of this circuit.

Permutation.to_instruction([parameter_map])

Create an Instruction out of this circuit.

Permutation.toffoli(control_qubit1, …[, …])

Apply CCXGate.

Permutation.u1(theta, qubit, *[, q])

Apply U1Gate.

Permutation.u2(phi, lam, qubit, *[, q])

Apply U2Gate.

Permutation.u3(theta, phi, lam, qubit, *[, q])

Apply U3Gate.

Permutation.uc(gate_list, q_controls, q_target)

Attach a uniformly controlled gates (also called multiplexed gates) to a circuit.

Permutation.ucg(angle_list, q_controls, q_target)

Deprecated version of uc.

Permutation.ucrx(angle_list, q_controls, …)

Attach a uniformly controlled (also called multiplexed) Rx rotation gate to a circuit.

Permutation.ucry(angle_list, q_controls, …)

Attach a uniformly controlled (also called multiplexed) Ry rotation gate to a circuit.

Permutation.ucrz(angle_list, q_controls, …)

Attach a uniformly controlled (also called multiplexed gates) Rz rotation gate to a circuit.

Permutation.ucx(angle_list, q_controls, q_target)

Deprecated version of ucrx.

Permutation.ucy(angle_list, q_controls, q_target)

Deprecated version of ucry.

Permutation.ucz(angle_list, q_controls, q_target)

Deprecated version of ucrz.

Permutation.unitary(obj, qubits[, label])

Apply unitary gate to q.

Permutation.width()

Return number of qubits plus clbits in circuit.

Permutation.x(qubit, *[, label, ctrl_state, q])

Apply XGate.

Permutation.y(qubit, *[, q])

Apply YGate.

Permutation.z(qubit, *[, q])

Apply ZGate.

Permutation.__len__()

Return number of operations in circuit.

Permutation.__getitem__(item)

Return indexed operation.