fn unchecked_new(dispersal: &Array2D<f64>, habitat: &H) -> Self {
        let habitat_extent = habitat.get_extent();

        let mut event_weights: Vec<(usize, f64)> = Vec::with_capacity(dispersal.row_len());

        let mut alias_dispersal_buffer = Vec::new();

        let alias_dispersal_ranges = Array2D::from_iter_row_major(
            dispersal.rows_iter().map(|row| {
                event_weights.clear();

                for (col_index, dispersal_probability) in row.enumerate() {
                    #[allow(clippy::cast_possible_truncation)]
                    let location = Location::new(
                        (col_index % (habitat_extent.width() as usize)) as u32 + habitat_extent.x(),
                        (col_index / (habitat_extent.width() as usize)) as u32 + habitat_extent.y(),
                    );

                    // Multiply all dispersal probabilities by the habitat of their target
                    let weight = dispersal_probability
                        * f64::from(habitat.get_habitat_at_location(&location));

                    if weight > 0.0_f64 {
                        event_weights.push((col_index, weight));
                    }
                }

                let range_from = alias_dispersal_buffer.len();

                if event_weights.is_empty() {
                    AliasSamplerRange::from(range_from..range_from)
                } else {
                    alias_dispersal_buffer
                        .append(&mut AliasMethodSamplerAtom::create(&event_weights));

                    AliasSamplerRange::from(range_from..alias_dispersal_buffer.len())
                }
            }),
            habitat_extent.height() as usize,
            habitat_extent.width() as usize,
        )
        .unwrap(); // infallible by PRE;

        Self {
            alias_dispersal_ranges,
            alias_dispersal_buffer: alias_dispersal_buffer.into_boxed_slice(),
            marker: PhantomData::<(H, G)>,
        }
    }
/// Creates a new `InMemoryPackedAliasDispersalSampler` from the
/// `dispersal` map and extent of the habitat map.
Creates a new `InMemoryPackedAliasDispersalSampler` from the
`dispersal` map and extent of the habitat map.
Creates a new ` InMemoryPackedAliasDispersalSampler ` from the ` dispersal ` map and extent of the habitat map .
fn unchecked_new(dispersal: &Array2D<f64>, habitat: &H) -> Self {
        let habitat_extent = habitat.get_extent();
        let mut event_weights: Vec<(usize, f64)> = Vec::with_capacity(dispersal.row_len());
        let mut alias_dispersal_buffer = Vec::new();
        let alias_dispersal_ranges = Array2D::from_iter_row_major(
            dispersal.rows_iter().map(|row| {
                event_weights.clear();
                for (col_index, dispersal_probability) in row.enumerate() {
                    #[allow(clippy::cast_possible_truncation)]
                    let location = Location::new(
                        (col_index % (habitat_extent.width() as usize)) as u32 + habitat_extent.x(),
                        (col_index / (habitat_extent.width() as usize)) as u32 + habitat_extent.y(),
                    );
                    // Multiply all dispersal probabilities by the habitat of their target
                    let weight = dispersal_probability
                        * f64::from(habitat.get_habitat_at_location(&location));
                    if weight > 0.0_f64 {
                        event_weights.push((col_index, weight));
                    }
                }
                let range_from = alias_dispersal_buffer.len();
                if event_weights.is_empty() {
                    AliasSamplerRange::from(range_from..range_from)
                } else {
                    alias_dispersal_buffer
                        .append(&mut AliasMethodSamplerAtom::create(&event_weights));
                    AliasSamplerRange::from(range_from..alias_dispersal_buffer.len())
                }
            }),
            habitat_extent.height() as usize,
            habitat_extent.width() as usize,
        )
        .unwrap(); // infallible by PRE;
        Self {
            alias_dispersal_ranges,
            alias_dispersal_buffer: alias_dispersal_buffer.into_boxed_slice(),
            marker: PhantomData::<(H, G)>,
        }
    }
fn unchecked_new ( dispersal : & Array2D < f64 > , habitat : & H ) -> Self { let habitat_extent = habitat . get_extent ( ) ; let mut event_weights : Vec < ( usize , f64 ) > = Vec :: with_capacity ( dispersal . row_len ( ) ) ; let mut alias_dispersal_buffer = Vec :: new ( ) ; let alias_dispersal_ranges = Array2D :: from_iter_row_major ( dispersal . rows_iter ( ) . map ( | row | { event_weights . clear ( ) ; for ( col_index , dispersal_probability ) in row . enumerate ( ) { # [ allow ( clippy cast_possible_truncation ) ] let location = Location :: new ( ( col_index % ( habitat_extent . width ( ) as usize ) ) as u32 + habitat_extent . x ( ) , ( col_index / ( habitat_extent . width ( ) as usize ) ) as u32 + habitat_extent . y ( ) , ) ; // Multiply all dispersal probabilities by the habitat of their target let weight = dispersal_probability * f64 :: from ( habitat . get_habitat_at_location ( & location ) ) ; if weight > 0.0_f64 { event_weights . push ( ( col_index , weight ) ) ; } } let range_from = alias_dispersal_buffer . len ( ) ; if event_weights . is_empty ( ) { AliasSamplerRange :: from ( range_from .. range_from ) } else { alias_dispersal_buffer . append ( & mut AliasMethodSamplerAtom :: create ( & event_weights ) ) ; AliasSamplerRange :: from ( range_from .. alias_dispersal_buffer . len ( ) ) } } ) , habitat_extent . height ( ) as usize , habitat_extent . width ( ) as usize , ) . unwrap ( ) ; // infallible by PRE; Self { alias_dispersal_ranges , alias_dispersal_buffer : alias_dispersal_buffer . into_boxed_slice ( ) , marker : PhantomData :: < ( H , G ) > , } }
Creates a new `InMemoryPackedAliasDispersalSampler` from the
`dispersal` map and extent of the habitat map.
Creates a new ` InMemoryPackedAliasDispersalSampler ` from the ` dispersal ` map and extent of the habitat map .
dispersal
&Array2D<f64>
habitat
&H
dispersal
&Array2D<f64>
habitat
&H