FWIW, I compared my suggestion (based on I. on the ravel) with Igor’s on a 3000x4000 Boolean, with about 3% ones. Igor’s was far better, in space and time.
Might be different given a different starting point, such as a sparse matrix, or index array, either/both of which Bill says he’s using. Cheers, Mike Sent from my iPad > On 23 Sep 2021, at 03:32, bill lam <[email protected]> wrote: > > Thank you all for solutions. > > I hadn't mentioned, for my need, map is either a sparse boolean matrix, or > in some cases, encoded using it's dimensions and a vector I.,map > > >> On Wed, Sep 22, 2021, 7:55 AM Igor Zhuravlov <[email protected]> wrote: >> >> acp=: 1 : '; (<"0 x) ,"0 L: 0 m <@#"1 y' >> 'abc' map acp 'ABCD' >> aA >> aD >> bB >> bC >> >> -- >> Regards >> Igor >> >> >>> On Tue, 21 Sep 2021, 19: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
