R/RcppExports.R

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

#' emptyNumeric
#'
#' Creates an uninitialized numeric vector (that is, assigns values according to what was allocated in the memory)
#'
#' @param n Number of elements
#'
#'@details The calculation time is O(1) + time(memory allocation), which is handled internally by R.
#'For small values of n, \code{numeric} is faster, but for large values of n, \code{emptyNumeric} is much faster.
#'
#'@return A numeric vector of length n
#'
#'@examples
#'vals <- numeric(1e7)
emptyNumeric <- function(n) {
    .Call('_emptyInit_emptyNumeric', PACKAGE = 'emptyInit', n)
}

#' emptyMatrix
#'
#' Creates an uninitialized matrix (that is, assigns values according to what was allocated in the memory)
#'
#' @param nrow,ncol number of rows and columns
#'
#'@return A numeric matrix of dim nrow x ncol.
#'
#'@examples
#'mat <- emptyMatrix(10, 10)
#'
#'# Initialize matrix with 1000000 entries
#'require(microbenchmark)
#'microbenchmark(matrix(, 100, 10000))
#'microbenchmark(emptyMatrix(100, 10000))
emptyMatrix <- function(nrow, ncol) {
    .Call('_emptyInit_emptyMatrix', PACKAGE = 'emptyInit', nrow, ncol)
}
naolsen/emptyInit documentation built on May 23, 2019, 5:07 p.m.