|
1 | | -## RcppEigen |
| 1 | +## RcppEigen: Rcpp Integration for the Eigen Templated Linear Algebra Library |
2 | 2 |
|
3 | | -[](https://travis-ci.org/RcppCore/RcppEigen) |
4 | | -[](http://www.gnu.org/licenses/gpl-2.0.html) |
5 | | -[](http://www.mozilla.org/MPL/2.0/) |
6 | | -[](https://cran.r-project.org/package=RcppEigen) |
| 3 | +[](https://travis-ci.org/RcppCore/RcppEigen) |
| 4 | +[](http://www.gnu.org/licenses/gpl-2.0.html) |
| 5 | +[](http://www.mozilla.org/MPL/2.0/) |
| 6 | +[](https://cran.r-project.org/package=RcppEigen) |
7 | 7 | [](https://cran.r-project.org/package=RcppEigen) |
8 | | -[](https://packages.debian.org/sid/r-cran-rcppeigen) |
| 8 | +[](https://packages.debian.org/sid/r-cran-rcppeigen) |
| 9 | +[](https://github.com/RcppCore/RcppEigen) |
9 | 10 | [](http://www.r-pkg.org/pkg/RcppEigen) |
10 | 11 | [](https://cran.r-project.org/package=RcppEigen) |
11 | 12 | [](https://cran.r-project.org/package=RcppEigen) |
12 | 13 | [](https://stackoverflow.com/questions/tagged/rcpp) |
13 | 14 |
|
14 | | -### Overview |
| 15 | +### Synopsis |
15 | 16 |
|
16 | | -[Eigen](http://eigen.tuxfamily.org) is a C++ template library for linear |
17 | | -algebra: matrices, vectors, numerical solvers and related algorithms. It |
18 | | -supports dense and sparse matrices on integer, floating point and complex |
19 | | -numbers, decompositions of such matrices, and solutions of linear |
20 | | -systems. Its performance on many algorithms is comparable with some of the |
21 | | -best implementations based on `Lapack` and level-3 `BLAS`. |
| 17 | +[Eigen](http://eigen.tuxfamily.org) is a C++ template library for linear algebra: |
| 18 | +matrices, vectors, numerical solvers and related algorithms. It supports dense and sparse |
| 19 | +matrices on integer, floating point and complex numbers, decompositions of such matrices, |
| 20 | +and solutions of linear systems. Its performance on many algorithms is comparable with |
| 21 | +some of the best implementations based on `Lapack` and level-3 `BLAS`. |
| 22 | + |
| 23 | +RcppEigen provides an interface from R to and from [Eigen](http://eigen.tuxfamily.org) by |
| 24 | +using the facilities offered by the [Rcpp](http://dirk.eddelbuettel.com/code/rcpp.html) |
| 25 | +package for seamless R and C++ integration. |
| 26 | + |
| 27 | +### Examples |
| 28 | + |
| 29 | +A few examples are over at the [Rcpp Gallery](http://gallery.rcpp.org/tags/eigen/). A simple one is |
| 30 | + |
| 31 | +```c++ |
| 32 | +#include <RcppEigen.h> |
| 33 | + |
| 34 | +// [[Rcpp::depends(RcppEigen)]] |
| 35 | + |
| 36 | +using Eigen::Map; // 'maps' rather than copies |
| 37 | +using Eigen::MatrixXd; // variable size matrix, double precision |
| 38 | +using Eigen::VectorXd; // variable size vector, double precision |
| 39 | +using Eigen::SelfAdjointEigenSolver; // one of the eigenvalue solvers |
| 40 | + |
| 41 | +// [[Rcpp::export]] |
| 42 | +VectorXd getEigenValues(Map<MatrixXd> M) { |
| 43 | + SelfAdjointEigenSolver<MatrixXd> es(M); |
| 44 | + return es.eigenvalues(); |
| 45 | +} |
| 46 | +``` |
| 47 | +
|
| 48 | +which can be turned into a function callable from R via a simple |
| 49 | +
|
| 50 | +``` |
| 51 | +sourceCpp("eigenExample.cpp") |
| 52 | +``` |
| 53 | +
|
| 54 | +due to the two Rcpp directives to use headers from the RcppEigen package, and to export |
| 55 | +the `getEigenValues()` function -- but read [the full |
| 56 | +post](http://gallery.rcpp.org/articles/eigen-eigenvalues/) for details. |
22 | 57 |
|
23 | | -The RcppEigen package includes the header files from the Eigen C++ |
24 | | -template library (currently version 3.3.5). Thus users do not need to |
25 | | -install Eigen itself in order to use RcppEigen. |
26 | 58 |
|
27 | 59 | ### Status |
28 | 60 |
|
|
0 commit comments