R/expandGrid.R

Defines functions expandGridIter expandGridCount expandGridSample expandGrid

Documented in expandGrid expandGridCount expandGridIter expandGridSample

expandGrid <- function(..., lower = NULL, upper = NULL,
                       nThreads = NULL, return_df = FALSE) {

    lst <- GridInputs(...)

    if (lst$early_return) {
        return(lst$res)
    }

    res <- .Call(
        `_RcppAlgos_ExpandGridCpp`, lst$p, lower, upper,
        nThreads, pkgEnv$maxThreads, FALSE, NULL, NULL, NULL,
        sample, FALSE, NULL, return_df
    )

    return(res)
}

expandGridSample <- function(
    ..., n = NULL, sampleVec = NULL, seed = NULL,
    nThreads = NULL, namedSample = FALSE, return_df = FALSE
) {

    if (!is.null(seed)) {
        set.seed(seed)
    }

    lst <- GridInputs(...)

    if (lst$early_return) {
        return(lst$res)
    }

    res <- .Call(
        `_RcppAlgos_ExpandGridCpp`, lst$p, NULL, NULL, nThreads,
        pkgEnv$maxThreads, TRUE, sampleVec, seed, n, sample,
        namedSample, new.env(), return_df
    )

    return(res)
}

expandGridCount <- function(...) {

    lst <- GridInputs(...)

    if (lst$early_return) {
        return(nrow(lst$res))
    }

    return(.Call(`_RcppAlgos_ExpandGridCountCpp`, lst$p))
}

expandGridIter <- function(..., nThreads = NULL, return_df = FALSE) {

    lst <- GridInputs(...)

    if (lst$early_return) {
        return(nrow(lst$res))
    }

    new("Cartesian", lst$p, nThreads, return_df)
}

Try the RcppAlgos package in your browser

Any scripts or data that you put into this service are public.

RcppAlgos documentation built on March 8, 2026, 9:08 a.m.