Assume data is an (n,9) matrix.

b=: test"1 data

b is an n-element boolean vector whose
i-th element indicates whether the i-th row
of data passed the test. You can use b#data
to extract the wanted rows of test.

Alternatively:   
i=: I. test"1 data

i is an integer vector of the indices of rows
of data that passed the test.  You can use
i{data to extract the rows.

For example:

   data=: 10000 9 ?...@$ 100
   test=: [: *./ 40 < ]  NB. all elements > 40
   b=: test"1 data
   $b
10000
   +/b
98
   5 {. b#data
63 76 45 83 60 97 75 88 89
99 51 57 69 92 57 62 53 56
90 99 52 94 70 47 98 77 95
88 68 95 70 55 56 63 53 79
90 52 62 63 54 68 99 76 61

   i=: I. test"1 data
   $i
98
   5{.i
8 304 432 591 772
   5 {. i{data
63 76 45 83 60 97 75 88 89
99 51 57 69 92 57 62 53 56
90 99 52 94 70 47 98 77 95
88 68 95 70 55 56 63 53 79
90 52 62 63 54 68 99 76 61



----- Original Message -----
From: Nicholas Spies <[email protected]>
Date: Tuesday, September 1, 2009 11:06
Subject: [Jprogramming] elementary programming question
To: [email protected]

> I have a list of candidate data, an array of some thousands of 9 
> integers each, and
> a test routine that given a 9 integer list returns a 0 or 1 
> depending on 
> whether the data is a
> miss or a hit.
> 
> How do I apply the test to the large set of data and extract the 
> few 
> cases that constitute "answers"?
> 
> This is so simple that it applies to a whole host of problem 
> sets, but I 
> haven't found a simple
> guide in the J documentation as to how this to solve the problem.
> 
> Thanks in advance, --Nick
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to