Struct lds_rs::lds::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(base0: usize, base1: 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
source§

impl PartialEq<Halton> for Halton

source§

fn eq(&self, other: &Halton) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Halton

source§

impl StructuralEq for Halton

source§

impl StructuralPartialEq for Halton

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.