[R] O/T good c/c++ code for LU decomposition

Romain Francois romain.francois at dbmail.com
Tue Jul 27 00:18:40 CEST 2010


Hi,

Armadillo (http://arma.sourceforge.net/docs.html) has LU. Here is an 
example adapted from armadillo's documentation using Rcpp/RcppArmadillo 
and inline:

require( inline )
require( RcppArmadillo )

fx <- cxxfunction( signature( A_ = "matrix"), '
using namespace arma ;
mat A = as<mat>(A_);

mat L;
mat U;
mat P;

lu(L, U, P, A);

mat B = trans(P)*L*U;
return List::create(
	_["L"] = L,
	_["U"] = U,
	_["P"] = P,
	_["A"] = A,
	_["B"] = B
	) ;
', plugin = "RcppArmadillo" )
fx( matrix( runif(100), 10, 10) )


Romain

Le 26/07/10 23:46, Erin Hodgess a écrit :
>
> Dear R People:
>
> Could someone recommend a good c/c++ code (or Fortran) for LU
> decomposition, please?
>
> Sorry to bother about this.  I'm trying to do some "non-R" work that
> requires a matrix inversion.
>
> Thanks,
> Erin
>
>


-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/bc8jNi : Rcpp 0.8.4
|- http://bit.ly/dz0RlX : bibtex 0.2-1
`- http://bit.ly/a5CK2h : Les estivales 2010



More information about the R-help mailing list