Hi Martin,

Unfortunately, the error is coming on the data set that I have right now. I
was successfully able to display any field in the matrix and even the whole
matrix when I tried the example code provided by you. However, it is failing
on the dataset I am working on.I can share the file with you if that helps.
Kindly let me know.

Also, please find the sessioninfo() output below:
> sessionInfo()
R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] Matrix_0.999375-30 lattice_0.17-25

loaded via a namespace (and not attached):
[1] grid_2.9.2
>


Thanks
Pallavi


On Wed, Oct 28, 2009 at 7:22 PM, Martin Maechler <maech...@stat.math.ethz.ch
> wrote:

> >>>>> "PP" == Pallavi P <pallavip...@gmail.com>
> >>>>>     on Wed, 28 Oct 2009 16:30:25 +0530 writes:
>
>    PP> Hi Martin,
>     PP> I followed your example on my set  of data. Which has non zero
> values in
>    PP> 300k positions in 22638 X 80914 sparse matrix. I am able to load
> data into a
>    PP> field and was able to do some operations (essentially  t(m) %*% m).
> However,
>    PP> when I tried to display the value in the resulted matrix. I am
> getting below
>    PP> error
>    PP> *
>    PP> Error in asMethod(object) :
>    PP> Cholmod error 'out of memory' at file:../Core/cholmod_memory.c, line
> 148*
>
>    PP> The sequence of commands I used are:
>
>    >>
> uac=read.table('C:\\personal\\code\\data\\user_album_count.csv',sep=',' ,
>     PP> header=T)
>     >> library(Matrix)
>    >> m<-sparseMatrix(i=uac[,"user"],j=uac[,"item"],x=uac[,"count"])
>    >> cm<-t(m) %*% m
>
> The above is less efficient than
>
>    cm <- crossprod(m)
>
> please use the latter {not just for sparse matrices; for all
> matrices in R !}
>
>    PP> upto this point, I was able to run, however when I tried to display
> cm[1,1],
>    PP> I got above error. Kindly let me know if there is anything wrong
> going on
>    PP> here.
>
> Interestingly, we had a recent thread on R-devel,
> which also made a point about excessive memory usage when
> accessing elements of a sparse matrix.
>
> I'd really like to investigate further;
> but can you ***PLEASE*** use reproducible code, i.e.,
> similar to the one I used, rather than reading data from one of
> your files.
>
> Note that your matrix is still fine and should be able to work
> with it, even thoug it seems the operation
>
>  a <- cm[1,1]
>
> is currently implemented very sub-optimally.
>
> I'm busy for the rest of today with other duties,
> but am looking forward to receive **reproducible** code from
> you, by tonight.
> Also, please do not forget to also show the result of
> sessionInfo() !
>
> Martin Maechler,
>
>    PP> Thanks
>    PP> Pallavi
>
>    PP> On Tue, Oct 27, 2009 at 8:34 PM, Martin Maechler <
> maech...@stat.math.ethz.ch
>     >> wrote:
>
>    >> >>>>> "PP" == Pallavi P <pallavip...@gmail.com>
>    >> >>>>>     on Tue, 27 Oct 2009 18:13:22 +0530 writes:
>    >>
>    PP> Hi Martin,
>    PP> Thanks for the help. Just to make sure I understand correctly.
>    >>
>    PP> The below steps are for creating an example table similar to the one
>    >> that I
>    PP> read from file.
>    >>
>    >> yes, exactly
>    >>
>    >> n <- 22638
>    >> m <- 80914
>    >> nnz <- 300000 # no idea if this is realistic for you
>    >>
>    >> set.seed(101)
>    >> ex <- cbind(i = sample(n,nnz, replace=TRUE),
>    >> j = sample(m,nnz, replace=TRUE),
>    >> x = round(100 * rnorm(nnz)))
>    >>
>    >>
>    PP> and I can understand the way sparseMatrix is initialized right now
>    >> as
>    >> M <- sparseMatrix(i = ex[,"i"],
>    >> j = ex[,"j"],
>    >> x = ex[,"x"])
>    >>
>    PP> How ever, I couldn't understand the use of below commands.
>    >>
>    >> MM. <- tcrossprod(M) # == MM' := M %*% t(M)
>    >> M.1 <- M %*% rep(1, ncol(M))
>    >> stopifnot(identical(drop(M.1), rowSums(M)))
>    >>
>    >> They were just for illustrative purposes,
>    >> to show how and that you can work with the created sparse matrix
>    >> 'M'.
>    >>
>    >> Regards,
>    >> Martin Maechler, ETH Zurich
>    >>
>    PP> Kindly let me know if I missed something.
>    >>
>    PP> Thanks
>    PP> Pallavi
>    >>
>    >>
>     PP> Hi Martin,<br><br>I followed your example on my set  of data. Which
> has non zero values in 300k positions in 22638 X 80914 sparse matrix. I am
> able to load data into a field and was able to do some operations
> (essentially  t(m) %*% m). However, when I tried to display the value in the
> resulted matrix. I am getting below error<br>
>    PP> <b><br>Error in asMethod(object) : <br>  Cholmod error &#39;out of
> memory&#39; at file:../Core/cholmod_memory.c, line 148</b><br><br>The
> sequence of commands I used
> are:<br><br>&gt;uac=read.table(&#39;C:\\personal\\code\\data\\user_album_count.csv&#39;,sep=&#39;,&#39;
> , header=T)<br>
>    PP>
> &gt;library(Matrix)<br>&gt;m&lt;-sparseMatrix(i=uac[,&quot;user&quot;],j=uac[,&quot;item&quot;],x=uac[,&quot;count&quot;])<br>&gt;cm&lt;-t(m)
> %*% m<br>upto this point, I was able to run, however when I tried to display
> cm[1,1], I got above error. Kindly let me know if there is anything wrong
> going on here.<br>
>    PP> <br>Thanks<br>Pallavi<br><br><div class="gmail_quote">On Tue, Oct
> 27, 2009 at 8:34 PM, Martin Maechler <span dir="ltr">&lt;<a href="mailto:
> maech...@stat.math.ethz.ch">maech...@stat.math.ethz.ch</a>&gt;</span>
> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid
> rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
>    PP> &gt;&gt;&gt;&gt;&gt; &quot;PP&quot; == Pallavi P &lt;<a
> href="mailto:pallavip...@gmail.com";>pallavip...@gmail.com</a>&gt;<br>
>    PP> &gt;&gt;&gt;&gt;&gt;     on Tue, 27 Oct 2009 18:13:22 +0530
> writes:<br>
>    PP> <br>
>    PP>    PP&gt; Hi Martin,<br>
>    PP>    PP&gt; Thanks for the help. Just to make sure I understand
> correctly.<br>
>    PP> <br>
>    PP>    PP&gt; The below steps are for creating an example table similar
> to the one that I<br>
>    PP>    PP&gt; read from file.<br>
>    PP> <br>
>    PP> yes, exactly<br>
>    PP> <div class="im"><br>
>     PP>     n &lt;- 22638<br>
>    PP>     m &lt;- 80914<br>
>     PP>     nnz &lt;- 300000 # no idea if this is realistic for you<br>
>    PP> <br>
>    PP>     set.seed(101)<br>
>     PP>     ex &lt;- cbind(i = sample(n,nnz, replace=TRUE),<br>
>    PP>     j = sample(m,nnz, replace=TRUE),<br>
>    PP>     x = round(100 * rnorm(nnz)))<br>
>    PP> <br>
>    PP> <br>
>    PP> </div>    PP&gt; and I can understand the way sparseMatrix is
> initialized right now as<br>
>    PP> <div class="im">    M &lt;- sparseMatrix(i = ex[,&quot;i&quot;],<br>
>     PP>                      j = ex[,&quot;j&quot;],<br>
>    PP>                      x = ex[,&quot;x&quot;])<br>
>     PP> <br>
>    PP> </div>    PP&gt; How ever, I couldn&#39;t understand the use of
> below commands.<br>
>    PP> <div class="im"><br>
>     PP>   MM. &lt;- tcrossprod(M) # == MM&#39; := M %*% t(M)<br>
>     PP>   M.1 &lt;- M %*% rep(1, ncol(M))<br>
>    PP>   stopifnot(identical(drop(M.1), rowSums(M)))<br>
>    PP> <br>
>    PP> </div>They were just for illustrative purposes,<br>
>    PP> to show how and that you can work with the created sparse matrix<br>
>    PP> &#39;M&#39;.<br>
>    PP> <br>
>    PP> Regards,<br>
>    PP> Martin Maechler, ETH Zurich<br>
>    PP> <br>
>    PP>    PP&gt; Kindly let me know if I missed something.<br>
>     PP> <br>
>    PP>    PP&gt; Thanks<br>
>    PP>    PP&gt; Pallavi<br>
>     PP>   <br></blockquote></div><br>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to