Disk

Struct Disk 

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

The Disk struct is a sequence generator that generates points in a 2-dimensional space using the Disk 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::Disk;
use approx_eq::assert_approx_eq;

let mut dgen = Disk::new(&[2, 3]);
dgen.reseed(0);
let result = dgen.pop();
assert_approx_eq!(result[0], -0.5773502691896257);

Implementations§

Source§

impl Disk

Source

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

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

Arguments:

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

Returns:

The new function returns an instance of the Disk struct.

Source

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

Returns the pop of this Disk.

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 Disk class, pop() returns the next point in the Disk 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::Disk;
use approx_eq::assert_approx_eq;

let mut dgen = Disk::new(&[2, 3]);
let result = dgen.pop();
assert_approx_eq!(result[0], -0.5773502691896257);
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 Disk

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Disk

§

impl RefUnwindSafe for Disk

§

impl Send for Disk

§

impl Sync for Disk

§

impl Unpin for Disk

§

impl UnwindSafe for Disk

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.