Description Usage Arguments Value Author(s) See Also Examples
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
.
1 2 | vectorizeFunction(f, fc = NULL, typeInfo = NULL, module = as(fc, "Module"),
scalarFunName = getName(fc), vectorArgName = names(parms)[1])
|
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 |
The compiled routine
Duncan Temple Lang
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.