pub fn exhaustive_rationals_with_denominator_range_to_infinity(
d: Natural,
a: Rational,
) -> RationalsWithDenominator<ExhaustiveIntegerRangeToInfinity> ⓘ
Expand description
Generates all Rational
s greater than or equal to some number $a$ and with a specific
denominator, in order of increasing absolute value.
When two Rational
s have the same absolute value, the positive one comes first.
The output satisfies $(|x_i|, \operatorname{sgn}(-x_i)) <_\mathrm{lex} (|x_j|, \operatorname{sgn}(-x_j))$ whenever $i < j$.
The output length is infinite.
§Worst-case complexity per iteration
$T(i) = O(\log i (\log \log i)^2 \log\log\log i)$
$M(i) = O(\log i \log \log i)$
where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.
§Panics
Panics if d
is zero.
§Examples
use malachite_base::iterators::prefix_to_string;
use malachite_nz::natural::Natural;
use malachite_q::exhaustive::exhaustive_rationals_with_denominator_range_to_infinity;
use malachite_q::Rational;
assert_eq!(
prefix_to_string(
exhaustive_rationals_with_denominator_range_to_infinity(
Natural::from(5u32),
Rational::from_signeds(22i32, 7)
),
10
),
"[16/5, 17/5, 18/5, 19/5, 21/5, 22/5, 23/5, 24/5, 26/5, 27/5, ...]"
);
assert_eq!(
prefix_to_string(
exhaustive_rationals_with_denominator_range_to_infinity(
Natural::from(2u32),
Rational::from_signeds(-22i32, 7)
),
10
),
"[1/2, -1/2, 3/2, -3/2, 5/2, -5/2, 7/2, 9/2, 11/2, 13/2, ...]"
);