@@ -73,7 +73,7 @@ require(highlight)
7373
7474\abstract {
7575 \noindent This document attempts to answer the most Frequently Asked
76- Questions (FAQ) regarding the \pkg {Rcpp} \citep {CRAN:Rcpp ,JSS:Rcpp } package.
76+ Questions (FAQ) regarding the \pkg {Rcpp} \citep {CRAN:Rcpp ,JSS:Rcpp , Eddelbuettel:2013:Rcpp } package.
7777}
7878
7979\section {Getting started }
@@ -179,7 +179,8 @@ Further steps, specific to \pkg{Rcpp}, are described in a separate vignette.
179179vignette( " Rcpp-package" )
180180@
181181
182- \subsection {How do I quickly prototype my code using inline? }
182+ \subsection {How do I quickly prototype my code? }
183+ \subsubsection {Using inline }
183184\label {using-inline }
184185
185186The \pkg {inline} package \citep {CRAN:inline } provides the functions
@@ -218,8 +219,31 @@ fx <- cxxfunction( signature(),
218219The \texttt {verbose } argument of \Sexpr{link(" cxxfunction" )} is very
219220useful as it shows how \pkg {inline} runs the show.
220221
221- Update: Also see question \ref {using-attributes } below about 'Rcpp
222- Attributes' \citep {CRAN:Rcpp:Attributes }.
222+ \subsubsection {Using Rcpp Attributes }
223+ \label {using-attributes }
224+
225+ Rcpp Attributes \citep {CRAN:Rcpp:Attributes }, discussed in \faq {using-attributes} below, permits an even easier
226+ route to integrating R and C++. It provides three key functions. First, \code {evalCpp}
227+ provide a means to evaluate simple C++ expression which is often useful for
228+ small tests, or to simply check if the toolchain is set up
229+ correctly. Second, \code {cppFunction} can be used to create C++ functions
230+ for R use on the fly. Third, \code {sourceCpp} can integrate entire files in
231+ order to define multiple functions.
232+
233+ The example above can now be rewritten as:
234+
235+ <<>>=
236+ cppFunction(' double accu(NumericVector x) {
237+ return(std::accumulate(x.begin(), x.end(), 0.0));
238+ }' )
239+ res <- accu(seq(1 , 10 , by = 0.5 ))
240+ res
241+ @
242+
243+ The \code {cppFunction} parses the supplied text, extracts the desired
244+ function names, creates the required scaffolding, compiles, links and loads
245+ the supplied code and makes it available under the selected identifier.
246+
223247
224248\subsection {How do I convert my prototyped code to a package ? }
225249\label {from-inline-to-package }
@@ -387,8 +411,15 @@ which is described in detail in its own vignette
387411
388412\section {Examples }
389413
390- The following questions were asked on the \texttt {rcpp-devel } mailing list,
391- which is generally the best place to ask questions.
414+ The following questions were asked on the
415+ \href {https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel}{Rcpp-devel}
416+ mailing list, which is our preferred place to ask questions as it guarantees
417+ exposure to a number of advanced Rcpp users. The
418+ \href {http://stackoverflow.com/questions/tagged/rcpp}{StackOverflow tag for
419+ rcpp} is an alternative; that site is also easily searchable.
420+
421+ Several dozen fully documented examples are provided at the
422+ \href {http://gallery.rcpp.org}{Rcpp Gallery} -- which is also open for new contributions.
392423
393424\subsection {Can I use templates with \pkg {Rcpp} and \pkg {inline} ? }
394425
@@ -423,10 +454,11 @@ fun <- cxxfunction(signature(xs="numeric", is="integer"),
423454fun(2.2 , 3L )
424455@
425456
426- Update: Also see question \ref {using-attributes } above about 'Rcpp
457+ Update: Also see \faq {using-attributes} above about 'Rcpp
427458Attributes' \citep {CRAN:Rcpp:Attributes } and its \code {sourceCpp} function.
428459
429460\subsection {Can I do matrix algebra with \pkg {Rcpp} ? }
461+ \label {matrix-algebra }
430462
431463\begin {quote }
432464 \emph {\pkg {Rcpp} allows element-wise operations on vector and matrices through
@@ -440,15 +472,16 @@ project (if done right) involving advanced techniques such as expression
440472templates. We currently do not plan to go in this direction, but we would
441473welcome external help. Please send us a design document.
442474
443- However, we have developed the \pkg {RcppArmadillo} package \citep {CRAN:RcppArmadillo } that provides a
475+ However, we have developed the \pkg {RcppArmadillo} package
476+ \citep {CRAN:RcppArmadillo ,Eddelbuettel +Sanderson:2014:RcppArmadillo } that provides a
444477bridge between \pkg {Rcpp} and \pkg {Armadillo} \citep {Sanderson:2010:Armadillo }. \pkg {Armadillo}
445478supports binary operators on its types in a way that takes full advantage of
446479expression templates to remove temporaries and allow chaining of
447480operations. That is a mouthful of words meaning that it makes the code go
448481faster by using fiendishly clever ways available via the so-called template
449482meta programming, an advanced \proglang {C++} technique.
450- Also, the \pkg {RcppEigen} package provides an alternative using the
451- \href {Eigen}{ http://eigen.tuxfamily.org} template library.
483+ Also, the \pkg {RcppEigen} package \citep { JSS:RcppEigen } provides an alternative using the
484+ \href {http://eigen.tuxfamily.org}{Eigen } template library.
452485
453486
454487The following example is adapted from the examples available at the project
@@ -521,6 +554,10 @@ fx()
521554fx()
522555@
523556
557+ Newer versions of Rcpp also provide the actual Rmath function in the \code {R}
558+ namespace, \textsl {i.e.} as \code {R::rnorm(m,s)} to obtain a scalar
559+ random variable distributed as $ N(m,s)$ .
560+
524561\subsection {Can I use NA and Inf with \pkg {Rcpp} ? }
525562
526563\begin {quote }
@@ -548,7 +585,7 @@ fun()
548585\end {quote }
549586
550587\noindent Yes, via the \pkg {RcppArmadillo} package which builds upon \pkg {Rcpp} and the
551- wonderful Armadillo library at \url {http://arma.sf.net }:
588+ wonderful Armadillo library described above in \faq {matrix-algebra }:
552589
553590<<eval =FALSE >>=
554591txt <- ' arma::mat Am = Rcpp::as< arma::mat >(A);
@@ -569,7 +606,7 @@ C <- mmult(A, B)
569606Armadillo supports a full range of common linear algebra operations.
570607
571608The \pkg {RcppEigen} package provides an alternative using the
572- \href {Eigen}{ http://eigen.tuxfamily.org} template library.
609+ \href {http://eigen.tuxfamily.org}{Eigen } template library.
573610
574611\subsection {How do I write a plugin for \pkg {inline} ? }
575612
@@ -737,15 +774,21 @@ searching.
737774\subsection {I like it. How can I help ? }
738775\label {helping }
739776
740- We maintain a list of issues in the github repository
741- we use. \href {https://github.com/RcppCore/Rcpp/issues?state=open}.
777+ We maintain a list of
778+ \href {https://github.com/RcppCore/Rcpp/issues?state=open}{open issues in the
779+ Github repository}. We welcome pull requests and suggest that code submissions
780+ come corresponding unit tests and, if applicable, documentation.
742781
743782If you are willing to donate time and have skills in C++, let us know. If you are
744- willing to donate money to sponsor improvements, let us know.
783+ willing to donate money to sponsor improvements, let us know too .
745784
746785You can also spread the word about \pkg {Rcpp}. There are many packages on CRAN
747786that use \proglang {C++}, yet are not using \pkg {Rcpp}. You could blog about
748- it or get the word out otherwise.
787+ it, or get the word out otherwise.
788+
789+ Last but not least the \href {http://gallery.rcpp.org}{Rcpp Gallery} is open
790+ for user contributions.
791+
749792
750793\subsection {I don't like it. How can I help ? }
751794
@@ -761,6 +804,16 @@ request.
761804
762805Yes. Just send us an email.
763806
807+ \subsection {Where is to code repository ? }
808+
809+ From late 2008 to late 2013, we used the
810+ \href {https://r-forge.r-project.org/scm/?group_id=155}{Subversion repository at R-Forge}
811+ which contained Rcpp and a number of related packages. It still has the full
812+ history as well as number of support files.
813+
814+ We have since switched to a \href {http://github.com/RcppCore/Rcpp}{Git
815+ repository at Github} for Rcpp (as well as RcppArmadillo and RcppEigen).
816+
764817\bibliographystyle {plainnat}
765818\bibliography {Rcpp}
766819
0 commit comments