Struct necsim_impls_no_std::alias::packed::AliasMethodSamplerAtom
source · #[repr(C)]pub struct AliasMethodSamplerAtom<E: Copy + PartialEq> { /* private fields */ }
Implementations§
source§impl<E: Copy + PartialEq> AliasMethodSamplerAtom<E>
impl<E: Copy + PartialEq> AliasMethodSamplerAtom<E>
pub fn u(&self) -> ClosedUnitF64
pub fn e(&self) -> E
pub fn k(&self) -> E
pub fn flip(&mut self)
sourcepub fn create(
event_weights: &[(E, NonNegativeF64)]
) -> Vec<AliasMethodSamplerAtom<E>>
pub fn create( event_weights: &[(E, NonNegativeF64)] ) -> Vec<AliasMethodSamplerAtom<E>>
§Contracts
Pre-condition - debug: event_weights is non-empty
! event_weights.is_empty()
Pre-condition - debug: all event weights are non-negative
event_weights.iter().all(|(_e, p)| *p >= 0.0_f64)
Post-condition - debug: stores exactly the input events
ret.iter().map(|s| &s.e).eq(old(event_weights).iter().map(|(e, _p)| e))
Post-condition - debug: full buckets sample the same event just in case
ret.iter().all(|s| { let full_bucket = s.u == ClosedUnitF64::one(); !full_bucket || (s.e == s.k) })
pub fn sample_event<M: MathsCore, G: RngCore<M>>( alias_samplers: &[AliasMethodSamplerAtom<E>], rng: &mut G ) -> E
sourcepub fn sample_event_with_cdf_limit<M: MathsCore, G: RngCore<M>>(
alias_samplers: &[AliasMethodSamplerAtom<E>],
rng: &mut G,
limit: ClosedUnitF64
) -> E
pub fn sample_event_with_cdf_limit<M: MathsCore, G: RngCore<M>>( alias_samplers: &[AliasMethodSamplerAtom<E>], rng: &mut G, limit: ClosedUnitF64 ) -> E
§Contracts
Pre-condition - debug: alias_samplers is non-empty
! alias_samplers.is_empty()
Post-condition - debug: returns one of the weighted events
old(alias_samplers).iter().map(|s| s.e).any(|e| e == ret)
Trait Implementations§
source§impl<E: Clone + Copy + PartialEq> Clone for AliasMethodSamplerAtom<E>
impl<E: Clone + Copy + PartialEq> Clone for AliasMethodSamplerAtom<E>
source§fn clone(&self) -> AliasMethodSamplerAtom<E>
fn clone(&self) -> AliasMethodSamplerAtom<E>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<E> ComputeTypeSet for AliasMethodSamplerAtom<E>
impl<E> ComputeTypeSet for AliasMethodSamplerAtom<E>
source§impl<E> TypeLayout for AliasMethodSamplerAtom<E>
impl<E> TypeLayout for AliasMethodSamplerAtom<E>
§type Inhabited = <And<<ClosedUnitF64 as TypeLayout>::Inhabited, <And<<E as TypeLayout>::Inhabited, <And<<E as TypeLayout>::Inhabited, Inhabited> as ComputeInhabited>::Output> as ComputeInhabited>::Output> as ComputeInhabited>::Output
type Inhabited = <And<<ClosedUnitF64 as TypeLayout>::Inhabited, <And<<E as TypeLayout>::Inhabited, <And<<E as TypeLayout>::Inhabited, Inhabited> as ComputeInhabited>::Output> as ComputeInhabited>::Output> as ComputeInhabited>::Output
Marker type for whether the type is
inhabited or
uninhabited.
The associated type must be either [
inhabited::Inhabited
]
or [inhabited::Uninhabited
].source§const TYPE_LAYOUT: TypeLayoutInfo<'static> = _
const TYPE_LAYOUT: TypeLayoutInfo<'static> = _
Shallow layout of the type.
Auto Trait Implementations§
impl<E> Freeze for AliasMethodSamplerAtom<E>where
E: Freeze,
impl<E> RefUnwindSafe for AliasMethodSamplerAtom<E>where
E: RefUnwindSafe,
impl<E> Send for AliasMethodSamplerAtom<E>where
E: Send,
impl<E> Sync for AliasMethodSamplerAtom<E>where
E: Sync,
impl<E> Unpin for AliasMethodSamplerAtom<E>where
E: Unpin,
impl<E> UnwindSafe for AliasMethodSamplerAtom<E>where
E: UnwindSafe,
Blanket Implementations§
§impl<T> Backup for Twhere
T: Clone,
impl<T> Backup for Twhere
T: Clone,
default unsafe fn backup_unchecked(&self) -> T
default unsafe fn __contracts_impl_backup_unchecked(&self) -> T
fn backup(&self) -> BackedUp<Self>
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
Mutably borrows from an owned value. Read more
§impl<T> ExtractDiscriminant for T
impl<T> ExtractDiscriminant for T
§type Discriminant = <T as ExtractDiscriminantSpec<<T as DiscriminantKind>::Discriminant>>::Ty
type Discriminant = <T as ExtractDiscriminantSpec<<T as DiscriminantKind>::Discriminant>>::Ty
The type of the discriminant, which must satisfy the trait bounds
required by
core::mem::Discriminant
. Read more§impl<T> TypeGraphLayout for Twhere
T: TypeLayout + ComputeTypeSet,
impl<T> TypeGraphLayout for Twhere
T: TypeLayout + ComputeTypeSet,
§const TYPE_GRAPH: TypeLayoutGraph<'static> = _
const TYPE_GRAPH: TypeLayoutGraph<'static> = _
Shallow layout of the type.