[Rd] matrix algebra in c

Richard D. Morey r.d.morey at rug.nl
Tue Jul 14 20:10:52 CEST 2009

I'd like to use some matrix algebra in my c code that is called from R.
I need matrix multiplication, transposition, and Cholesky decomposition.
I haven't come across any easy way to do this, but from browsing the web
and R-devel a few options come to mind:

1. use F77_CALL() to call matrix multiplication functions from blas.
This should be ok as long as I remember that c and FORTRAN store
matrices differently.

2. include gsl code and link against the gsl binaries? This seems like
it would cause problems compiling it on different systems.

3. write my own code (bad idea)

4. Call R from my C code (slow?)

What's the best/easiest way? I don't really care how the matrices are
represented in c (could be gsl_matrix, SEXP, whatever) as long as it works.

Richard Morey

More information about the R-devel mailing list