On 10 October 2022 at 09:16, Dirk Eddelbuettel wrote: | | On 10 October 2022 at 14:02, Sparapani, Rodney wrote: | | I’m wondering what it would take to make RcppEigen functions | | work wth sourceCpp? Please let me know. Thanks | | The standard one line: add `// [[Rcpp::depends(RcppEigen)]]`
I.e. here is (verbatim) what README.md has: ### Examples A few examples are over at the [Rcpp Gallery](https://gallery.rcpp.org/tags/eigen/). A simple one is ```c++ #include <RcppEigen.h> // [[Rcpp::depends(RcppEigen)]] using Eigen::Map; // 'maps' rather than copies using Eigen::MatrixXd; // variable size matrix, double precision using Eigen::VectorXd; // variable size vector, double precision using Eigen::SelfAdjointEigenSolver; // one of the eigenvalue solvers // [[Rcpp::export]] VectorXd getEigenValues(Map<MatrixXd> M) { SelfAdjointEigenSolver<MatrixXd> es(M); return es.eigenvalues(); } ``` which can be turned into a function callable from R via a simple ``` sourceCpp("eigenExample.cpp") ``` due to the two Rcpp directives to use headers from the RcppEigen package, and to export the `getEigenValues()` function -- but read [the full post](https://gallery.rcpp.org/articles/eigen-eigenvalues/) for details. Dirk -- dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel