RLLVMCompile (version 0.2-0)

vectorizeFunction: Create a vectorized version of a scalar function

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

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

See Also

compileFunction

Examples

Run this code

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) 

Run the code above in your browser using DataLab