I am not sure about efficiency issues. How large of a data set are you working on? What kind of bottleneck are you encountering?
That said, here's a tacit re-expression of your specification: extend=: [ +/~ 0 * ] start=: extend +.&, extend~ offsets=: 0-@,,&$ or_inf=: offsets ([: +./ |.!.0"0 1)^:_ start a or_inf b 0 1 1 0 1 1 1 1 1 1 1 1 I hope this helps, -- Raul On Wed, Jun 17, 2020 at 12:40 PM Hauke Rehr <[email protected]> wrote: > > I have two binary patterns, e. g. > a =. 0 1 0 [ b =. 0 0 1 0 0 > with a <&$ b > > Here is a simple way to get what I want: > > a2 =. (a *&$ b) $ a [ b2 =. (a *&$ b) $ b > NB. I need the whole (a *&$ b) patterns > NB. for a and b are of relatively prime $s > or1 =. a2 +. b2 > > with my example patterns that’s: > a2: 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 > b2: 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 > or1: 0 1 1 0 1 0 0 1 0 0 1 0 1 1 0 > > the first (a <. b) entries are fixed now > > I want to +. or1 with itself shifted > both ($a) and ($b) items, like this > > or2 =. +./ or1 |.!.0"0 1~ - 0, ($ a), $ b > resulting in > 0 1 1 0 1 1 1 1 0 1 1 0 1 1 0 > > Now I repeat > or3 =. +./ or2 |.!.0"0 1~ - 0, ($ a), $ b > 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 > > this obviously won’t change anymore, > I repeat until convergence. > This will eventually be ^:_ so I call this > or_inf =. or3 > > Now at each place p with p > a >.&$ b, > (p { or_inf) = (p-$a) +.&({&or_inf) p-$b > > That’s what I wanted to get. > > How to find the resulting bit pattern > (called or_inf here) effitiently when > the $s of a and b get large? > > > -- > ---------------------- > mail written using NEO > neo-layout.org > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
