That's an interesting question.

Here's an intermediate result:

   sdata i."1(1)
1 │ 2
2 │ 1
3 │ 1
4 │ 0

For that matter:
   sdata
1 2 │ 1
2 1 │ 1
3 1 │ 1
3 2 │ 1
4 0 │ 1

In other words, since the array is sparse, the first row does not really
"exist" - it's just the default value. In other words, you'd be getting a
dense result rather than a sparse result, to have the "this value does not
show up" behavior from i. work for you here.

Sparse matrices are quirky and limited (and, perhaps, a bit "lazy")..

-- 
Raul


On Fri, Sep 26, 2014 at 8:30 AM, Ben Gorte - CITG <[email protected]>
wrote:

> Good afternoon,
>
> I was finding a bug in my program that finally boiled down to this:
>
>    ]data =: #: i.5        NB. some test data
> 0 0 0
> 0 0 1
> 0 1 0
> 0 1 1
> 1 0 0
>    sdata =: $.data     NB. now sparse
>
>    data i."1 (1)
> 3 2 1 1 0
>
>    0$. sdata i."1 (1)
> 0 2 1 1 0
>
> Shouldn't these be the same?
>
> Thanks for any advice,
>
> Ben
> ----------------------------------------------------------------------
> 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