2008/5/18, Roger Hui <[EMAIL PROTECTED]>:
> Why do you have to start with a non-sparse matrix?

Please consider the sales example I posted here earlier. I can
calculate the indexes and the sum of sales for (area, model) pair,
like how I did in my script.  Using those two vectors(indexes,
values), I want to get a sparse matrix, for its space and
time-efficiency for furthur analysis.

> 1$.s;a;e  builds a blank sparse matrix with the "full shape" s .
>

Thanks. Now I can amend the blank sparse matrix with indexes and values vectors.

>
>
> ----- 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
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to