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
743
743
744
744
Rcpp Attributes, once again, makes this even easier:
745
745
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
749
758
A <- matrix (1 : 9 , 3 , 3 )
750
759
B <- matrix (9 : 1 , 3 , 3 )
751
760
mult(A ,B )
761
+ */
752
762
@
753
763
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
+
754
768
\subsection {How do I write a plugin for \pkg {inline} and/or Rcpp Attributes? }
755
769
756
770
\begin {quote }
You can’t perform that action at this time.
0 commit comments