OR

class OR(num_variable_qubits, flags=None, mcx_mode='noancilla')[source]

A circuit implementing the logical OR operation on a number of qubits.

For the OR operation the state \(|1\rangle\) is interpreted as True. The result qubit is flipped, if the state of any variable qubit is True. The OR is implemented using a multi-open-controlled X gate (i.e. flips if the state is \(|0\rangle\)) and applying an X gate on the result qubit. Using a list of flags, qubits can be skipped or negated.

The OR gate without special flags:

../_images/qiskit.circuit.library.OR_0_0.png

Using flags we can negate qubits or skip them. For instance, if we have 5 qubits and want to return True if the first qubit is False or one of the last two are True we use the flags [-1, 0, 0, 1, 1].

../_images/qiskit.circuit.library.OR_1_0.png

Create a new logical OR circuit.

Parameters
  • num_variable_qubits (int) – The qubits of which the OR is computed. The result will be written into an additional result qubit.

  • flags (Optional[List[int]]) – A list of +1/0/-1 marking negations or omisiions of qubits.

  • mcx_mode (str) – The mode to be used to implement the multi-controlled X gate.

Attributes

OR.clbits

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

OR.data

Return the circuit data (instructions and context).

OR.extension_lib

OR.header

OR.instances

OR.n_qubits

Deprecated, use num_qubits instead.

OR.num_clbits

Return number of classical bits.

OR.num_parameters

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

OR.num_qubits

Return number of qubits.

OR.parameters

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

OR.prefix

OR.qubits

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

Methods

OR.AND(qr_variables, qb_target, qr_ancillae)

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

OR.OR(qr_variables, qb_target, qr_ancillae)

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

OR.__getitem__(item)

Return indexed operation.

OR.__len__()

Return number of operations in circuit.

OR.add_register(*regs)

Add registers.

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

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

OR.assign_parameters(param_dict[, inplace])

Assign parameters to new parameters or values.

OR.barrier(*qargs)

Apply Barrier.

OR.bind_parameters(value_dict)

Assign numeric parameters to values yielding a new circuit.

OR.cast(value, _type)

Best effort to cast value to type.

OR.cbit_argument_conversion(clbit_representation)

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

OR.ccx(control_qubit1, control_qubit2, …)

Apply CCXGate.

OR.ch(control_qubit, target_qubit, *[, …])

Apply CHGate.

OR.cls_instances()

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

OR.cls_prefix()

Return the prefix to use for auto naming.

OR.cnot(control_qubit, target_qubit, *[, …])

Apply CXGate.

OR.combine(rhs)

Append rhs to self if self contains compatible registers.

OR.compose(other[, qubits, clbits, front, …])

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

OR.copy([name])

Copy the circuit.

OR.count_ops()

Count each operation kind in the circuit.

OR.crx(theta, control_qubit, target_qubit, *)

Apply CRXGate.

OR.cry(theta, control_qubit, target_qubit, *)

Apply CRYGate.

OR.crz(theta, control_qubit, target_qubit, *)

Apply CRZGate.

OR.cswap(control_qubit, target_qubit1, …)

Apply CSwapGate.

OR.cu1(theta, control_qubit, target_qubit, *)

Apply CU1Gate.

OR.cu3(theta, phi, lam, control_qubit, …)

Apply CU3Gate.

OR.cx(control_qubit, target_qubit, *[, …])

Apply CXGate.

OR.cy(control_qubit, target_qubit, *[, …])

Apply CYGate.

OR.cz(control_qubit, target_qubit, *[, …])

Apply CZGate.

OR.dcx(qubit1, qubit2)

Apply DCXGate.

OR.decompose()

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

OR.depth()

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

OR.diag_gate(diag, qubit)

Deprecated version of QuantumCircuit.diagonal.

OR.diagonal(diag, qubit)

Attach a diagonal gate to a circuit.

OR.draw([output, scale, filename, style, …])

Draw the quantum circuit.

OR.extend(rhs)

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

OR.fredkin(control_qubit, target_qubit1, …)

Apply CSwapGate.

OR.from_qasm_file(path)

Take in a QASM file and generate a QuantumCircuit object.

OR.from_qasm_str(qasm_str)

Take in a QASM string and generate a QuantumCircuit object.

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

Apply HGate.

OR.hamiltonian(operator, time, qubits[, label])

Apply hamiltonian evolution to to qubits.

OR.has_register(register)

Test if this circuit has the register r.

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

Apply IGate.

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

Apply IGate.

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

Deprecated identity gate.

OR.initialize(params, qubits)

Apply initialize to circuit.

OR.inverse()

Invert this circuit.

OR.iso(isometry, q_input, q_ancillas_for_output)

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

OR.isometry(isometry, q_input, …[, …])

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

OR.iswap(qubit1, qubit2)

Apply iSwapGate.

OR.mcmt(gate, control_qubits, target_qubits)

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

OR.mcrx(theta, q_controls, q_target[, …])

Apply Multiple-Controlled X rotation gate

OR.mcry(theta, q_controls, q_target, q_ancillae)

Apply Multiple-Controlled Y rotation gate

OR.mcrz(lam, q_controls, q_target[, …])

Apply Multiple-Controlled Z rotation gate

OR.mct(control_qubits, target_qubit[, …])

Apply MCXGate.

OR.mcu1(lam, control_qubits, target_qubit)

Apply MCU1Gate.

OR.mcx(control_qubits, target_qubit[, …])

Apply MCXGate.

OR.measure(qubit, cbit)

Measure quantum bit into classical bit (tuples).

OR.measure_active([inplace])

Adds measurement to all non-idle qubits.

OR.measure_all([inplace])

Adds measurement to all qubits.

OR.mirror()

Mirror the circuit by reversing the instructions.

OR.ms(theta, qubits)

Apply MSGate.

OR.num_connected_components([unitary_only])

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

OR.num_nonlocal_gates()

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

OR.num_tensor_factors()

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

OR.num_unitary_factors()

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

OR.qasm([formatted, filename])

Return OpenQASM string.

OR.qbit_argument_conversion(qubit_representation)

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

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

Apply RGate.

OR.rcccx(control_qubit1, control_qubit2, …)

Apply RC3XGate.

OR.rccx(control_qubit1, control_qubit2, …)

Apply RCCXGate.

OR.remove_final_measurements([inplace])

Removes final measurement on all qubits if they are present.

OR.reset(qubit)

Reset q.

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

Apply RXGate.

OR.rxx(theta, qubit1, qubit2)

Apply RXXGate.

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

Apply RYGate.

OR.ryy(theta, qubit1, qubit2)

Apply RYYGate.

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

Apply RZGate.

OR.rzx(theta, qubit1, qubit2)

Apply RZXGate.

OR.rzz(theta, qubit1, qubit2)

Apply RZZGate.

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

Apply SGate.

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

Apply SdgGate.

OR.size()

Returns total number of gate operations in circuit.

OR.snapshot(label[, snapshot_type, qubits, …])

Take a statevector snapshot of the internal simulator representation.

OR.snapshot_density_matrix(label[, qubits])

Take a density matrix snapshot of simulator state.

OR.snapshot_expectation_value(label, op, qubits)

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

OR.snapshot_probabilities(label, qubits[, …])

Take a probability snapshot of the simulator state.

OR.snapshot_stabilizer(label)

Take a stabilizer snapshot of the simulator state.

OR.snapshot_statevector(label)

Take a statevector snapshot of the simulator state.

OR.squ(unitary_matrix, qubit[, mode, …])

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

OR.swap(qubit1, qubit2)

Apply SwapGate.

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

Apply TGate.

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

Apply TdgGate.

OR.to_gate([parameter_map])

Create a Gate out of this circuit.

OR.to_instruction([parameter_map])

Create an Instruction out of this circuit.

OR.toffoli(control_qubit1, control_qubit2, …)

Apply CCXGate.

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

Apply U1Gate.

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

Apply U2Gate.

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

Apply U3Gate.

OR.uc(gate_list, q_controls, q_target[, …])

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

OR.ucg(angle_list, q_controls, q_target[, …])

Deprecated version of uc.

OR.ucrx(angle_list, q_controls, q_target)

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

OR.ucry(angle_list, q_controls, q_target)

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

OR.ucrz(angle_list, q_controls, q_target)

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

OR.ucx(angle_list, q_controls, q_target)

Deprecated version of ucrx.

OR.ucy(angle_list, q_controls, q_target)

Deprecated version of ucry.

OR.ucz(angle_list, q_controls, q_target)

Deprecated version of ucrz.

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

Apply unitary gate to q.

OR.width()

Return number of qubits plus clbits in circuit.

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

Apply XGate.

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

Apply YGate.

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

Apply ZGate.

OR.__getitem__(item)

Return indexed operation.

OR.__len__()

Return number of operations in circuit.