VdCorput

Struct VdCorput 

Source
pub struct VdCorput { /* private fields */ }
Expand description

The VdCorput struct is a generator for Van der Corput sequences.

Properties:

  • count: The count property represents the number of elements that have been generated from the Van der Corput sequence so far.
  • base: The base property represents the base of the Van der Corput sequence. It determines the distribution of the generated numbers.
  • scale: The scale property 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

Source

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: The base parameter represents the base of the Van der Corput sequence. It determines the number of unique values that can be generated by the sequence.
  • scale: The scale parameter in the new function is of type u32, which stands for unsigned 32-bit integer. It represents the scale factor used in the VdCorput struct.

Returns:

The new function returns an instance of the VdCorput struct.

Source

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);
Source

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.

Trait Implementations§

Source§

impl Debug for VdCorput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.