You are right, obl dows not work, since other hyper planes are required for
convolution.
Here is my (general) solution:

conv=: 4 : 0
nsh=.<: +/"1 x ,.&$ y
plns=. (((],:+)i.)-:# sh) +/"2@:{&.|: (#: [:i. */) sh=.x ,&$ y
plns=. plns {~ t=./: plns
nsh $ plns +//. t{ ,x */ y
)

   g-: f conv h
1

It is also consistent with the latest result of Ambrus:

   a conv b
20 20 0
10  2 2
 0  1 0
   

R.E. Boss



> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming-
> [email protected]] Namens Raul Miller
> Verzonden: dinsdag 2 maart 2010 23:56
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] convolution
> 
> On Tue, Mar 2, 2010 at 5:22 PM, Dan Bron <[email protected]> wrote:
> > Raul wrote:
> >>  We can use /. for convolution (+//.@(*/)) of one dimensional
> >>  arrays, but do we have anything that simple for higher
> >>  dimensional arrays?
> >
> > I haven't looked into it, but would RE Boss' proposal for a different
> definition of /. (oblique) help generalize  +//.@(*/)  ?
> >
> > http://www.jsoftware.com/pipermail/programming/2006-December/004410.html
> 
> It might, but I do not see how.
> 
> Using the above definition of obl and the 2d data from that
> wiki page:
> 
> h=:".;._2]0 :0
>  _8  1 _7 _2 _9  4
>   4  5 _5  2  7 _1
>  _6 _3 _3 _6  9  5
> )
> 
> f=:".;._2]0 :0
>  _5  2 _2 _6 _7
>   9  7 _6  5 _7
>   1 _1  9  2 _7
>   5  9 _9  2 _5
>  _8  5 _2  8  5
> )
> 
> g=:".;._2]0 :0
>   40  _21  53   42  105    1  87   60   39 _28
>  _92  _64  19 _167  _71  _47 128 _109   40 _21
>   58   85 _93   37  101  _14   5   37  _76 _56
>  _90 _135  60 _125   68   53 223    4  _36 _48
>   78   16   7 _199  156 _162  29   28 _103 _10
>  _62  _89  69  _61   66  193 _61   71   _8 _30
>   48   _6  21   _9 _150  _22 _56   32   85  25
> )
> 
>    g -: f +/obl@(*/) h
> 0
>    $ f +/obl@(*/) h
> 16
> 
> Thanks,
> 
> --
> Raul
> ----------------------------------------------------------------------
> 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