Similar approach,  essentially,  to Ric’s,  using a table of indices of the 
ones:

   ix =: $#:I.@,
   ix map
0 0
0 3
1 1
1 2
   ({&m@:{."1)ix map
aabb
   ({&m@:{."1,. {&n@:{:"1)ix map
aA
aD
bB
bC

Somehow, though, I think you’re after something more elegant.

Sorry, the display is probably poor as typing from iPad.

Cheers,

Mike

Sent from my iPad

> On 21 Sep 2021, at 10:53, Ric Sherlock <[email protected]> wrote:
> 
> Some variation on this?
> 
>   |:(m,:n) {~"1 |: 4$.$. map
> aA
> aD
> bB
> bC
> 
> 
> 
> 
>> On Tue, 21 Sep 2021, 21:37 bill lam, <[email protected]> wrote:
>> 
>> Say I have a boolean matrix
>>   ] map=. 3 4 $ 1 0 0 1 0 1 1 0 0 0 0 0
>> 1 0 0 1
>> 0 1 1 0
>> 0 0 0 0
>> 
>> and 2 vectors of dimension equal to the 2 sides of the matrix
>>   m=. 'abc' [ n=. 'ABCD'
>> I want a cross product for those 1 in the matrix, with result like this
>>   _2 ]\ 'aAaDbBbC'
>> aA
>> aD
>> bB
>> bC
>> 
>> Is it possible to do it without explicit loops? The dimension of the matrix
>> can be very large so that generating all cross products then eliminating is
>> not an option.
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>> 
> ----------------------------------------------------------------------
> 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