Why do you have to start with a non-sparse matrix?
1$.s;a;e  builds a blank sparse matrix with the "full shape" s .



----- Original Message -----
From: June Kim <[EMAIL PROTECTED]>
Date: Saturday, May 17, 2008 19:35
Subject: [Jprogramming] Re: sparse matrix from index/value pairs
To: Programming forum <[email protected]>

> 2008/5/18, June Kim <[EMAIL PROTECTED]>:
> > Is there a more efficient way of getting sparse matrix from 
> index/value pairs?
> >
> >   s
> > 0 1 │   1
> > 0 2 │  10
> > 1 0 │   2
> > 1 3 │ 100
> >   (4&$.,.5&$.)s
> > 0 1   1
> > 0 2  10
> > 1 0   2
> > 1 3 100
> >
> > I'm thinking about some verb f that might satisfy(or something 
> similar):>
> >   s-:(4&$.,.5&$.)s
> 
> Sorry for my typo:
> 
>    s-:f (4&$.,.5&$.)s
> 
> >
> > I can do that using amend, but I have to build up a blank 
> matrix of
> 
> I mean, build a blank non-sparse matrix and amend it, and turn 
> it into
> a sparse matrix.
> 
> > the full shape in the first place. Are there more efficient 
> ways in
> > time and space-wise?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to