The sparse linear algebra example in the dictionary page for $. shows you how it's done. http://www.jsoftware.com/help/dictionary/d211.htm#sparse%20linear%20algebra
Another example: x=: 1 $. 1e6 1e6 NB. create an empty 1e6 by 1e6 sparse matrix d=: 1e6 ?@$ 0 NB. 1e6-element dense vector x=: d (<"1 ,.~i.1e6)}x NB. amend the diagonal of x by d $x NB. shape of x 1000000 1000000 x -: |: x NB. x is symmetric 1 d -: +/x 1 d -: +/"1 x 1 On Thu, Jul 12, 2012 at 8:10 PM, Ed Gottsman <edward.j.gotts...@gmail.com>wrote: > Greetings. I'm just picking J up again after a brief 10-year hiatus and I > have a question about sparse arrays. I understand I can convert a dense > array to a sparse array so: > > sparse =. $. ? 1000000 # 3 NB. Gives me an array whose zeros are not > taking up any room. Perfect. > > But what do I do if the dense array I'm trying to "sparse" is too big to > exist as a dense array? For example: > > sparse =. $. = ? 100000000 # 1000 NB. Gives me an out of memory error. > > Now, the self-classify of this array is mostly zeros and, as a sparse > array, it wouldn't take up much space. But I can't work out how to make it > into a sparse array...as it's being created? Before it's created? Is > there a way to bind the sparse verb to the self-classify verb such that = > "pipes" directly into the sparse version of its result? > > Any insights into this would be greatly appreciated. > > Many thanks. > > Ed > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm