Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

FixedValueComparator

FixedValueComparator(num_state_qubits, value, geq=True, i_state=None, i_target=None) GitHub(opens in a new tab)

DEPRECATED. Fixed Value Comparator

Deprecated since version 0.7.0

Use Terra’s qiskit.circuit.library.IntegerComparator instead.

Operator compares basis states |i>_n against a classically given fixed value L and flips a target qubit if i >= L (or < depending on parameters):

|i>_n|0> –> |i>_n|1> if i >= L else |i>|0>

Operator 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 (= results bit) is 1, the “>=” condition is True otherwise it is False.

Parameters

  • num_state_qubits (int) – number of state qubits, the target qubit comes on top of this
  • value (int) – fixed value to compare with
  • geq (Optional(bool)) – evaluate “>=” condition of “<” condition
  • i_state (Optional(Union(list, numpy.ndarray))) – indices of state qubits in given list of qubits / register, if None, i_state = list(range(num_state_qubits)) is used
  • i_target (Optional(int)) – index of target qubit in given list of qubits / register, if None, i_target = num_state_qubits is used

Attributes

num_state_qubits

returns num state qubits

num_target_qubits

Returns the number of target qubits

value

returns value


Methods

build

FixedValueComparator.build(qc, q, q_ancillas=None, params=None)

Adds corresponding sub-circuit to given circuit

Parameters

  • qc (QuantumCircuit) – quantum circuit
  • q (list) – list of qubits (has to be same length as self._num_qubits)
  • q_ancillas (list) – list of ancilla qubits (or None if none needed)
  • params (list) – parameters for circuit

build_controlled

FixedValueComparator.build_controlled(qc, q, q_control, q_ancillas=None, use_basis_gates=True)

Adds corresponding controlled sub-circuit to given circuit

Parameters

  • qc (QuantumCircuit) – quantum circuit
  • q (list) – list of qubits (has to be same length as self._num_qubits)
  • q_control (Qubit) – control qubit
  • q_ancillas (list) – list of ancilla qubits (or None if none needed)
  • use_basis_gates (bool) – use basis gates for expansion of controlled circuit

build_controlled_inverse

FixedValueComparator.build_controlled_inverse(qc, q, q_control, q_ancillas=None, use_basis_gates=True)

Adds controlled inverse of corresponding sub-circuit to given circuit

Parameters

  • qc (QuantumCircuit) – quantum circuit
  • q (list) – list of qubits (has to be same length as self._num_qubits)
  • q_control (Qubit) – control qubit
  • q_ancillas (list) – list of ancilla qubits (or None if none needed)
  • use_basis_gates (bool) – use basis gates for expansion of controlled circuit

build_controlled_inverse_power

FixedValueComparator.build_controlled_inverse_power(qc, q, q_control, power, q_ancillas=None, use_basis_gates=True)

Adds controlled, inverse, power of corresponding circuit. May be overridden if a more efficient implementation is possible

build_controlled_power

FixedValueComparator.build_controlled_power(qc, q, q_control, power, q_ancillas=None, use_basis_gates=True)

Adds controlled power of corresponding circuit. May be overridden if a more efficient implementation is possible

build_inverse

FixedValueComparator.build_inverse(qc, q, q_ancillas=None)

Adds inverse of corresponding sub-circuit to given circuit

Parameters

  • qc (QuantumCircuit) – quantum circuit
  • q (list) – list of qubits (has to be same length as self._num_qubits)
  • q_ancillas (list) – list of ancilla qubits (or None if none needed)

build_inverse_power

FixedValueComparator.build_inverse_power(qc, q, power, q_ancillas=None)

Adds inverse power of corresponding circuit. May be overridden if a more efficient implementation is possible

build_power

FixedValueComparator.build_power(qc, q, power, q_ancillas=None)

Adds power of corresponding circuit. May be overridden if a more efficient implementation is possible

get_num_qubits

FixedValueComparator.get_num_qubits()

returns number of qubits

get_num_qubits_controlled

FixedValueComparator.get_num_qubits_controlled()

returns number of qubits controlled

required_ancillas

FixedValueComparator.required_ancillas()

returns required ancillas

required_ancillas_controlled

FixedValueComparator.required_ancillas_controlled()

returns required ancillas controlled

Was this page helpful?
Report a bug or request content on GitHub.