Randy,

Raul was pointing out that assuming  4&$.  refers to all 1s is not enough.  
This is because in a sparse array, not every axis has
to be sparse.  Look at Roger's first two examples:

           (2;0)$.4 5$1
        0 | 1 1 1 1 1
        1 | 1 1 1 1 1
        2 | 1 1 1 1 1
        3 | 1 1 1 1 1
        
           (2;0)$.4 7$1
        0 | 1 1 1 1 1 1 1
        1 | 1 1 1 1 1 1 1
        2 | 1 1 1 1 1 1 1
        3 | 1 1 1 1 1 1 1

The  4&$.  are exactly the same, and both refer to all 1s, but the arrays are 
different.  So the "all ones" assumption is
insufficient:  you'd have to know the shape of the original array, and which 
axes were specified to be sparse.

But, if I understand you correctly, you're suggesting Roger assume   4&$.  
refers to all SCALAR 1s; i.e.,  4&$.^:_1  should
produce a two dimensional boolean array, and both axes should be sparse.  

Maybe that assumption is too restrictive to be useful, especially given that  
1&$.  already provides a more general mechanism?

In any case, Raul's post was relevant because:

RM>    #(,m)-.0 1
RM> 0

proves that the array contains only 0s and 1s, and

RM>    3 $.m
RM> 0

proves that the sparse element is zero.  So if the sparse element is 0, and the 
array only contains 0 and 1, then  4&$.  only
refers to 1s [A].  

Raul was demonstrating that even if you know that, you still can't recover  s  
: 

           test =: ('passed'"_) @: (verb define) :: ('failed'"_)
                        assert.      0  -:   #(,y)-.0 1
                        assert.     84  -:   +/,y
                        assert.    105  -:   */$y
                        assert.      0  -: 3 $. y
                        assert. (i.4 1) -: 4 $. y
           )
        
        
           m0   =.  1 (i.4) }  1 $. (5 21 ) ; (,0) ; 0 
           m1   =.  1 (i.4) }  1 $. (5 3 7) ; (,0) ; 0
        
           test m0
        passed
        
           test m1
        passed
        
           m0 -: m1
        0
 
The arrays are different (in shape), yet  4&$.  is the same, and refers to all 
1s in each case.

-Dan

[A]  Actually, these two tests don't prove that  4&$.  refers to all 1s, c.f. 
Roger's  s4  :

           s4
        0 | 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
        1 | 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
        2 | 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
        3 | 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
           

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to