[Rcpp-commits] r762 - papers/rjournal

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Feb 21 20:35:41 CET 2010


Author: edd
Date: 2010-02-21 20:35:40 +0100 (Sun, 21 Feb 2010)
New Revision: 762

Modified:
   papers/rjournal/EddelbuettelFrancois.tex
Log:
some more corrections and polish


Modified: papers/rjournal/EddelbuettelFrancois.tex
===================================================================
--- papers/rjournal/EddelbuettelFrancois.tex	2010-02-21 19:30:33 UTC (rev 761)
+++ papers/rjournal/EddelbuettelFrancois.tex	2010-02-21 19:35:40 UTC (rev 762)
@@ -363,7 +363,7 @@
 (e.g. \code{std::map<std::string,T>}); as long as 
 the type \code{T} is wrappable;
 \item any type that implements implicit conversion to \code{SEXP} through the 
-\code{operator SEXP()}.
+\code{operator SEXP()};
 \item any type for which the \code{wrap} template is partially or fully 
 specialized.
 \end{itemize}
@@ -520,7 +520,7 @@
 \end{table*}
 
 The next example shows how to use \pkg{Rcpp} to emulate the R code
-\code{rnorm( 10L, sd=100.0)}.
+\code{rnorm(10L, sd=100.0)}.
 %
 As shown in table~\ref{fig:rnormCode}, the code can be expressed in several
 ways in either \pkg{Rcpp} or the standard R API. The first version shows the
@@ -533,7 +533,7 @@
 This example illustrates that the \pkg{Rcpp} API permits us to work with code
 that is easier to read, write and maintain. More examples are available as
 part of the documentation included in the \pkg{Rcpp} package, as well as
-among its over one hundred and fifty unit tests.
+among its over one hundred and ninety unit tests.
 
 
 \section{Using code `inline'}
@@ -703,7 +703,7 @@
 
 In this section, we illustrate how C++ features may well come with a price
 in terms of performance. However, as users of \pkg{Rcpp}, we do not need to
-substitute performance with ease of use.
+compromise performance for ease of use.
 
 As part of the redesign of \pkg{Rcpp}, data copy is kept to the
 absolute minimum. The \code{RObject} class and all its derived
@@ -759,7 +759,7 @@
 \}
 \end{example}
 
-We have benchmarked the various implementations using 1000 replicates of each
+We have benchmarked the various implementations by averaging over 1000 calls of each
 function with \code{a} and \code{b} containing 100 elements
 each.\footnote{The code for this example is contained in the directory
   \code{inst/examples/ConvolveBenchmarks} in the \pkg{Rcpp} package.} The timings
@@ -786,16 +786,10 @@
 
 The first implementation, using the traditional R API, unsurprisingly 
 appears to be the most efficient. It takes advantage of pointer 
-arithmetics and needs not to pay the price of object encapsulation. 
+arithmetics and does not pay the price of object encapsulation. This provides
+our base case.
 
-The last implementation comes close. Replicating the experiment
-shows that the difference is not significant. 
-
-The third implementation illustrates the price of object encapsulation
-and calling an overloaded \code{operator[]} as opposed to using 
-pointer arithmetics.
-
-Finally the second implementation---from the classic \pkg{Rcpp} API---is
+The second implementation---from the classic \pkg{Rcpp} API---is
 clearly behind in terms of efficiency. The difference is mainly 
 caused by the many unnecessary copies that the \code{RcppVector<double>}
 class performs. First, both objects (\code{a} and \code{b})
@@ -805,6 +799,17 @@
 at each access that the index is suitable for the object. Finally, \code{xab}
 is converted back to an R object. 
 
+The third implementation---using the more efficient new \pkg{Rcpp} API---is
+already orders of magnitude faster than the preceding solution. Yet it
+illustrates the price of object encapsulation and of calling an overloaded
+\code{operator[]} as opposed to using pointer arithmetics.
+
+Finally, the last implementation comes very close to the base case and shows
+the code using the new API can essentially as fast as the R API base case
+while being easier to write. 
+
+
+
 \section{Summary}
 
 The \code{Rcpp} package greatly simplifies integration of compiled C++ code



More information about the Rcpp-commits mailing list