File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -743,14 +743,28 @@ The \pkg{RcppEigen} package provides an alternative using the
743743
744744Rcpp Attributes, once again, makes this even easier:
745745
746- <<>>=
747- cppFunction(' arma::mat mult(arma::mat A, arma::mat B) { return A*B; }' ,
748- depends = " RcppArmadillo" ) # needed to use RcppArmadillo
746+ <<lang =cpp >>=
747+
748+ # include <RcppArmadillo.h>
749+
750+ // [[Rcpp :: depends(RcppArmadillo )]]
751+
752+ // [[Rcpp :: export ]]
753+ arma :: mat mult(arma :: mat A , arma :: mat B ) {
754+ return A * B ;
755+ }
756+
757+ /*** R
749758A <- matrix (1 : 9 , 3 , 3 )
750759B <- matrix (9 : 1 , 3 , 3 )
751760mult(A ,B )
761+ */
752762@
753763
764+ which can be built, and run, from R via a simple \rdoc {Rcpp}{sourceCpp}
765+ call---and will also run the small R example at the end.
766+
767+
754768\subsection {How do I write a plugin for \pkg {inline} and/or Rcpp Attributes? }
755769
756770\begin {quote }
You can’t perform that action at this time.
0 commit comments