AND

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

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

For the AND operation the state \(|1\rangle\) is interpreted as True. The result qubit is flipped, if the state of all variable qubits is True. In this format, the AND operation equals a multi-controlled X gate, which is controlled on all variable qubits. Using a list of flags however, qubits can be skipped or negated. Practically, the flags allow to skip controls or to apply pre- and post-X gates to the negated qubits.

The AND gate without special flags equals the multi-controlled-X gate:

../_images/qiskit.circuit.library.AND_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 and the last two are True we use the flags [-1, 0, 0, 1, 1].

../_images/qiskit.circuit.library.AND_1_0.png

Create a new logical AND 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

AND.clbits

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

AND.data

Return the circuit data (instructions and context).

AND.extension_lib

AND.header

AND.instances

AND.n_qubits

Deprecated, use num_qubits instead.

AND.num_clbits

Return number of classical bits.

AND.num_parameters

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

AND.num_qubits

Return number of qubits.

AND.parameters

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

AND.prefix

AND.qubits

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

Methods

AND.AND(qr_variables, qb_target, qr_ancillae)

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

AND.OR(qr_variables, qb_target, qr_ancillae)

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

AND.__getitem__(item)

Return indexed operation.

AND.__len__()

Return number of operations in circuit.

AND.add_register(*regs)

Add registers.

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

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

AND.assign_parameters(param_dict[, inplace])

Assign parameters to new parameters or values.

AND.barrier(*qargs)

Apply Barrier.

AND.bind_parameters(value_dict)

Assign numeric parameters to values yielding a new circuit.

AND.cast(value, _type)

Best effort to cast value to type.

AND.cbit_argument_conversion(…)

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

AND.ccx(control_qubit1, control_qubit2, …)

Apply CCXGate.

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

Apply CHGate.

AND.cls_instances()

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

AND.cls_prefix()

Return the prefix to use for auto naming.

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

Apply CXGate.

AND.combine(rhs)

Append rhs to self if self contains compatible registers.

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

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

AND.copy([name])

Copy the circuit.

AND.count_ops()

Count each operation kind in the circuit.

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

Apply CRXGate.

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

Apply CRYGate.

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

Apply CRZGate.

AND.cswap(control_qubit, target_qubit1, …)

Apply CSwapGate.

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

Apply CU1Gate.

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

Apply CU3Gate.

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

Apply CXGate.

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

Apply CYGate.

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

Apply CZGate.

AND.dcx(qubit1, qubit2)

Apply DCXGate.

AND.decompose()

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

AND.depth()

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

AND.diag_gate(diag, qubit)

Deprecated version of QuantumCircuit.diagonal.

AND.diagonal(diag, qubit)

Attach a diagonal gate to a circuit.

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

Draw the quantum circuit.

AND.extend(rhs)

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

AND.fredkin(control_qubit, target_qubit1, …)

Apply CSwapGate.

AND.from_qasm_file(path)

Take in a QASM file and generate a QuantumCircuit object.

AND.from_qasm_str(qasm_str)

Take in a QASM string and generate a QuantumCircuit object.

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

Apply HGate.

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

Apply hamiltonian evolution to to qubits.

AND.has_register(register)

Test if this circuit has the register r.

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

Apply IGate.

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

Apply IGate.

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

Deprecated identity gate.

AND.initialize(params, qubits)

Apply initialize to circuit.

AND.inverse()

Invert this circuit.

AND.iso(isometry, q_input, q_ancillas_for_output)

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

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

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

AND.iswap(qubit1, qubit2)

Apply iSwapGate.

AND.mcmt(gate, control_qubits, target_qubits)

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

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

Apply Multiple-Controlled X rotation gate

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

Apply Multiple-Controlled Y rotation gate

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

Apply Multiple-Controlled Z rotation gate

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

Apply MCXGate.

AND.mcu1(lam, control_qubits, target_qubit)

Apply MCU1Gate.

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

Apply MCXGate.

AND.measure(qubit, cbit)

Measure quantum bit into classical bit (tuples).

AND.measure_active([inplace])

Adds measurement to all non-idle qubits.

AND.measure_all([inplace])

Adds measurement to all qubits.

AND.mirror()

Mirror the circuit by reversing the instructions.

AND.ms(theta, qubits)

Apply MSGate.

AND.num_connected_components([unitary_only])

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

AND.num_nonlocal_gates()

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

AND.num_tensor_factors()

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

AND.num_unitary_factors()

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

AND.qasm([formatted, filename])

Return OpenQASM string.

AND.qbit_argument_conversion(…)

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

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

Apply RGate.

AND.rcccx(control_qubit1, control_qubit2, …)

Apply RC3XGate.

AND.rccx(control_qubit1, control_qubit2, …)

Apply RCCXGate.

AND.remove_final_measurements([inplace])

Removes final measurement on all qubits if they are present.

AND.reset(qubit)

Reset q.

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

Apply RXGate.

AND.rxx(theta, qubit1, qubit2)

Apply RXXGate.

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

Apply RYGate.

AND.ryy(theta, qubit1, qubit2)

Apply RYYGate.

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

Apply RZGate.

AND.rzx(theta, qubit1, qubit2)

Apply RZXGate.

AND.rzz(theta, qubit1, qubit2)

Apply RZZGate.

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

Apply SGate.

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

Apply SdgGate.

AND.size()

Returns total number of gate operations in circuit.

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

Take a statevector snapshot of the internal simulator representation.

AND.snapshot_density_matrix(label[, qubits])

Take a density matrix snapshot of simulator state.

AND.snapshot_expectation_value(label, op, qubits)

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

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

Take a probability snapshot of the simulator state.

AND.snapshot_stabilizer(label)

Take a stabilizer snapshot of the simulator state.

AND.snapshot_statevector(label)

Take a statevector snapshot of the simulator state.

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

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

AND.swap(qubit1, qubit2)

Apply SwapGate.

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

Apply TGate.

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

Apply TdgGate.

AND.to_gate([parameter_map])

Create a Gate out of this circuit.

AND.to_instruction([parameter_map])

Create an Instruction out of this circuit.

AND.toffoli(control_qubit1, control_qubit2, …)

Apply CCXGate.

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

Apply U1Gate.

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

Apply U2Gate.

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

Apply U3Gate.

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

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

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

Deprecated version of uc.

AND.ucrx(angle_list, q_controls, q_target)

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

AND.ucry(angle_list, q_controls, q_target)

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

AND.ucrz(angle_list, q_controls, q_target)

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

AND.ucx(angle_list, q_controls, q_target)

Deprecated version of ucrx.

AND.ucy(angle_list, q_controls, q_target)

Deprecated version of ucry.

AND.ucz(angle_list, q_controls, q_target)

Deprecated version of ucrz.

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

Apply unitary gate to q.

AND.width()

Return number of qubits plus clbits in circuit.

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

Apply XGate.

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

Apply YGate.

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

Apply ZGate.

AND.__getitem__(item)

Return indexed operation.

AND.__len__()

Return number of operations in circuit.