Lines Matching full:high

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);
139 /// values. Further, the implementations here give more weight to the high-bits
141 /// are of lower quality than the high 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
447 let high = *high_b.borrow(); localVariable
448 assert!(low < high, "Uniform::new called with `low >= high`");
449 UniformSampler::new_inclusive(low, high - 1)
460 let high = *high_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;
509 let high = *high_b.borrow(); localVariable
510 assert!(low < high, "UniformSampler::sample_single: low >= high");
511 Self::sample_single_inclusive(low, high - 1, rng)
521 let high = *high_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;
595 let high = *high_b.borrow(); localVariable
596 assert!(low.lt(high).all(), "Uniform::new called with `low >= high`");
597 UniformSampler::new_inclusive(low, high - 1)
607 let high = *high_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();
758 let high = char_to_comp_u32(*high_b.borrow()); in new() localVariable
759 let sampler = UniformInt::<u32>::new(low, high); in new()
771 let high = char_to_comp_u32(*high_b.borrow()); in new_inclusive() localVariable
772 let sampler = UniformInt::<u32>::new_inclusive(low, high); in new_inclusive()
829 let high = *high_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);
860 let high = *high_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);
911 let high = *high_b.borrow(); localVariable
913 low.all_lt(high),
914 "UniformSampler::sample_single: low >= high"
916 let mut scale = high - low;
932 if res.all_lt(high) {
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
952 // to fail the `res < high` check above and end up here.
955 // and `high` before entering the loop, by doing the checks
958 // `high` are non-finite we'll end up here and can do the
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"
1039 let high = *high_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()
1051 let high = *high_b.borrow(); in new_inclusive() localVariable
1053 low <= high, in new_inclusive()
1054 "Uniform::new_inclusive called with `low > high`" in new_inclusive()
1059 let mut high_s = high.as_secs(); in new_inclusive()
1060 let mut high_n = high.subsec_nanos(); in new_inclusive()
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()
1341 let high = <$ty>::splat(1.0 as $f_scalar).replace(lane, high_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()
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()
1368 // since for those rounding might result in selecting high for a very 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()
1451 let high = <$ty>::splat(1.0 as $f_scalar).replace(lane, high_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()
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()