similar to: Matrix*vector: coercing sparse to dense matrix for arithmetic

Displaying 20 results from an estimated 4000 matches similar to: "Matrix*vector: coercing sparse to dense matrix for arithmetic"

2006 Dec 19
1
preserving sparse matrices (Matrix)
Hi, I have sparse (tridiagonal) matrices, and I use the Matrix package for handling them. For certain computations, I need to either set the first row to zero, or double the last row. I find that neither operation preserves sparsity, eg > m <- Diagonal(5) > m 5 x 5 diagonal matrix of class "ddiMatrix" [,1] [,2] [,3] [,4] [,5] [1,] 1 . . . . [2,] . 1
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 m1, I do > as(m1, "dgCMatrix")
2009 Jan 20
1
Creating a Sparse Matrix from a Sparse Vector
Hello, I am working with a sparse matrix that is approx. 13,900 by 14,100. My goal is to select a row out of the matrix and create a new matrix with that row repeated 13,900 times without having to do any looping. Example: Starting Matrix: exampleMatrix 3 x 4 sparse Matrix of class "dgCMatrix" [1,] 1 . . . [2,] . 1 . 0.5 [3,] . . 1 .. New Matrix:.. newExampleMatrix 3 x 4 sparse
2016 Apr 19
2
Matrix: How create a _row-oriented_ sparse Matrix (=dgRMatrix)?
Using the Matrix package, how can I create a row-oriented sparse Matrix from scratch populated with some data? By default a column-oriented one is created and I'm aware of the note that the package is optimized for column-oriented ones, but I'm only interested in using it for holding my sparse row-oriented data and doing basic subsetting by rows (even using drop=FALSE). Here is what I
2016 Apr 20
0
Matrix: How create a _row-oriented_ sparse Matrix (=dgRMatrix)?
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com> >>>>> on Tue, 19 Apr 2016 14:04:11 -0700 writes: > Using the Matrix package, how can I create a row-oriented sparse > Matrix from scratch populated with some data? By default a > column-oriented one is created and I'm aware of the note that the > package is optimized for
2009 Oct 22
0
dgTMatrix --- [, , drop=F] strange behavior, Matrix 0.999375-20
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I have something strange here... I want to subset a large sparse matrix, with the subset being still in sparse form. Easily achievable with mm[i,,drop=F] , right? Well, it doesn't work on the matrix I'm working on. This is a very large wikipedia Matrix (now I can play with it as I just got 16Gb of memory): > mm at Dim [1] 793251
2011 Mar 31
1
rank of Matrix
Dear list, Can anyone tell me how to obtain the rank of a sparse Matrix, for example from package Matrix (class dgCMatrix)? Here is an example of QR decomposition of a sparse matrix (from the sparseQR class help). library(Matrix) data(KNex) mm <- KNex$mm str(mmQR <- qr(mm)) Similarly, using the functions/classes from the relatively new MatrixModels package: library(MatrixModels)
2012 Aug 31
1
using apply with sparse matrix from package Matrix
Hi: I was trying to use apply on a sparse matrix from package Matrix, and I get 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"
2009 May 13
2
Optimization algorithm to be applied to S4 classes - specifically sparse matrices
Hello. I am trying to optimize a set of parameters using /optim/ in which the actual function to be minimized contains matrix multiplication and is of the form: SUM ((A%*%X - B)^2) where A is a matrix and X and B are vectors, with X as parameter vector. This has worked well so far. Recently, I was given a data set A of size 360440 x 1173, which could not be handled as a normal matrix. I
2017 Oct 21
1
What exactly is an dgCMatrix-class. There are so many attributes.
> On Oct 21, 2017, at 7:50 AM, Martin Maechler <maechler at stat.math.ethz.ch> wrote: > >>>>>> C W <tmrsg11 at gmail.com> >>>>>> on Fri, 20 Oct 2017 15:51:16 -0400 writes: > >> 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
2017 Oct 21
0
What exactly is an dgCMatrix-class. There are so many attributes.
>>>>> C W <tmrsg11 at gmail.com> >>>>> on Fri, 20 Oct 2017 15:51:16 -0400 writes: > 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 >>
2008 Jun 17
0
Quickly reading data into the Matrix packages sparse formats
I have data set that I wish to solve with the Matrix package's sparse matrix functionality. The speed improvements that it has achieved are amazing, with my dense matrix solutions never taking really long enough to time in what I've been able to time so far. However, before I can solve my full linear model, I need to be able to read in all the data, and therein lies the rub.
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) >
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
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) { UseMethod("is.UG") }
2018 Apr 23
4
R 3.5.0 fails its regression test suite on Linux/x86_64
Hi, I just tried to upgrade Nixpkgs to R 3.5.0, but unfortunately the new version fails its regression test suite. We configure the build using the flags "--without-recommended-packages", in case that's relevant. You can see a complete build log with all relevant information at [1]. Anyway, the test failures look like this: | make[3]: Entering directory
2011 Aug 23
0
Matrix:::qr.qy and signature(qr = "sparseQR", y = "dgCMatrix")
> sessionInfo() R version 2.13.1 (2011-07-08) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Matrix_0.999375-50 lattice_0.19-30 loaded via a namespace (and not attached): [1] grid_2.13.1
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 signature
2018 Feb 27
2
scale.default gives an incorrect error message when is.numeric() fails on a sparse row matrix (dgeMatrix)
I am attempting to use the lars package with a sparse input feature matrix, but the following fails: library(Matrix) library(lars) data(diabetes) attach(diabetes) x = as(as.matrix(as.data.frame(x)), 'dgCMatrix') lars(x, y, intercept = FALSE) Error in scale.default(x, FALSE, normx) : > > length of 'scale' must equal the number of columns of 'x' > > More
2011 Oct 06
0
linear classifiers with sparse matrices
I've been trying to get some linear classifiers (LiblineaR, kernlab, e1071) to work with a sparse matrix of feature data. In the case of LiblineaR and kernlab, it seems I have to coerce my data into a dense matrix in order to train a model. I've done a number of searches, read through the manuals and vignettes, but I can't seem to see how to use either of these packages with sparse