Lines Matching full:low
53 //! `low < high`). The example below merely wraps another back-end.
73 //! fn new<B1, B2>(low: B1, high: B2) -> Self
77 //! UniformMyF32(UniformFloat::<f32>::new(low.borrow().0, high.borrow().0))
79 //! fn new_inclusive<B1, B2>(low: B1, high: B2) -> Self
83 //! UniformSampler::new(low, high)
94 //! let (low, high) = (MyF32(17.0f32), MyF32(22.0f32));
95 //! let uniform = Uniform::new(low, high);
140 /// generated by the RNG than the low bits, since with some RNGs the low-bits
143 /// Implementations must sample in `[low, high)` range for
144 /// `Uniform::new(low, high)`, i.e., excluding `high`. In particular, care must
145 /// be taken to ensure that rounding never results values `< low` or `>= high`.
179 /// open range `[low, high)` (excluding `high`). Panics if `low >= high`.
180 pub fn new<B1, B2>(low: B1, high: B2) -> Uniform<X> in new()
185 Uniform(X::Sampler::new(low, high)) in new()
189 /// range `[low, high]` (inclusive). Panics if `low > high`.
190 pub fn new_inclusive<B1, B2>(low: B1, high: B2) -> Uniform<X> in new_inclusive()
195 Uniform(X::Sampler::new_inclusive(low, high)) in new_inclusive()
223 /// the implementation can be faster than `Self::new(low, high).sample(rng)`.
232 /// `[low, high)`.
235 /// `Uniform::new`, which asserts that `low < high` before calling this.
236 fn new<B1, B2>(low: B1, high: B2) -> Self in new()
241 /// Construct self, with inclusive bounds `[low, high]`.
244 /// `Uniform::new_inclusive`, which asserts that `low <= high` before
246 fn new_inclusive<B1, B2>(low: B1, high: B2) -> Self in new_inclusive()
255 /// and exclusive upper bound `[low, high)`.
258 /// `UniformSampler::new(low, high).sample(rng)`. However, for some types
273 fn sample_single<R: Rng + ?Sized, B1, B2>(low: B1, high: B2, rng: &mut R) -> Self::X in sample_single()
278 let uniform: Self = UniformSampler::new(low, high); in sample_single()
283 /// and inclusive upper bound `[low, high]`.
286 /// `UniformSampler::new_inclusive(low, high).sample(rng)`. However, for
290 fn sample_single_inclusive<R: Rng + ?Sized, B1, B2>(low: B1, high: B2, rng: &mut R) in sample_single_inclusive()
295 let uniform: Self = UniformSampler::new_inclusive(low, high); in sample_single_inclusive()
395 /// `range = (high - low + 1)`. To avoid bias, we must ensure that the size of
415 /// multiply by `range`, the result is in the high word. Then comparing the low
420 low: X, field
446 let low = *low_b.borrow(); localVariable
448 assert!(low < high, "Uniform::new called with `low >= high`");
449 UniformSampler::new_inclusive(low, high - 1)
459 let low = *low_b.borrow(); localVariable
462 low <= high,
463 "Uniform::new_inclusive called with `low > high`"
467 let range = high.wrapping_sub(low).wrapping_add(1) as $unsigned;
476 low,
493 return self.low.wrapping_add(hi as $ty);
508 let low = *low_b.borrow(); localVariable
510 assert!(low < high, "UniformSampler::sample_single: low >= high");
511 Self::sample_single_inclusive(low, high - 1, rng)
520 let low = *low_b.borrow(); localVariable
522 assert!(low <= high, "UniformSampler::sample_single_inclusive: low > high");
523 let range = high.wrapping_sub(low).wrapping_add(1) as $unsigned as $u_large;
547 return low.wrapping_add(hi as $ty);
594 let low = *low_b.borrow(); localVariable
596 assert!(low.lt(high).all(), "Uniform::new called with `low >= high`");
597 UniformSampler::new_inclusive(low, high - 1)
606 let low = *low_b.borrow(); localVariable
608 assert!(low.le(high).all(),
609 "Uniform::new_inclusive called with `low > high`");
614 let range: $unsigned = ((high - low) + 1).cast();
627 low,
654 let result = self.low + hi;
757 let low = char_to_comp_u32(*low_b.borrow()); in new() localVariable
759 let sampler = UniformInt::<u32>::new(low, high); in new()
770 let low = char_to_comp_u32(*low_b.borrow()); in new_inclusive() localVariable
772 let sampler = UniformInt::<u32>::new_inclusive(low, high); in new_inclusive()
810 low: X, field
828 let low = *low_b.borrow(); localVariable
830 assert!(low.all_lt(high), "Uniform::new called with `low >= high`");
832 low.all_finite() && high.all_finite(),
839 let mut scale = high - low;
842 let mask = (scale * max_rand + low).ge_mask(high);
851 UniformFloat { low, scale }
859 let low = *low_b.borrow(); localVariable
862 low.all_le(high),
863 "Uniform::new_inclusive called with `low > high`"
866 low.all_finite() && high.all_finite(),
873 let mut scale = (high - low) / max_rand;
876 let mask = (scale * max_rand + low).gt_mask(high);
885 UniformFloat { low, scale }
901 value0_1 * self.scale + self.low
910 let low = *low_b.borrow(); localVariable
913 low.all_lt(high),
914 "UniformSampler::sample_single: low >= high"
916 let mut scale = high - low;
929 let res = value0_1 * scale + low;
931 debug_assert!(low.all_le(res) || !scale.all_finite());
937 // * `low` or `high` is NaN. In this case `scale` and
939 // * `low` is negative infinity and `high` is finite.
942 // * `high` is positive infinity and `low` is finite.
945 // * `low` is negative infinity and `high` is positive
948 // * `low` and `high` are finite, but `high - low`
951 // So if `high` or `low` are non-finite, we are guaranteed
954 // While we technically should check for non-finite `low`
957 // checks. But we are still guaranteed that if `low` or
961 // Likewise `high - low` overflowing to infinity is also
966 low.all_finite() && high.all_finite(),
967 "Uniform::sample_single: low and high must be finite"
1038 let low = *low_b.borrow(); in new() localVariable
1040 assert!(low < high, "Uniform::new called with `low >= high`"); in new()
1041 UniformDuration::new_inclusive(low, high - Duration::new(0, 1)) in new()
1050 let low = *low_b.borrow(); in new_inclusive() localVariable
1053 low <= high, in new_inclusive()
1054 "Uniform::new_inclusive called with `low > high`" in new_inclusive()
1057 let low_s = low.as_secs(); in new_inclusive()
1058 let low_n = low.subsec_nanos(); in new_inclusive()
1146 assert_eq!(a_nanos.0.low, nanos.0.low); in test_serialization_uniform_duration()
1151 assert_eq!(a_nanos.0.low, nanos.0.low); in test_serialization_uniform_duration()
1159 assert_eq!(a_secs.0.low, secs.0.low); in test_serialization_uniform_duration()
1173 assert_eq!(unit_box.0.low, de_unit_box.0.low); in test_uniform_serialization()
1180 assert_eq!(unit_box.0.low, de_unit_box.0.low); in test_uniform_serialization()
1215 for &(low, high) in $v.iter() { in test_integers()
1216 let my_uniform = Uniform::new(low, high); in test_integers()
1219 assert!($le(low, v) && $lt(v, high)); in test_integers()
1222 let my_uniform = Uniform::new_inclusive(low, high); in test_integers()
1225 assert!($le(low, v) && $le(v, high)); in test_integers()
1228 let my_uniform = Uniform::new(&low, high); in test_integers()
1231 assert!($le(low, v) && $lt(v, high)); in test_integers()
1234 let my_uniform = Uniform::new_inclusive(&low, &high); in test_integers()
1237 assert!($le(low, v) && $le(v, high)); in test_integers()
1241 let v = <$ty as SampleUniform>::Sampler::sample_single(low, high, &mut rng); in test_integers()
1242 assert!($le(low, v) && $lt(v, high)); in test_integers()
1246 … let v = <$ty as SampleUniform>::Sampler::sample_single_inclusive(low, high, &mut rng); in test_integers()
1247 assert!($le(low, v) && $le(v, high)); in test_integers()
1340 let low = <$ty>::splat(0.0 as $f_scalar).replace(lane, low_scalar); in test_floats() localVariable
1342 let my_uniform = Uniform::new(low, high); in test_floats()
1343 let my_incl_uniform = Uniform::new_inclusive(low, high); in test_floats()
1350 ::sample_single(low, high, &mut rng).extract(lane); in test_floats()
1355 rng.sample(Uniform::new_inclusive(low, low)).extract(lane), in test_floats()
1362 ::sample_single(low, high, &mut zero_rng) in test_floats()
1367 // Don't run this test for really tiny differences between high and low in test_floats()
1377 ::sample_single(low, high, &mut lowering_max_rng) in test_floats()
1424 fn range<T: SampleUniform>(low: T, high: T) { in test_float_assertions()
1426 T::Sampler::sample_single(low, high, &mut rng); in test_float_assertions()
1450 let low = <$ty>::splat(0.0 as $f_scalar).replace(lane, low_scalar); in test_float_assertions() localVariable
1452 assert!(catch_unwind(|| range(low, high)).is_err()); in test_float_assertions()
1453 assert!(catch_unwind(|| Uniform::new(low, high)).is_err()); in test_float_assertions()
1454 assert!(catch_unwind(|| Uniform::new_inclusive(low, high)).is_err()); in test_float_assertions()
1455 assert!(catch_unwind(|| range(low, low)).is_err()); in test_float_assertions()
1456 assert!(catch_unwind(|| Uniform::new(low, low)).is_err()); in test_float_assertions()
1493 for &(low, high) in v.iter() { in test_durations()
1494 let my_uniform = Uniform::new(low, high); in test_durations()
1497 assert!(low <= v && v < high); in test_durations()
1516 fn new<B1, B2>(low: B1, high: B2) -> Self in test_custom_uniform()
1521 UniformMyF32(UniformFloat::<f32>::new(low.borrow().x, high.borrow().x)) in test_custom_uniform()
1524 fn new_inclusive<B1, B2>(low: B1, high: B2) -> Self in test_custom_uniform()
1529 UniformSampler::new(low, high) in test_custom_uniform()
1542 let (low, high) = (MyF32 { x: 17.0f32 }, MyF32 { x: 22.0f32 }); in test_custom_uniform()
1543 let uniform = Uniform::new(low, high); in test_custom_uniform()
1547 assert!(low <= x && x < high); in test_custom_uniform()
1554 assert_eq!(r.0.low, 2); in test_uniform_from_std_range()
1557 assert_eq!(r.0.low, 2.0); in test_uniform_from_std_range()
1564 assert_eq!(r.0.low, 2); in test_uniform_from_std_range_inclusive()
1567 assert_eq!(r.0.low, 2.0); in test_uniform_from_std_range_inclusive()