[R] Memory Efficiency of Symmetric Matrix

Martin Maechler maechler at stat.math.ethz.ch
Wed Jan 7 09:45:25 CET 2009


>>>>> "NSW" == Nathan S Watson-Haigh <nathan.watson-haigh at csiro.au>
>>>>>     on Wed, 7 Jan 2009 12:45:50 +1000 writes:

    NSW> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

    NSW> andrew wrote:
    >> the SparseM package might be what you are looking for
    >> 
    >> http://www.econ.uiuc.edu/~roger/research/sparse/SparseM.pdf
    >> 
    >> On Jan 7, 11:36 am, Søren Højsgaard
    >> <Soren.Hojsga... at agrsci.dk> wrote:
    >>> You can do mat[lower.tri(mat, diag=F)] Søren
    >>> 

    NSW> Thanks, although my matrices are dense and not
    NSW> sparse. I have however, found the Matrix package:

    NSW> http://cran.r-project.org/web/packages/Matrix/index.html

    NSW> The dspMatrix class, seems like what I might want:
    NSW> dspMatrix - Symmetric real matrices in packed storage
    NSW> (one triangle only)

    NSW> I'm just trying to test it out with my usual 24k x 24k
    NSW> size matrices.

Good;  I was just about to propose using  'Matrix'.
Note that 'Matrix' is a 'Recommended' package in "R-devel" aka
"R 2.9.0 Under development (unstable).

As a co-maintainer of the package, I'm biased of course, but
also extremely interested in feedback / questions from users
like you, about missing features, unclear documentation,
possible bugs, ...

Regards,
Martin Maechler, ETH Zurich

    >>> ________________________________
    >>> 
    >>> Fra: r-help-boun... at r-project.org på vegne af Nathan
    >>> S. Watson-Haigh Sendt: on 07-01-2009 01:28 Til:
    >>> r-h... at r-project.org Emne: [R] Memory Efficiency of
    >>> Symmetric Matrix
    >>> 
    >> I'm generating a symmetric correlation matrix using a
    >> data matrix as input: mat <- cor(data.mat)
    >> 
    >> My question is: Is there a more memory efficient way to
    >> store this data? For instance, since: all(mat == t(mat))
    >> every value is duplicated, and I should be able to almost
    >> half the memory usage for large matrices.
    >> 
    >> Any thoughts/comments?
    >> 
    >> Cheers, Nathan
    >> 
    NSW> - -- -
    NSW> --------------------------------------------------------
    NSW> Dr. Nathan S. Watson-Haigh OCE Post Doctoral Fellow
    NSW> CSIRO Livestock Industries Queensland Bioscience
    NSW> Precinct St Lucia, QLD 4067 Australia

    NSW> Tel: +61 (0)7 3214 2922 Fax: +61 (0)7 3214 2900 Web:
    NSW> http://www.csiro.au/people/Nathan.Watson-Haigh.html -
    NSW> --------------------------------------------------------




More information about the R-help mailing list