3.9.1. qupulse.utils.numeric¶
Functions
|
Find the best fraction approximation of alpha_num / den with an error smaller d_num / den. |
|
Return the fraction with the smallest denominator in (x - abs_err, x + abs_err). |
|
Return the fraction with the smallest denominator in (x - abs_err, x + abs_err) |
|
Find the smallest factor of n that is greater or equal min_factor |
- qupulse.utils.numeric.approximate_double(x: float, abs_err: float, fraction_type: Type[numbers.Rational]) numbers.Rational [source]¶
Return the fraction with the smallest denominator in (x - abs_err, x + abs_err).
- qupulse.utils.numeric.approximate_rational(x: numbers.Rational, abs_err: numbers.Rational, fraction_type: Type[numbers.Rational]) numbers.Rational [source]¶
Return the fraction with the smallest denominator in (x - abs_err, x + abs_err)
- qupulse.utils.numeric.smallest_factor_ge(n: int, min_factor: int, brute_force: int = 5)[source]¶
Find the smallest factor of n that is greater or equal min_factor
- Parameters
n – number to factorize
min_factor – factor must be larger this
brute_force – range(min_factor, min(min_factor + brute_force)) is probed by brute force
- Returns
Smallest factor of n that is greater or equal min_factor