--- Roger Hui <[EMAIL PROTECTED]> wrote:
> Better to just map i and j and values separately 
> (perhaps i,.j and value as two map files), and apply your
> iterative methods to these.

Or maybe three mapped files: i, j, values.
Then access to the matrix is simply relational.
See http://www.jsoftware.com/jwiki/DB/Flwor

   i.3 4              NB. matrix
0 1  2  3
4 5  6  7
8 9 10 11
   (#: i.@(*/)) 3 4   NB. index odometer
0 0
0 1
0 2
0 3
1 0
1 1
1 2
1 3
2 0
2 1
2 2
2 3
   'r c'=. |:(#: i.@(*/)) 3 4
   v=. ,@i. 3 4
   r,.c,.v            NB. relational form
0 0  0
0 1  1
0 2  2
0 3  3
1 0  4
1 1  5
1 2  6
1 3  7
2 0  8
2 1  9
2 2 10
2 3 11
   1 = r              NB. row 1 mask
0 0 0 0 1 1 1 1 0 0 0 0
   v #~ 1=r           NB. SQL: select v where r=1
4 5 6 7
   1 2 =/ r           NB. rows 1 2 mask
0 0 0 0 1 1 1 1 0 0 0 0
0 0 0 0 0 0 0 0 1 1 1 1
   v #~ 1 2 =/ r      NB. rows 1 2 value
4 5  6  7
8 9 10 11
   
   1 = c              NB. column 1 mask
0 1 0 0 0 1 0 0 0 1 0 0
   v #~ 1 = c         NB. etc ...
1 5 9

   v #~ c = 1
1 5 9
   1 3 =/ c
0 1 0 0 0 1 0 0 0 1 0 0
0 0 0 1 0 0 0 1 0 0 0 1
   v #~ 1 3 =/ c
1 5  9
3 7 11


   (t#r),.(t#c),.v#~t=. 0=4|v NB. 4 multiple
0 0 0
1 0 4
2 0 8
   
   (~.r) ,. r+//.v            NB. sum by rows
0  6
1 22
2 38
   +/"1 i.3 4
6 22 38



      
____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to