IntegerComparator

class IntegerComparator(num_state_qubits=None, value=None, geq=True, name='cmp')[ソース]

Integer Comparator.

Operator compares basis states \(|i\rangle_n\) against a classically given integer \(L\) of fixed value and flips a target qubit if \(i \geq L\) (or \(<\) depending on the parameter geq):

\[|i\rangle_n |0\rangle \mapsto |i\rangle_n |i \geq L\rangle\]

This operation is based on two’s complement implementation of binary subtraction but only uses carry bits and no actual result bits. If the most significant carry bit (the results bit) is 1, the \(\geq\) condition is True otherwise it is False.

Create a new fixed value comparator circuit.

パラメータ
  • num_state_qubits (Optional[int]) – Number of state qubits. If this is set it will determine the number of qubits required for the circuit.

  • value (Optional[int]) – The fixed value to compare with.

  • geq (bool) – If True, evaluate a >= condition, else <.

  • name (str) – Name of the circuit.

Attributes

IntegerComparator.ancillas

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

IntegerComparator.clbits

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

IntegerComparator.data

Return the circuit data (instructions and context).

IntegerComparator.extension_lib

IntegerComparator.geq

Return whether the comparator compares greater or less equal.

IntegerComparator.global_phase

Return the global phase of the circuit in radians.

IntegerComparator.header

IntegerComparator.instances

IntegerComparator.n_qubits

Deprecated, use num_qubits instead.

IntegerComparator.num_ancilla_qubits

The number of ancilla qubits used.

IntegerComparator.num_ancillas

Return the number of ancilla qubits.

IntegerComparator.num_clbits

Return number of classical bits.

IntegerComparator.num_parameters

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

IntegerComparator.num_qubits

Return number of qubits.

IntegerComparator.num_state_qubits

The number of qubits encoding the state for the comparison.

IntegerComparator.parameters

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

IntegerComparator.prefix

IntegerComparator.qregs

A list of the quantum registers associated with the circuit.

IntegerComparator.qubits

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

IntegerComparator.value

The value to compare the qubit register to.

Methods

IntegerComparator.AND(qr_variables, …[, …])

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

IntegerComparator.OR(qr_variables, …[, …])

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

IntegerComparator.__getitem__(item)

Return indexed operation.

IntegerComparator.__len__()

Return number of operations in circuit.

IntegerComparator.add_register(*regs)

Add registers.

IntegerComparator.append(instruction[, …])

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

IntegerComparator.assign_parameters(param_dict)

Assign parameters to new parameters or values.

IntegerComparator.barrier(*qargs)

Apply Barrier.

IntegerComparator.bind_parameters(value_dict)

Assign numeric parameters to values yielding a new circuit.

IntegerComparator.cast(value, _type)

Best effort to cast value to type.

IntegerComparator.cbit_argument_conversion(…)

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

IntegerComparator.ccx(control_qubit1, …[, …])

Apply CCXGate.

IntegerComparator.ch(control_qubit, …[, …])

Apply CHGate.

IntegerComparator.cls_instances()

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

IntegerComparator.cls_prefix()

Return the prefix to use for auto naming.

IntegerComparator.cnot(control_qubit, …[, …])

Apply CXGate.

IntegerComparator.combine(rhs)

Append rhs to self if self contains compatible registers.

IntegerComparator.compose(other[, qubits, …])

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

IntegerComparator.control([num_ctrl_qubits, …])

Control this circuit on num_ctrl_qubits qubits.

IntegerComparator.copy([name])

Copy the circuit.

IntegerComparator.count_ops()

Count each operation kind in the circuit.

IntegerComparator.cp(theta, control_qubit, …)

Apply CPhaseGate.

IntegerComparator.crx(theta, control_qubit, …)

Apply CRXGate.

IntegerComparator.cry(theta, control_qubit, …)

Apply CRYGate.

IntegerComparator.crz(theta, control_qubit, …)

Apply CRZGate.

IntegerComparator.cswap(control_qubit, …)

Apply CSwapGate.

IntegerComparator.csx(control_qubit, …[, …])

Apply CSXGate.

IntegerComparator.cu(theta, phi, lam, gamma, …)

Apply CUGate.

IntegerComparator.cu1(theta, control_qubit, …)

Apply CU1Gate.

IntegerComparator.cu3(theta, phi, lam, …)

Apply CU3Gate.

IntegerComparator.cx(control_qubit, …[, …])

Apply CXGate.

IntegerComparator.cy(control_qubit, …[, …])

Apply CYGate.

IntegerComparator.cz(control_qubit, …[, …])

Apply CZGate.

IntegerComparator.dcx(qubit1, qubit2)

Apply DCXGate.

IntegerComparator.decompose()

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

IntegerComparator.depth()

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

IntegerComparator.diag_gate(diag, qubit)

Deprecated version of QuantumCircuit.diagonal.

IntegerComparator.diagonal(diag, qubit)

Attach a diagonal gate to a circuit.

IntegerComparator.draw([output, scale, …])

Draw the quantum circuit.

IntegerComparator.extend(rhs)

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

IntegerComparator.fredkin(control_qubit, …)

Apply CSwapGate.

IntegerComparator.from_qasm_file(path)

Take in a QASM file and generate a QuantumCircuit object.

IntegerComparator.from_qasm_str(qasm_str)

Take in a QASM string and generate a QuantumCircuit object.

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

Apply HGate.

IntegerComparator.hamiltonian(operator, …)

Apply hamiltonian evolution to to qubits.

IntegerComparator.has_register(register)

Test if this circuit has the register r.

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

Apply IGate.

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

Apply IGate.

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

Deprecated identity gate.

IntegerComparator.initialize(params, qubits)

Apply initialize to circuit.

IntegerComparator.inverse()

Invert (take adjoint of) this circuit.

IntegerComparator.iso(isometry, q_input, …)

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

IntegerComparator.isometry(isometry, …[, …])

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

IntegerComparator.iswap(qubit1, qubit2)

Apply iSwapGate.

IntegerComparator.mcmt(gate, control_qubits, …)

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

IntegerComparator.mcrx(theta, q_controls, …)

Apply Multiple-Controlled X rotation gate

IntegerComparator.mcry(theta, q_controls, …)

Apply Multiple-Controlled Y rotation gate

IntegerComparator.mcrz(lam, q_controls, q_target)

Apply Multiple-Controlled Z rotation gate

IntegerComparator.mct(control_qubits, …[, …])

Apply MCXGate.

IntegerComparator.mcu1(lam, control_qubits, …)

Apply MCU1Gate.

IntegerComparator.mcx(control_qubits, …[, …])

Apply MCXGate.

IntegerComparator.measure(qubit, cbit)

Measure quantum bit into classical bit (tuples).

IntegerComparator.measure_active([inplace])

Adds measurement to all non-idle qubits.

IntegerComparator.measure_all([inplace])

Adds measurement to all qubits.

IntegerComparator.mirror()

DEPRECATED: use circuit.reverse_ops().

IntegerComparator.ms(theta, qubits)

Apply MSGate.

IntegerComparator.num_connected_components([…])

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

IntegerComparator.num_nonlocal_gates()

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

IntegerComparator.num_tensor_factors()

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

IntegerComparator.num_unitary_factors()

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

IntegerComparator.p(theta, qubit)

Apply PhaseGate.

IntegerComparator.power(power[, matrix_power])

Raise this circuit to the power of power.

IntegerComparator.qasm([formatted, filename])

Return OpenQASM string.

IntegerComparator.qbit_argument_conversion(…)

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

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

Apply RGate.

IntegerComparator.rcccx(control_qubit1, …)

Apply RC3XGate.

IntegerComparator.rccx(control_qubit1, …)

Apply RCCXGate.

IntegerComparator.remove_final_measurements([…])

Removes final measurement on all qubits if they are present.

IntegerComparator.repeat(reps)

Repeat this circuit reps times.

IntegerComparator.reset(qubit)

Reset q.

IntegerComparator.reverse_bits()

Return a circuit with the opposite order of wires.

IntegerComparator.reverse_ops()

Reverse the circuit by reversing the order of instructions.

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

Apply RXGate.

IntegerComparator.rxx(theta, qubit1, qubit2)

Apply RXXGate.

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

Apply RYGate.

IntegerComparator.ryy(theta, qubit1, qubit2)

Apply RYYGate.

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

Apply RZGate.

IntegerComparator.rzx(theta, qubit1, qubit2)

Apply RZXGate.

IntegerComparator.rzz(theta, qubit1, qubit2)

Apply RZZGate.

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

Apply SGate.

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

Apply SdgGate.

IntegerComparator.size()

Returns total number of gate operations in circuit.

IntegerComparator.snapshot(label[, …])

Take a statevector snapshot of the internal simulator representation.

IntegerComparator.snapshot_density_matrix(label)

Take a density matrix snapshot of simulator state.

IntegerComparator.snapshot_expectation_value(…)

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

IntegerComparator.snapshot_probabilities(…)

Take a probability snapshot of the simulator state.

IntegerComparator.snapshot_stabilizer(label)

Take a stabilizer snapshot of the simulator state.

IntegerComparator.snapshot_statevector(label)

Take a statevector snapshot of the simulator state.

IntegerComparator.squ(unitary_matrix, qubit)

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

IntegerComparator.swap(qubit1, qubit2)

Apply SwapGate.

IntegerComparator.sx(qubit)

Apply SXGate.

IntegerComparator.sxdg(qubit)

Apply SXdgGate.

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

Apply TGate.

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

Apply TdgGate.

IntegerComparator.to_gate([parameter_map, label])

Create a Gate out of this circuit.

IntegerComparator.to_instruction([parameter_map])

Create an Instruction out of this circuit.

IntegerComparator.toffoli(control_qubit1, …)

Apply CCXGate.

IntegerComparator.u(theta, phi, lam, qubit)

Apply UGate.

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

Apply U1Gate.

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

Apply U2Gate.

IntegerComparator.u3(theta, phi, lam, qubit, *)

Apply U3Gate.

IntegerComparator.uc(gate_list, q_controls, …)

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

IntegerComparator.ucg(angle_list, …[, …])

Deprecated version of uc.

IntegerComparator.ucrx(angle_list, …)

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

IntegerComparator.ucry(angle_list, …)

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

IntegerComparator.ucrz(angle_list, …)

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

IntegerComparator.ucx(angle_list, …)

Deprecated version of ucrx.

IntegerComparator.ucy(angle_list, …)

Deprecated version of ucry.

IntegerComparator.ucz(angle_list, …)

Deprecated version of ucrz.

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

Apply unitary gate to q.

IntegerComparator.width()

Return number of qubits plus clbits in circuit.

IntegerComparator.x(qubit, *[, label, …])

Apply XGate.

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

Apply YGate.

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

Apply ZGate.

IntegerComparator.__getitem__(item)

Return indexed operation.

IntegerComparator.__len__()

Return number of operations in circuit.