[R] "best" c++ matrix library?

Rafael Laboissiere laboissiere at cbs.mpg.de
Wed Aug 31 22:28:29 CEST 2005


* Ott Toomet <otoomet at ut.ee> [2005-08-31 19:53]:

> I am planning to write some more time-consuming matrix manipulations
> in c++.  What is the experience with the existing c++ matrix
> libraries?  Do you have some recommendations?  Are some libraries more
> compatible with R than the others?

Liboctave is a quite powerful C++ matrix library.  It is part of Octave
(www.octave.org), but you can write standalone applications with it.
Since liboctave links against standard Fortran and C libraries (lapack,
odepack, minpack, quadpack, slatec, fftw, etc), you have access to all
matrix algorithms of Octave.

Attached below is an example, showing eigenvalue computation (via the
lapack routine).  Also attached is the compilation command and the output
of the program (in my Debian sarge box).

I do not know how liboctave compares with the other libraries as regards
speed.  As far as I know, there is no efforts for gluing liboctave into
R. 

-- 
Rafael Laboissiere
-------------- next part --------------
$ g++ -I/usr/include/octave eig.cc -o eig -L/usr/lib/octave-2.1.69/ -loctave
$ LD_LIBRARY_PATH=/usr/lib/octave-2.1.69/ ./eig
Original Matrix
 3 2
 2 0

Eigen Vectors
 (0.447214,0) (-0.894427,0)
 (-0.894427,0) (-0.447214,0)

Eigen Values
(-1,0)
(4,0)

Recomposed Matrix
 (3,0) (2,0)
 (2,0) (-9.92587e-17,0)


More information about the R-help mailing list