RcppExample {Rcpp} | R Documentation |
RcppExample
illustrates how the Rcpp
R/C++
interface class library is used.
RcppExample(params, nlist, vec, mat)
params |
A parameter list specifying method (string),
tolerance (double), maxIter (int) |
nlist |
a list of named numeric values (double or int) |
vec |
a numeric 1D vector (double or int) |
mat |
a numeric 2D matrix (double or int) |
See the document Rcpp: R/C++ Interface Classes: Using C++
Libraries from R
for more information. The source
code for the example and for Rcpp
(along with source code for
the test library MyLib
) can be found
in the Rcpp
package doc
subdirectory.
RcppExample
returns a list containing:
nlFirstName |
first name in nlist |
nlFirstValue |
first value in nlist |
matD |
an RcppMatrix<double> object |
vecD |
a RcppVector<double> object |
a |
A matrix in C/C++ format |
v |
A vector in C/C++ format |
settleDays |
An integer-valued parameter |
price |
A real-valued parameter |
riskFreeRate |
A real-valued parameter |
dividendYield |
A real-valued parameter |
params |
The input parameter list |
Dominick Samperi
params <- list(optType='call', tradeDate=c(5,15,1998), settleDays=2, exerciseDate=c(5,17,1999), strikePrice=8, price= 7, volatility=0.10, riskFreeRate=0.05, dividendYield=0.05) nlist <- list(ibm = 80.50, hp = 53.64, c = 45.41) vec <- seq(1,5) mat <- matrix(seq(1,20),4,5) result <- RcppExample(params, nlist, vec, mat) result