R/RcppExports.R

Defines functions simd_size get_n_eff_cpp draw_nb_offspring_cpp

Documented in draw_nb_offspring_cpp get_n_eff_cpp simd_size

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

#' Draw a number of offspring given a fitness value
#'
#' The number of offspring is drawn in a Poisson distribution in
#' `rpois(lambda = fitness)`. Vectorized.
#'
#' @param fitness a vector of positive floats, the fitness value(s).
#'
#' @seealso get_fitness
#' @author Theo Pannetier
#' @export
#' @name draw_nb_offspring_cpp
NULL

draw_nb_offspring_cpp <- function(fitness) {
    .Call('_comsie_draw_nb_offspring_cpp', PACKAGE = 'comsie', fitness)
}

#' SIMD size
#'
#' Returns the number of cores that can be used for SIMD
#' @name simd_size
#' @author Hanno Hildenbrandt
#' @export
NULL

#' Compute the effective population size
#'
#' Computes \code{n_eff}, the effective population size experienced by an
#' individual.
#' @param z numeric vector, the trait values of all individuals in the
#' community.
#' @param competition_sd numeric `>= 0`. Width of the competition kernel.
#' @param brute_force_opt a string specifying which brute force option to use
#' to speed up the calculation of competition coefficients. Defaults to "none".
#' Other options are omp", for multithreading with OpenMP, "simd" for single
#' instruction, multiple data (SIMD) via the C++ library
#' [`xsimd`](https://github.com/xtensor-stack/xsimd); and "simd_omp" for both.
#' @details `n_eff` sums the competitive effects an individual receives from
#' every individual in the community, including the individual itself. It is
#' called effective population size because it is the size of the population
#' that is relevant for competition.
#' @name get_n_eff_cpp
#' @author Hanno Hildenbrandt
#' @export
get_n_eff_cpp <- function(z, competition_sd, brute_force_opt = "none") {
    .Call('_comsie_get_n_eff_cpp', PACKAGE = 'comsie', z, competition_sd, brute_force_opt)
}

simd_size <- function() {
    .Call('_comsie_simd_size', PACKAGE = 'comsie')
}
TheoPannetier/comsie documentation built on Nov. 21, 2022, 4:35 p.m.