qiskit.aqua.components.reciprocals.LongDivision
class LongDivision(scale=0, precision=None, negative_evals=False, evo_time=None, lambda_min=None)
The Long Division Rotation for Reciprocals.
This method calculates inverse of eigenvalues using binary long division and performs the corresponding rotation. Long division is implemented as a sequence of subtraction (utilizing ripple carry adder module) and bit shifting. The method allows for adjusting of the reciprocal precision by changing number of iterations. The method was optimized for register conventions used in HHL algorithm (i.e. eigenvalues rescaled to values between 0 and 1).
The rotation value is always scaled down additionally to the normal scale parameter by 0.5 to get the angle into the linear part of the arcsin(x).
It finds the reciprocal with long division method and rotates the ancillary qubit by C/lambda. This is a first order approximation of arcsin(C/lambda).
Parameters
- scale (
float
) – The scale of rotation angle, corresponds to HHL constant C. This parameter is used to scale the reciprocals such that for a scale C, the rotation is performed by an angle . If neither the scale nor the evo_time and lambda_min parameters are specified, the smallest resolvable Eigenvalue is used. - precision (
Optional
[int
]) – Number of qubits that defines the precision of long division. The parameter sets minimum desired bit precision for the reciprocal. Due to shifting some of reciprocals, however, are effectively estimated with higher than this minimum specified precision. - negative_evals (
bool
) – Indicate if negative eigenvalues need to be handled - evo_time (
Optional
[float
]) – The evolution time. This parameter scales the Eigenvalues in the phase estimation onto the range (0,1] ( (-0.5,0.5] for negative Eigenvalues ). - lambda_min (
Optional
[float
]) – The smallest expected eigenvalue
__init__
__init__(scale=0, precision=None, negative_evals=False, evo_time=None, lambda_min=None)
Parameters
- scale (
float
) – The scale of rotation angle, corresponds to HHL constant C. This parameter is used to scale the reciprocals such that for a scale C, the rotation is performed by an angle . If neither the scale nor the evo_time and lambda_min parameters are specified, the smallest resolvable Eigenvalue is used. - precision (
Optional
[int
]) – Number of qubits that defines the precision of long division. The parameter sets minimum desired bit precision for the reciprocal. Due to shifting some of reciprocals, however, are effectively estimated with higher than this minimum specified precision. - negative_evals (
bool
) – Indicate if negative eigenvalues need to be handled - evo_time (
Optional
[float
]) – The evolution time. This parameter scales the Eigenvalues in the phase estimation onto the range (0,1] ( (-0.5,0.5] for negative Eigenvalues ). - lambda_min (
Optional
[float
]) – The smallest expected eigenvalue
Methods
__init__ ([scale, precision, negative_evals, …]) | type scalefloat |
construct_circuit (mode[, register, circuit]) | Construct the Long Division Rotation circuit. |
sv_to_resvec (statevector, num_q) | Convert statevector to result vector. |
construct_circuit
construct_circuit(mode, register=None, circuit=None)
Construct the Long Division Rotation circuit.
Parameters
- mode (str) – construction mode, ‘matrix’ not supported
- register (QuantumRegister) – input register, typically output register of Eigenvalues
- circuit (QuantumCircuit) – Quantum Circuit or None
Returns
containing the Long Division Rotation circuit.
Return type
Raises
NotImplementedError – mode not supported
sv_to_resvec
sv_to_resvec(statevector, num_q)
Convert statevector to result vector.
Parameters
- statevector (list) – The statevector from simulation.
- num_q (int) – Number of qubits of result register.
Returns
The result vector.