## Overview

RcppArmadillo provides an interface from R to and from Armadillo by utilising the Rcpp R/C++ interface library.

## So what is Armadillo?

Armadillo is a C++ linear algebra library aiming towards a good balance between speed and ease of use. Integer, floating point and complex numbers are supported, as well as a subset of trigonometric and statistics functions. Various matrix decompositions are provided through optional integration with LAPACK and ATLAS libraries.

A delayed evaluation approach is employed (during compile time) to combine several operations into one and reduce (or eliminate) the need for temporaries. This is accomplished through recursive templates and template meta-programming.

This library is useful if C++ has been decided as the language of choice (due to speed and/or integration capabilities), rather than another language.

## So give me an example!

Sure, glad you asked. Here is a simple implementation of a fast linear regression (provided by RcppArmadillo via the `fastLm()`

function:

```
#include <RcppArmadillo.h>
using namespace Rcpp;
// [[Rcpp::export]]
List fastLm(const arma::mat& X, const arma::colvec& y) {
int n = X.n_rows, k = X.n_cols;
arma::colvec coef = arma::solve(X, y); // fit model y ~ X
arma::colvec res = y - X*coef; // residuals
// std.errors of coefficients
double s2 = std::inner_product(res.begin(), res.end(), res.begin(), 0.0)/(n - k);
arma::colvec std_err = arma::sqrt(s2 * arma::diagvec(arma::pinv(arma::trans(X)*X)));
return List::create(Named("coefficients") = coef,
Named("stderr") = std_err,
Named("df.residual") = n - k);
}
```

## Where do I get it?

RcppArmadillo is a CRAN package, and lives otherwise in its own habitat on GitHub within the RcppCore GitHub organization.

## Authors

RcppArmadillo is being written by Romain Francois, Dirk Eddelbuettel and Doug Bates using Rcpp and building on top of the excellent Armadillo library by Conrad Sanderson.

## License

Armadillo up to version 7.700 is licensed under the MPL version 2; versions 7.800 and later are licensed under the Apache License 2.0. RcppArmadillo (the Rcpp bindings/bridge to Armadillo) is license under GNU GPL version 2 or later, as is the rest of Rcpp.

Initially created: Thu Mar 11 11:14:31 CST 2010

Last modified: Sat Feb 18 07:55:26 CST 2017