Halton

Struct Halton 

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

The Halton struct is a sequence generator that generates points in a 2-dimensional space using the Halton sequence.

Properties:

  • vdc0: A variable of type VdCorput that represents the Van der Corput sequence generator for the first base. The Van der Corput sequence is a low-discrepancy sequence that is commonly used in quasi-Monte Carlo methods. It generates a sequence of numbers between 0 and
  • vdc1: The vdc1 property is an instance of the VdCorput struct, which is responsible for generating the Van der Corput sequence with a base of 3. The Van der Corput sequence is another low-discrepancy sequence commonly used in quasi-Monte Carlo methods

§Examples

use lds_rs::Halton;

let mut hgen = Halton::new(&[2, 3]);
hgen.reseed(10);
let result = hgen.pop();
assert_eq!(result[0], 0.8125);

Implementations§

Source§

impl Halton

Source

pub fn new(base: &[usize]) -> Self

The new function creates a new Halton object with specified bases for generating the Halton sequence.

Arguments:

  • base: The base parameter is an array of two usize values. These values are used as the bases for generating the Halton sequence. The first value in the array (base[0]) is used as the base for generating the first component of the Halton sequence, and the second

Returns:

The new function returns an instance of the Halton struct.

Source

pub fn pop(&mut self) -> [f64; 2]

Returns the pop of this Halton.

The pop() function is used to generate the next value in the sequence. For example, in the VdCorput class, pop() increments the count and calculates the Van der Corput sequence value for that count and base. In the Halton class, pop() returns the next point in the Halton sequence as a [f64; 2]. Similarly, in the Circle class, pop() returns the next point on the unit circle as a [f64; 2]. In the Sphere class, pop() returns the next point on the unit sphere as a [f64; 3]. And in the Sphere3Hopf class, pop() returns the next point on the 3-sphere using the Hopf fibration as a [f64; 4].

Returns:

An array of two f64 values is being returned.

§Examples
use lds_rs::lds::Halton;

let mut halton = Halton::new(&[2, 5]);
assert_eq!(halton.pop(), [0.5, 0.2]);
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 Halton

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Halton

§

impl RefUnwindSafe for Halton

§

impl Send for Halton

§

impl Sync for Halton

§

impl Unpin for Halton

§

impl UnwindSafe for Halton

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.