Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

PiecewiseLinearRotation

class PiecewiseLinearRotation(breakpoints, slopes, offsets, num_state_qubits, basis='Y', i_state=None, i_target=None)

GitHub

DEPRECATED. Piecewise-linearly-controlled rotation.

Deprecated since version 0.7.0

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

For a piecewise linear (not necessarily continuous) function f(x). The function f(x) is defined through breakpoints, slopes and offsets as follows. Suppose the breakpoints { x_0, …, x_J } are a subset of [0, 2^n-1], where n is the number of state qubits. Further on, denote the corresponding slopes and offsets by a_j, b_j respectively. Then f(x) is defined as:

x < x_0 –> f(x) = 0 x_j <= x < x_{j+1} –> f(x) = a_j * (x - x_j) + b_j

where we implicitly assume x_{J+1} = 2^n.

Parameters

  • breakpoints (Union(list, numpy.ndarray)) – breakpoints to define piecewise-linear function
  • slopes (Union(list, numpy.ndarray)) – slopes for different segments of piecewise-linear function
  • offsets (Union(list, numpy.ndarray)) – offsets for different segments of piecewise-linear function
  • num_state_qubits (int) – number of qubits representing the state
  • basis (Optional(str)) – type of Pauli rotation (‘X’, ‘Y’, ‘Z’)
  • i_state (Optional(Union(list, numpy.ndarray))) – indices of qubits representing the state, set to range(num_state_qubits) if None
  • i_target (Optional(int)) – index of target qubit, set to num_state_qubits if None

Attributes

num_target_qubits

Returns the number of target qubits


Methods

build

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

Build the circuit.

build_controlled

PiecewiseLinearRotation.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

PiecewiseLinearRotation.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

PiecewiseLinearRotation.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

PiecewiseLinearRotation.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

PiecewiseLinearRotation.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

PiecewiseLinearRotation.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

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

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

evaluate

PiecewiseLinearRotation.evaluate(x)

Classically evaluate the piecewise linear rotation

Parameters

x (float) – value to be evaluated at

Returns

value of piecewise linear function at x

Return type

float

get_num_qubits

PiecewiseLinearRotation.get_num_qubits()

returns number of qubits

get_num_qubits_controlled

PiecewiseLinearRotation.get_num_qubits_controlled()

returns number of qubits controlled

required_ancillas

PiecewiseLinearRotation.required_ancillas()

Return the number of required ancillas.

required_ancillas_controlled

PiecewiseLinearRotation.required_ancillas_controlled()

returns required ancillas controlled

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