[R] matrix.csr %*% matrix --> matrix

Sam Steingold sds at gnu.org
Wed Nov 7 16:05:36 CET 2012


> * Martin Maechler <znrpuyre at fgng.zngu.rgum.pu> [2012-11-07 10:10:51 +0100]:
>
>>>>>> "Sam" == Sam Steingold <sds at gnu.org>
>>>>>>     on Tue, 6 Nov 2012 13:08:30 -0500 writes:
>
>     Sam> The question is even more pressing for me now given that I no longer can
>     Sam> convert some csr matrices to the regular ones for scaling.
>     Sam> (http://article.gmane.org/gmane.comp.lang.r.general:279305)
>     Sam> Any suggestions? (the original csr matrix is too large to be converted
>     Sam> to a regular one, but the product is small enough).
>
>     >> * Sam Steingold <fqf at tah.bet> [2012-08-27 14:58:47 -0400]:
>     >> 
>     >> When a sparse matrix is multiplied by a regular one, the result is
>     >> usually not sparse. However, when matrix.csr is multiplied by a regular
>     >> matrix in R, a matrix.csr is produced.
>     >> Is there a way to avoid this?
>     >> Thanks!
>
> Why don't you use the sparse matrix classes from the Matrix
> package .. which is part of every R distribution ?
> "SparseM" has been written as very first package to support
> sparse matrices, and is to be applauded for that,
> but it does lack many features nowadays (and also uses less
> modern algorithm for e.g. the sparse Cholesky decomposition).

Thank you very much for your advice.

I do not think I use SparseM directly.
I use e1071::read.matrix.csr and e1071::write.matrix.csr which use SparseM.
I.e., I need to be able to do i/o on files which are palatable to
libsvm/liblinear, specifically, read/write files like
--8<---------------cut here---------------start------------->8---
1.2 2:3.5 6:5.1
2 4:6.7
8 7:6.6
--8<---------------cut here---------------end--------------->8---

As you can see from my other messages
(e.g., http://article.gmane.org/gmane.comp.lang.r.general:279387),
I am not happy with my current setup.
I would be delighted to learn that there is an alternative, but so far
the only matrix i/o I could find is Matrix::readHB and it does not
handle the libsvm/liblinear format.

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://openvotingconsortium.org http://truepeace.org
http://palestinefacts.org http://camera.org http://www.memritv.org
Heck is a place for people who don't believe in gosh.




More information about the R-help mailing list