[R] Symmetric Matrix classes

Martin Maechler maechler at stat.math.ethz.ch
Tue Jan 19 16:26:31 CET 2010


Scanning for 'Matrix' in old R-help e-mail, I found

>>>>> "GA" == Gad Abraham <gabraham at csse.unimelb.edu.au>
>>>>>     on Fri, 27 Nov 2009 13:45:00 +1100 writes:

    GA> Hi,
    GA> I'd like to store large covariance matrices using Matrix classes.

    GA> dsyMatrix seems like the right one, but I want to specify just the
    GA> upper/lower triangle and diagonal and not have to instantiate a huge
    GA> n^2 vector just for the sake of having half of it ignored:

    GA> Dumb example:
    GA> M <- new("dsyMatrix", uplo="U", x=rnorm(1e4), Dim=as.integer(c(100, 100)))
    GA> diag(M) <- 1

    GA> This doesn't work:
    GA> M <- new("dsyMatrix", uplo="U", x=0, Dim=as.integer(c(100, 100)))
    GA> Error in validObject(.Object) :
    GA> invalid class "dsyMatrix" object: length of x slot != prod(Dim)

    GA> Is there an easier way of doing this?

I think you want a  "dspMatrix"  ("sp" == "symmetric packed")
instead.

Before going into details: Is this topic still interesting to
those involved almost two months ago?

Regards,
Martin

    GA> -- 
    GA> Gad Abraham
    GA> PhD Student, Dept. CSSE and NICTA
    GA> The University of Melbourne
    GA> Parkville 3010, Victoria, Australia
    GA> email: gabraham at csse.unimelb.edu.au
    GA> web: http://www.csse.unimelb.edu.au/~gabraham



More information about the R-help mailing list