Skip to content
Prev 301585 / 398503 Next

Creating sparse matrix of type "dgCMatrix" directly

-----Original Message-----
From: dmbates at gmail.com [mailto:dmbates at gmail.com] On Behalf Of Douglas Bates
Sent: 28. juli 2012 20:36
To: S?ren H?jsgaard
Cc: r-help at r-project.org
Subject: Re: [R] Creating sparse matrix of type "dgCMatrix" directly
On Sat, Jul 28, 2012 at 7:26 AM, S?ren H?jsgaard <sorenh at math.aau.dk> wrote:
The Matrix function is a high-level function that is designed to produce a compact and informative representation of its arguments.
That's why it checks for symmetry, triangularity, etc.

To decide how to bypass these checks it would be useful to know what you are starting with.  Will it be a dense matrix or a triplet representation or ...?

[>>] Dear Doug,
[>>] I use sparse matrices to represent graphs so the matrices contain zeros and non-zeros (in most cases ones). I need the matrices to be of the dgCMatrix type because these matrices can be used as sparse matrices in the RcppEigen package. For now I have created my own dgCMatrix() function doing what I've sketched above, but there is - as you also indicate - an overhead in the checks in the Matrix() function, and also an overhead in using as().
Regards
S?ren