vectorizeFunction: Create a vectorized version of a scalar function

Description Usage Arguments Value Author(s) See Also Examples

Description

This function takes an R scalar function or a compiled version of an R function and generates a new function that loops over its inputs element at a time and calls the original scalar function. In the near future, this function will generate a compiled version of the vectorized version. This will be merely a compilation of a call to sapply.

Usage

1
2
vectorizeFunction(f, fc = NULL, typeInfo = NULL, module = as(fc, "Module"),
                  scalarFunName = getName(fc), vectorArgName = names(parms)[1])

Arguments

f

the scalar R function

fc

the compiled version of this scalar function

typeInfo

information about the types of the scalar routine/function

module

the LLVM module in which to create the new routine

scalarFunName

the name of the compiled scalar routine

vectorArgName

the name of the parameter over which we want to vectorize the computations

Value

The compiled routine

Author(s)

Duncan Temple Lang

See Also

compileFunction

Examples

1
2
3
4
5
6
Dnorm = function(x, mu = 0, sd = 1)
         1/sqrt(2 * pi * sd^2) * exp( - .5*( (x-mu)/sd ) ^2)
fc = compileFunction(Dnorm, DoubleType, list(DoubleType, DoubleType,
         DoubleType))

g = vectorizeFunction(Dnorm, fc) 

duncantl/RLLVMCompile documentation built on May 15, 2019, 5:31 p.m.