this is for holding javascript data
Antonio Coppola edited C++ Functions.tex
over 9 years ago
Commit id: 08e550884203498167399ddff0d246734282f7ab
deletions | additions
diff --git a/C++ Functions.tex b/C++ Functions.tex
index 1bc5710..832f65e 100644
--- a/C++ Functions.tex
+++ b/C++ Functions.tex
...
\subsection{The Basics}
The package supports the implementation of the objective and gradient functions in C++, which may yield significant speed improvements over the respective R implementations. The optimization routine's API accepts both R function objects and external pointers to compiled C++ functions.
In order to be compatible with the lbfgs API, the C++ functions \textbf{must} return an object of type Rcpp::NumericVector, and take in either one or two objects of type SEXP. The first argument of type SEXP must be the pointer to an R numerical vector containing the values of the function's parameters. The second (optional) argument must be the pointer to an R environment holding all extra parameters to be fed into the objective and gradient functions. To perform optimization on the Rosenbrock function, we begin by defining the C++ implementations of the objective and of the gradient as character strings, using the RCPP library:
\begin{lstlisting}
objective.include <- 'Rcpp::NumericVector rosenbrock(SEXP xs) {