pub struct VdCorput { /* private fields */ }Expand description
The VdCorput struct is a generator for Van der Corput sequences.
Properties:
count: Thecountproperty represents the number of elements that have been generated from the Van der Corput sequence so far.base: Thebaseproperty represents the base of the Van der Corput sequence. It determines the distribution of the generated numbers.scale: Thescaleproperty determines the precision of the generated Van der Corput sequence. It represents the number of bits used to represent the fractional part of the sequence. A higher scale value will result in a more precise sequence, but will also require more memory and computation.
§Examples
use lds_rs::VdCorput;
let mut vgen = VdCorput::new(2);
vgen.reseed(10);
let result = vgen.pop();
assert_eq!(result, 0.8125);Implementations§
Source§impl VdCorput
impl VdCorput
Sourcepub const fn new(base: usize, scale: u32) -> Self
pub const fn new(base: usize, scale: u32) -> Self
Creates a new VdCorput.
The new function creates a new VdCorput struct with the specified base and scale values.
Arguments:
base: Thebaseparameter represents the base of the Van der Corput sequence. It determines the number of unique values that can be generated by the sequence.scale: Thescaleparameter in thenewfunction is of typeu32, which stands for unsigned 32-bit integer. It represents the scale factor used in theVdCorputstruct.
Returns:
The new function returns an instance of the VdCorput struct.
Sourcepub fn pop(&mut self) -> usize
pub fn pop(&mut self) -> usize
Returns the pop of this VdCorput.
The pop method of the VdCorput struct returns the next element in the Van der Corput
sequence. It increments the count property of the struct and uses the vdc_i function to
calculate the corresponding Van der Corput value based on the current count, base, and scale. In
the example provided, a VdCorput instance is created with a base of 2 and a scale of 10. The
pop method is then called, which returns the Van der Corput value for the current count (which
is initially 0). In this case, the returned value is 512.
§Examples
use lds_rs::ilds::VdCorput;
let mut vd_corput = VdCorput::new(2, 10);
assert_eq!(vd_corput.pop(), 512);Sourcepub fn reseed(&mut self, seed: usize)
pub fn reseed(&mut self, seed: usize)
The below code is a Rust function called reseed that is used to reset the state of a sequence
generator to a specific seed value. This allows the sequence generator to start generating the
sequence from the beginning or from a specific point in the sequence, depending on the value of the
seed.