pub struct Circle { /* private fields */ }Expand description
Circle sequence generator
The Circle struct is a generator for a circle sequence using the Van der Corput sequence.
Properties:
vdc: A variable of type VdCorput, which is a sequence generator for Van der Corput sequence.
§Examples
use lds_rs::Circle;
let mut cgen = Circle::new(2);
cgen.reseed(1);
let result = cgen.pop();
assert_eq!(result[1], 1.0);Implementations§
Source§impl Circle
impl Circle
Sourcepub fn new(base: usize) -> Self
pub fn new(base: usize) -> Self
Creates a new Circle.
The new function creates a new Circle object with a specified base value.
Arguments:
base: Thebaseparameter in thenewfunction is the base value used to generate the Van der Corput sequence. The Van der Corput sequence is a low-discrepancy sequence used in quasi-Monte Carlo methods. It is generated by reversing the digits of the fractional part of the
Returns:
The new function is returning an instance of the Circle struct.
Sourcepub fn pop(&mut self) -> [f64; 2]
pub fn pop(&mut self) -> [f64; 2]
Returns the pop of this Circle.
The pop function returns the coordinates of a point on a circle based on a random value.
Returns:
The pop function returns an array of two f64 values, representing the sine and cosine of a
randomly generated angle.
§Examples
use lds_rs::lds::Circle;
use approx_eq::assert_approx_eq;
let mut circle = Circle::new(2);
let result = circle.pop();
assert_approx_eq!(result[1], 0.0);
assert_approx_eq!(result[0], -1.0);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.