diff --git a/necsim/impls/no-std/src/cogs/dispersal_sampler/in_memory/packed_separable_alias/dispersal.rs b/necsim/impls/no-std/src/cogs/dispersal_sampler/in_memory/packed_separable_alias/dispersal.rs index 9b3dcca46..e010a64e8 100644 --- a/necsim/impls/no-std/src/cogs/dispersal_sampler/in_memory/packed_separable_alias/dispersal.rs +++ b/necsim/impls/no-std/src/cogs/dispersal_sampler/in_memory/packed_separable_alias/dispersal.rs @@ -23,7 +23,7 @@ impl, G: RngCore> DispersalSampler let location_row = location.y().wrapping_sub(habitat.get_extent().origin().y()) as usize; let location_column = location.x().wrapping_sub(habitat.get_extent().origin().x()) as usize; - let location_index = + let self_dispersal_index = location_row * usize::from(habitat.get_extent().width()) + location_column; // Only safe as trait precondition that `location` is inside `habitat` @@ -41,13 +41,13 @@ impl, G: RngCore> DispersalSampler let dispersal_target_index: usize = if self_dispersal.self_dispersal == ClosedUnitF64::one() { // guaranteed self-dispersal - location_index + self_dispersal_index } else if ( // guaranteed non-self-dispersal self_dispersal.self_dispersal == ClosedUnitF64::zero() ) || ( // self-dispersal with an underfull atom, so included - self_dispersal.non_self_dispersal_event.is_some() + self_dispersal.non_self_dispersal_event != self_dispersal_index ) || ( // excluded self-dispersal, but we sampled non-self-dispersal rng.sample_uniform_closed_open() >= self_dispersal.self_dispersal @@ -62,7 +62,7 @@ impl, G: RngCore> DispersalSampler AliasMethodSamplerAtom::sample_event(alias_dispersals_at_location, rng) } else { // excluded self-dispersal, and we sampled it - location_index + self_dispersal_index }; #[allow(clippy::cast_possible_truncation)] @@ -90,7 +90,7 @@ impl, G: RngCore> SeparableDispersalSampler Location { let location_row = location.y().wrapping_sub(habitat.get_extent().origin().y()) as usize; let location_column = location.x().wrapping_sub(habitat.get_extent().origin().x()) as usize; - let location_index = + let self_dispersal_index = location_row * usize::from(habitat.get_extent().width()) + location_column; // Only safe as trait precondition that `location` is inside `habitat` @@ -120,7 +120,7 @@ impl, G: RngCore> SeparableDispersalSampler, G: RngCore> SeparableDispersalSampler, + // if it is set to self-dispersal, then it marks self-dispersal not + // being part of the alias sampler + non_self_dispersal_event: usize, } #[allow(clippy::module_name_repetitions)] @@ -74,14 +74,16 @@ impl, G: RngCore> InMemoryDispersalSampler, G: RngCore> InMemoryDispersalSampler, G: RngCore> InMemoryDispersalSampler