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

Martin Maechler maechler at stat.math.ethz.ch
Thu Sep 1 13:30:12 CEST 2005


>>>>> "Romain" == Romain Francois <francoisromain at free.fr>
>>>>>     on Thu, 01 Sep 2005 11:19:59 +0200 writes:

    Romain> Le 01.09.2005 10:32, Ott Toomet a écrit :
    >> Thanks for everyone who replied to my question.
    >> 
    >> I tried newmat myself, seems to be working well.  What I
    >> am interested in is something like
    >> 
    >> * Fast element-wise operations.  You know, it may be slow
    >> in R.
    >> 
    >> * (Some) control over memory allocation.  I would like to
    >> specify when the matrix should not be copied.
    >> 
    >> * Compatibility with R.  At least the way how the matrix
    >> data is represented in memory should be the same as R
    >> has.  Otherwise, the data interchange may become slow and
    >> memory-consuming.
    >> 
    >> * And, of course, the basic matrix operations like
    >> multiplication, inverting, eigenvalues etc....
    >> 
    >> I am using linux/gcc if that matters.
    >> 
    >> Best, Ott | From: "Tuszynski, Jaroslaw W."
    >> <JAROSLAW.W.TUSZYNSKI at saic.com> | Date: Wed, 31 Aug 2005
    >> 12:59:04 -0400
    >> | 
    >> | What kind of matrix operations do you need?
    >> | 
    >> | Jarek
    >> | 
    >> | -----Original Message----- | From:
    >> r-help-bounces at stat.math.ethz.ch |
    >> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
    >> Ott Toomet | Sent: Wednesday, August 31, 2005 12:54 PM |
    >> To: r-help at stat.math.ethz.ch | Subject: [R] "best" c++
    >> matrix library?
    >> | 
    >> | Hi folks,
    >> | 
    >> | 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?
    >> | 
    >> | All suggestions welcome!
    >> | 
    >> | Best, | Ott
    >> 
    >> 
    Romain> Hello,

    Romain> CPPLAPACK : <http://cpplapack.sourceforge.net/> is a
    Romain> c++ wrapper for lapack routines.  It is not so
    Romain> complicated to use once you have blas and lapack
    Romain> installed.  I think it is much faster than newmat.

LAPACK is ``state of the art'' of numerical algebra.
Don't use anything else if you don't have to.

It's definitely *much* more ``compatible with R''
since we base almost all our matrix computations on LAPACK.
GNU octave and commercial Matlab are also entirely based on
LAPACK for the matrix computations.

I have no idea about the "CPP" (= c++) part in CPPLAPACK though.

The CRAN package 'Matrix' has several objectives, notably
*sparse* matrix computations.  But it also uses LAPACK for dense
matric computations, AFAIR also for a few things not available
(via LAPACK) in "core R".

Martin Maechler, ETH Zurich




More information about the R-help mailing list