R/apply.r

Defines functions genericLapply genericApply

genericApply <- function(mat, margin, func, ..., nthread=1, clutype="PSOCK")
{
    if(nthread <= 1)
        return(apply(mat,margin,func,...))
    cl <- parallel::makeCluster(nthread,type=clutype)
    ret <- tryCatch(parallel::parApply(cl,mat,margin,func,...),
                    finally=parallel::stopCluster(cl))
    return(ret)
}

genericLapply <- function(x, func, ..., nthread=1, clutype="PSOCK")
{
    if(nthread <= 1)
        return(lapply(x, func, ...))
    cl <- parallel::makeCluster(nthread,type=clutype)
    ret <- tryCatch(parallel::parLapply(cl,x,func,...),
                    finally=parallel::stopCluster(cl))
    return(ret)
}

Try the DynamicGP package in your browser

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

DynamicGP documentation built on Nov. 10, 2022, 5:15 p.m.