pub struct RNG { /* private fields */ }
Expand description
Random Number Generator
Random number generator. It encapsulates the state (currently, a 64-bit integer) and has methods to return scalar random values and to fill arrays with random values. Currently it supports uniform and Gaussian (normal) distributions. The generator uses Multiply-With-Carry algorithm, introduced by G. Marsaglia ( http://en.wikipedia.org/wiki/Multiply-with-carry ). Gaussian-distribution random numbers are generated using the Ziggurat algorithm ( http://en.wikipedia.org/wiki/Ziggurat_algorithm ), introduced by G. Marsaglia and W. W. Tsang.
Implementations§
source§impl RNG
impl RNG
sourcepub fn default() -> Result<RNG>
pub fn default() -> Result<RNG>
constructor
These are the RNG constructors. The first form sets the state to some pre-defined value, equal to 2**32-1 in the current implementation. The second form sets the state to the specified value. If you passed state=0 , the constructor uses the above default value instead to avoid the singular random number sequence, consisting of all zeros.
sourcepub fn new(state: u64) -> Result<RNG>
pub fn new(state: u64) -> Result<RNG>
constructor
These are the RNG constructors. The first form sets the state to some pre-defined value, equal to 2**32-1 in the current implementation. The second form sets the state to the specified value. If you passed state=0 , the constructor uses the above default value instead to avoid the singular random number sequence, consisting of all zeros.
§Overloaded parameters
§Parameters
- state: 64-bit value used to initialize the RNG.
Trait Implementations§
source§impl Boxed for RNG
impl Boxed for RNG
source§unsafe fn from_raw(ptr: <RNG as OpenCVFromExtern>::ExternReceive) -> Self
unsafe fn from_raw(ptr: <RNG as OpenCVFromExtern>::ExternReceive) -> Self
source§fn into_raw(self) -> <RNG as OpenCVTypeExternContainer>::ExternSendMut
fn into_raw(self) -> <RNG as OpenCVTypeExternContainer>::ExternSendMut
source§fn as_raw(&self) -> <RNG as OpenCVTypeExternContainer>::ExternSend
fn as_raw(&self) -> <RNG as OpenCVTypeExternContainer>::ExternSend
source§fn as_raw_mut(&mut self) -> <RNG as OpenCVTypeExternContainer>::ExternSendMut
fn as_raw_mut(&mut self) -> <RNG as OpenCVTypeExternContainer>::ExternSendMut
source§impl RNGTrait for RNG
impl RNGTrait for RNG
fn as_raw_mut_RNG(&mut self) -> *mut c_void
fn set_state(&mut self, val: u64)
source§fn next(&mut self) -> Result<u32>
fn next(&mut self) -> Result<u32>
source§fn to_u8(&mut self) -> Result<u8>
fn to_u8(&mut self) -> Result<u8>
source§fn to_i8(&mut self) -> Result<i8>
fn to_i8(&mut self) -> Result<i8>
source§fn to_u16(&mut self) -> Result<u16>
fn to_u16(&mut self) -> Result<u16>
source§fn to_i16(&mut self) -> Result<i16>
fn to_i16(&mut self) -> Result<i16>
source§fn to_u32(&mut self) -> Result<u32>
fn to_u32(&mut self) -> Result<u32>
source§fn to_i32(&mut self) -> Result<i32>
fn to_i32(&mut self) -> Result<i32>
source§fn to_f32(&mut self) -> Result<f32>
fn to_f32(&mut self) -> Result<f32>
source§fn to_f64(&mut self) -> Result<f64>
fn to_f64(&mut self) -> Result<f64>
source§fn apply(&mut self) -> Result<u32>
fn apply(&mut self) -> Result<u32>
source§fn apply_range(&mut self, n: u32) -> Result<u32>
fn apply_range(&mut self, n: u32) -> Result<u32>
source§fn uniform(&mut self, a: i32, b: i32) -> Result<i32>
fn uniform(&mut self, a: i32, b: i32) -> Result<i32>
source§fn uniform_f32(&mut self, a: f32, b: f32) -> Result<f32>
fn uniform_f32(&mut self, a: f32, b: f32) -> Result<f32>
source§fn uniform_f64(&mut self, a: f64, b: f64) -> Result<f64>
fn uniform_f64(&mut self, a: f64, b: f64) -> Result<f64>
source§fn fill(
&mut self,
mat: &mut impl ToInputOutputArray,
dist_type: i32,
a: &impl ToInputArray,
b: &impl ToInputArray,
saturate_range: bool
) -> Result<()>
fn fill( &mut self, mat: &mut impl ToInputOutputArray, dist_type: i32, a: &impl ToInputArray, b: &impl ToInputArray, saturate_range: bool ) -> Result<()>
source§fn fill_def(
&mut self,
mat: &mut impl ToInputOutputArray,
dist_type: i32,
a: &impl ToInputArray,
b: &impl ToInputArray
) -> Result<()>
fn fill_def( &mut self, mat: &mut impl ToInputOutputArray, dist_type: i32, a: &impl ToInputArray, b: &impl ToInputArray ) -> Result<()>
source§impl RNGTraitConst for RNG
impl RNGTraitConst for RNG
impl Send for RNG
Auto Trait Implementations§
impl Freeze for RNG
impl RefUnwindSafe for RNG
impl !Sync for RNG
impl Unpin for RNG
impl UnwindSafe for RNG
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
source§unsafe fn modify_inplace<Res>(
&mut self,
f: impl FnOnce(&Mat, &mut Mat) -> Res
) -> Res
unsafe fn modify_inplace<Res>( &mut self, f: impl FnOnce(&Mat, &mut Mat) -> Res ) -> Res
Mat
or another similar object. By passing
a mutable reference to the Mat
to this function your closure will get called with the read reference and a write references
to the same Mat
. This is of course unsafe as it breaks the Rust aliasing rules, but it might be useful for some performance
sensitive operations. One example of an OpenCV function that allows such in-place modification is imgproc::threshold
. Read more