R/RcppExports.R

Defines functions move_population move_prob_Lst move_prob distance_calc

Documented in distance_calc move_population move_prob move_prob_Lst

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' @title distance calculation
#'
#' @description \code{distance_calc} calculates the euclidean distance between
#' two cell references.
#'
#' @param x1 is an integar for the starting x position
#' @param y1 is an integar for the starting y position
#' @param x2 is an integar for the end x position
#' @param y2 is an integar for the end y position
#'
#' @return is a distance between the two cells
#'
#' @examples distance_calc(2, 3, 5, 7) 
#'
#' @export
distance_calc <- function(x1, y1, x2, y2) {
    .Call('_MixFishSim_distance_calc', PACKAGE = 'MixFishSim', x1, y1, x2, y2)
}

#' @title movement probability function 
#'
#' @description \code{move_prob} calculates the movement probability between 
#' a cell and all other cells based on the distance and \emph{lambda}.
#'
#' @param start is a Numeric vector of dim 2 for the starting position c(x,y)
#' @param lambda is an integar for the value for the exponential decay in probability 
#' of movement, i.e. \eqn{Pr(B|A) = \exp{-\lambda*dist_{a,b}} / Sum(c=1:c=n)  \exp{-\lambda*dist}}
#' @param hab is a matrix of the habitat suitability
#'
#' @return is a matrix of the movement probabilities from a cell
#'
#' @examples move_prob(c(2, 5), 0.3, matrix(nc = 3, runif(9))) 
#' 
#' @export
move_prob <- function(start, lambda, hab) {
    .Call('_MixFishSim_move_prob', PACKAGE = 'MixFishSim', start, lambda, hab)
}

#' @title movement probability function as a list 
#'
#' @description \code{move_prob_list} applies \code{\link{move_prob}} from all
#' cells to all other cells and returns as a list.
#'
#' @param lambda is the decay value as in \code{move_prob} 
#' @param hab is a matrix of the habitat suitability for the population
#'
#' @return is a list of the movement probabilities form each cell to all other
#' cells
#'
#' @examples None at the moment
#'
#' @export
move_prob_Lst <- function(lambda, hab) {
    .Call('_MixFishSim_move_prob_Lst', PACKAGE = 'MixFishSim', lambda, hab)
}

#' @title population movement function 
#'
#' @description \code{move_population} redistributes the population based on
#' the movement probabilities
#' @param moveProp is a list of the proportion of the population from each
#' cell to reallocated to each of the other cells
#' @param StartPop is a Numeric Matrix of the current populations distribution 
#'
#' @return is a list of the new position for the population from each of the
#' cells. 
#' 
#' NOTE: This is not aggregated and requires calling the R function
#' \emph{Reduce('+', Lst)} to reaggregate. Would be better if done in function
#' but Reduce is currently faster...but much more memory intensive to get out
#' the lists...using the standard c++ accumulate
#' function may work for this but untested
#'
#' @examples None at the moment
#'
#' @export
move_population <- function(moveProp, StartPop) {
    .Call('_MixFishSim_move_population', PACKAGE = 'MixFishSim', moveProp, StartPop)
}
pdolder/MixFishSim documentation built on Oct. 17, 2023, 4:25 p.m.