search for: dgcmatrix

Displaying 20 results from an estimated 92 matches for "dgcmatrix".

2012 Dec 11
1
Dispatching on a dgCMatrix does not work.
I represent a graph as an adjacency matrix of class "dgCMatrix" (from the Matrix package). > xx 5 x 5 sparse Matrix of class "dgCMatrix" a b c d e a . 1 1 . . b 1 . 1 . . c 1 1 . 1 1 d . . 1 . 1 e . . 1 1 . To check if the matrix defines and undirected graph, I have made the following functions/methods: is.UG <- function (object) {...
2012 Jul 28
1
Creating sparse matrix of type "dgCMatrix" directly
I want to create a sparse matrix of type "dgCMatrix" using the Matrix package (and the matrix must be of this type even if other more compact representations may exist). I do > library(Matrix) > m1<-Matrix(rep(1,4),nrow=2,ncol=2,sparse=T) > m1 2 x 2 sparse Matrix of class "dsCMatrix" [1,] 1 1 [2,] 1 1 To convert...
2009 Jul 20
1
S4 method dispatch with inheritance
Hi, I'm trying to create a new S4 class (myMatrix) which for now just extends dgCMatrix (from package Matrix). Then I want to use "[" which is defined in Matrix. Out of the box with "[" (defined in Matrix) I lose the class information and the result is an object of class dgCMatrix. If I specify a "["-method for myMatrix, it is not used because a signa...
2006 Jul 09
1
package:Matrix handling of data with identical indices
...s.integer(c(0,0,1,1,4)), j = as.integer(c(0,1,2,2,4)), x = as.double(1:5), Dim = as.integer(c(5,5)))) ## 5 x 5 sparse Matrix of class "dgTMatrix" ## [1,] 1 2 . . . ## [2,] . . 7 . . <--- 7 = 3 + 4. ## [3,] . . . . . ## [4,] . . . . . ## [5,] . . . . 5 # If instead I make a dgCMatrix-class matrix, the first # instance is overwritten by the second, e.g., library(Matrix) (Mc <- new("dgCMatrix", i = as.integer(c(0,0,1,1,4)), p = as.integer(c(0,1,2,4,5)), x = as.double(1:5), Dim = as.integer(c(5,5)))) ## 5 x 5 sparse Matrix of class "dgCMatrix"...
2006 Jul 09
1
package:Matrix handling of data with identical indices
...s.integer(c(0,0,1,1,4)), j = as.integer(c(0,1,2,2,4)), x = as.double(1:5), Dim = as.integer(c(5,5)))) ## 5 x 5 sparse Matrix of class "dgTMatrix" ## [1,] 1 2 . . . ## [2,] . . 7 . . <--- 7 = 3 + 4. ## [3,] . . . . . ## [4,] . . . . . ## [5,] . . . . 5 # If instead I make a dgCMatrix-class matrix, the first # instance is overwritten by the second, e.g., library(Matrix) (Mc <- new("dgCMatrix", i = as.integer(c(0,0,1,1,4)), p = as.integer(c(0,1,2,4,5)), x = as.double(1:5), Dim = as.integer(c(5,5)))) ## 5 x 5 sparse Matrix of class "dgCMatrix"...
2012 Oct 09
1
converting dgCMatrix to regular matrix
Hi: I've looked around and I must be missing it because it's probably somewhere. Does someone know how to convert an object of class dgCmatrix to a regular matrix. I can send someone the data if they need it but it's too big to include here. I read the data in using temp<-readMat("movielens.mat") where readMat is from the R.matlab package. But the resulting 2 matrices are S4 object of class dgCmatrix with 6 slots sho...
2017 Oct 20
3
What exactly is an dgCMatrix-class. There are so many attributes.
Dear R list, I came across dgCMatrix. I believe this class is associated with sparse matrix. I see there are 8 attributes to train$data, I am confused why are there so many, some are vectors, what do they do? Here's the R code: library(xgboost) data(agaricus.train, package='xgboost') data(agaricus.test, package='xgb...
2011 Aug 23
0
Matrix:::qr.qy and signature(qr = "sparseQR", y = "dgCMatrix")
...zed residuals and need the diagonal elements of the hat matrix. I tried to adjust function hat() in the "stats" package for use with sparse matrices. But the method qr.qy does not seem to have a function available for the following signature: signature(qr = "sparseQR", y = "dgCMatrix") - although it indicates that it understands this signature. Following is a minimal example (in my application dd2 is too large for my memory): library(Matrix) data(KNex); mm <- KNex$mm mmQR <- qr(mm) dim(mmQR) # 1850 712 class(mmQR) # [1] "sparseQR";attr(,"packa...
2017 Oct 20
0
What exactly is an dgCMatrix-class. There are so many attributes.
Subsetting using [] vs. head(), gives different results. R code: > head(train$data, 5) [1] 0 0 1 0 0 > train$data[1:5, 1:5] 5 x 5 sparse Matrix of class "dgCMatrix" cap-shape=bell cap-shape=conical cap-shape=convex [1,] . . 1 [2,] . . 1 [3,] 1 . . [4,] . . 1 [5,]...
2017 Oct 20
0
What exactly is an dgCMatrix-class. There are so many attributes.
> On Oct 20, 2017, at 11:11 AM, C W <tmrsg11 at gmail.com> wrote: > > Dear R list, > > I came across dgCMatrix. I believe this class is associated with sparse > matrix. Yes. See: help('dgCMatrix-class', pack=Matrix) If Martin Maechler happens to respond to this you should listen to him rather than anything I write. Much of what the Matrix package does appears to be magical to one such as I....
2017 Oct 20
4
What exactly is an dgCMatrix-class. There are so many attributes.
Thank you for your responses. I guess I don't feel alone. I don't find the documentation go into any detail. I also find it surprising that, > object.size(train$data) 1730904 bytes > object.size(as.matrix(train$data)) 6575016 bytes the dgCMatrix actually takes less memory, though it *looks* like the opposite. Cheers! On Fri, Oct 20, 2017 at 3:22 PM, David Winsemius <dwinsemius at comcast.net> wrote: > > > On Oct 20, 2017, at 11:11 AM, C W <tmrsg11 at gmail.com> wrote: > > > > Dear R list, > > >...
2017 Oct 21
1
What exactly is an dgCMatrix-class. There are so many attributes.
...ss I don't feel >> alone. I don't find the documentation go into any detail. > >> I also find it surprising that, > >>> object.size(train$data) >> 1730904 bytes > >>> object.size(as.matrix(train$data)) >> 6575016 bytes > >> the dgCMatrix actually takes less memory, though it >> *looks* like the opposite. > > to whom? > > The whole idea of these sparse matrix classes in the 'Matrix' > package (and everywhere else in applied math, CS, ...) is that > 1. they need much less memory and > 2. matrix...
2017 Oct 21
0
What exactly is an dgCMatrix-class. There are so many attributes.
...ur responses. I guess I don't feel > alone. I don't find the documentation go into any detail. > I also find it surprising that, >> object.size(train$data) > 1730904 bytes >> object.size(as.matrix(train$data)) > 6575016 bytes > the dgCMatrix actually takes less memory, though it > *looks* like the opposite. to whom? The whole idea of these sparse matrix classes in the 'Matrix' package (and everywhere else in applied math, CS, ...) is that 1. they need much less memory and 2. matrix arithmetic with them can be much f...
2016 Apr 19
2
Matrix: How create a _row-oriented_ sparse Matrix (=dgRMatrix)?
...in using it for holding my sparse row-oriented data and doing basic subsetting by rows (even using drop=FALSE). Here is what I get when I set up a column-oriented sparse Matrix: > Cc <- Matrix(0, nrow=5, ncol=5, sparse=TRUE) > Cc[1:3,1] <- 1 > Cc 5 x 5 sparse Matrix of class "dgCMatrix" [1,] 1 . . . . [2,] 1 . . . . [3,] 1 . . . . [4,] . . . . . [5,] . . . . . > str(Cc) Formal class 'dgCMatrix' [package "Matrix"] with 6 slots ..@ i : int [1:3] 0 1 2 ..@ p : int [1:6] 0 3 3 3 3 3 ..@ Dim : int [1:2] 5 5 ..@ Dimnames:List of 2 .....
2015 Mar 20
0
RFC: Matrix package: Matrix products (%*%, crossprod, tcrossprod) involving "nsparseMatrix" aka sparse pattern matrices
Hi Martin, package arules heavily relies on ngCMatrix and uses multiplication and addition for logical operations. I think it makes sense that in a mixed operation with one dgCMatrix and one ngCMatrix the ngCMatrix should be "promoted" to a dgCMatrix. The current behavior of %*% and friends is in deed confusing: > m <- matrix(sample(c(0,1), 5*5, replace=TRUE), nrow=5) > x <- as(m, "dgCMatrix") > y <- as(m, "ngCMatrix") >...
2008 Jan 30
1
R package Matrix failing to build with R-devel on Ubuntu AMD64
.... I am using Ubuntu Gusty AMD64 OS. Tail of install output and sessionInfo follows. Mark Loading required package: methods Loading required package: lattice Attaching package: 'Matrix' The following object(s) are masked from package:stats : xtabs Error in new("dgCMatrix") : trying to generate an object from a virtual class ("dgCMatrix") Calls: <Anonymous> ... eval.parent -> eval -> eval -> eval -> eval -> new -> .Call Execution halted ERROR: installing package indices failed ** Removing '/home/mkimpel/R_HOME/site-libr...
2016 Apr 20
0
Matrix: How create a _row-oriented_ sparse Matrix (=dgRMatrix)?
...he `[<-` method very few times (as above). Also using Matrix() is nice when being introduced to using the Matrix package. However, for efficience in non-small cases, do use sparseMatrix() directly to construct sparse matrices. >> Cc > 5 x 5 sparse Matrix of class "dgCMatrix" > [1,] 1 . . . . > [2,] 1 . . . . > [3,] 1 . . . . > [4,] . . . . . > [5,] . . . . . >> str(Cc) > Formal class 'dgCMatrix' [package "Matrix"] with 6 slots > ..@ i : int [1:3] 0 1 2 > ..@ p : int [...
2015 Mar 19
6
RFC: Matrix package: Matrix products (%*%, crossprod, tcrossprod) involving "nsparseMatrix" aka sparse pattern matrices
This is a Request For Comment, also BCCed to 390 package maintainers of reverse dependencies of the Matrix package. Most users and package authors working with our 'Matrix' package will be using it for numerical computations, and so will be using "dMatrix" (d : double precision) matrix objects M, and indirectly, e.g., for M >= c will also use "lMatrix" (l:
2012 Aug 31
1
using apply with sparse matrix from package Matrix
...the error: Error in asMethod(object) : Cholmod error 'problem too large' at file ../Core/cholmod_dense.c, line 106 Is there a way to apply a function to all the rows without bumping into this problem? Here is a simplified example: > dim(sm) [1] 72913 43052 > class(sm) [1] "dgCMatrix" attr(,"package") [1] "Matrix" > str(sm) Formal class 'dgCMatrix' [package "Matrix"] with 6 slots ..@ i : int [1:6590004] 789 801 802 1231 1236 11739 17817 17943 18148 18676 ... ..@ p : int [1:43053] 0 147 303 450 596 751 908 1053 1188...
2018 Apr 23
4
R 3.5.0 fails its regression test suite on Linux/x86_64
...oc = lib.loc, character.only = TRUE, logical.return = TRUE, : | < there is no package called 'Matrix' | --- | > Trying some Matrix objects, too | > | > Matrix> Matrix(0, 3, 2) # 3 by 2 matrix of zeros -> sparse | > 3 x 2 sparse Matrix of class "dgCMatrix" | > | > [1,] . . | > [2,] . . | > [3,] . . | > | > Matrix> Matrix(0, 3, 2, sparse=FALSE)# -> 'dense' | > 3 x 2 Matrix of class "dgeMatrix" | > [,1] [,2] | > [1,] 0 0 | > [2,] 0 0 | > [3,] 0 0 | > |...