[Rcpp-commits] r582 - papers/rjournal

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Feb 5 16:25:39 CET 2010


Author: romain
Date: 2010-02-05 16:25:39 +0100 (Fri, 05 Feb 2010)
New Revision: 582

Modified:
   papers/rjournal/EddelbuettelFrancois.tex
Log:
comment

Modified: papers/rjournal/EddelbuettelFrancois.tex
===================================================================
--- papers/rjournal/EddelbuettelFrancois.tex	2010-02-05 15:11:50 UTC (rev 581)
+++ papers/rjournal/EddelbuettelFrancois.tex	2010-02-05 15:25:39 UTC (rev 582)
@@ -309,7 +309,7 @@
 A second example deals with character vectors and emulates this R code
 
 \begin{example}
-> x <- c("foo", "bar")
+> c("foo", "bar")
 \end{example}
 
 Using the traditional R API, the vector can be allocated and filled as such:
@@ -353,7 +353,7 @@
 \end{example}
 
 The templated function takes a reference to a `wrappable` 
-object and convert this object into a SEXP, which is what R expects. 
+object and convert this object into a \code{SEXP}, which is what R expects. 
 Currently wrappable types are :
 \begin{itemize}
 \item primitive types, \code{int}, \code{double}, ... which are converted 
@@ -463,7 +463,7 @@
 
 The same mechanism is used throughout the API, including : access/modification
 of object attributes, slots, elements of generic vectors (lists), 
-function arguments. 
+function arguments, nodes of dotted pair lists and language calls, etc ... 
 
 \section{Function calls}
 
@@ -474,7 +474,9 @@
 \end{example}
 
 The code can be expressed in several ways in \pkg{Rcpp}, the first version
-shows the use of the \code{Environment} and \code{Function} classes. 
+shows the use of the \code{Environment} and \code{Function} classes
+\footnote{We have removed the \code{Rcpp::} prefix from the
+following examples for readability.}. 
 
 \begin{example}
 Environment stats("package:stats") ;
@@ -498,7 +500,10 @@
 In this version, we first create a call to the symbol "rnorm" and
 evaluate the call in the global environment. In both cases, \code{wrap}
 is used implicitely to convert \code{10} and \code{100} 
-into R integer vectors. 
+into R integer vectors. It should be noted that this 
+version involves potentially expensive implicit lookup in the search path
+to find the "rnorm" function. 
+% should we quote luke's : http://www.cs.uiowa.edu/~luke/R/bytecode.html
 
 Using the R API, the first example, using the actual \code{rnorm} function,
 translates to :
@@ -518,9 +523,7 @@
 return res ;
 \end{example}
 
-and the second example, using the \samp{rnorm} symbol --- and therefore
-involving potentially expensive implicit lookup in the search path ---
-can be written as:
+and the second example, using the \samp{rnorm} symbol, can be written as:
 
 \begin{example}
 SEXP call  = PROTECT( 
@@ -590,15 +593,12 @@
 	src, Rcpp=TRUE)
 \end{example}
 
-% [Romain]: I've removed the line
-% for (int i = 0; i < nab; i++) xab[i] = 0.0;
-% because the constructor now does it automatically to match 
-% what numeric( 10 ) would do in R
-
 The main difference to the previous solution is that the input parameters are
 directly passed to types \code{Rcpp::NumericVector}, and that the return
 vector is automatically converted to a \code{SEXP} type through implicit
-conversion.
+conversion. Also in this version, the vector \code{xab} is not 
+initialized because the constructor already performs initialization
+to match the behaviour of the R function \code{numeric}.
 
 \section{Error handling}
 



More information about the Rcpp-commits mailing list