pub struct HaltonSequence { /* private fields */ }Expand description
Multi-dimensional Halton sequence - Van der Corput across the
first HALTON_MAX_DIM primes. Discrepancy is excellent for
dimensions up to ~10; beyond that consider SobolSequence or
scrambled Halton.
§Examples
use vrd::quasirandom::HaltonSequence;
let mut h = HaltonSequence::new(2);
let p = h.next_point::<2>();
assert_eq!(p.len(), 2);
assert!(p[0] >= 0.0 && p[0] < 1.0);Implementations§
Source§impl HaltonSequence
impl HaltonSequence
Sourcepub fn new(d: usize) -> Self
pub fn new(d: usize) -> Self
Builds an d-dimensional Halton sequence. Panics if
d > HALTON_MAX_DIM.
Sourcepub fn next_point<const D: usize>(&mut self) -> [f64; D]
pub fn next_point<const D: usize>(&mut self) -> [f64; D]
Returns the next D-dimensional point. Panics if
D != self.dimensions().
Sourcepub fn next_point_vec(&mut self) -> Vec<f64>
pub fn next_point_vec(&mut self) -> Vec<f64>
Returns the next point as an allocated Vec. Useful when
D isn’t a compile-time constant. Requires alloc.
Sourcepub fn dimensions(&self) -> usize
pub fn dimensions(&self) -> usize
Returns the dimension count.
Trait Implementations§
Source§impl Clone for HaltonSequence
impl Clone for HaltonSequence
Source§fn clone(&self) -> HaltonSequence
fn clone(&self) -> HaltonSequence
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HaltonSequence
impl Debug for HaltonSequence
impl Copy for HaltonSequence
Auto Trait Implementations§
impl Freeze for HaltonSequence
impl RefUnwindSafe for HaltonSequence
impl Send for HaltonSequence
impl Sync for HaltonSequence
impl Unpin for HaltonSequence
impl UnsafeUnpin for HaltonSequence
impl UnwindSafe for HaltonSequence
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more