Thank you Mr Boss and Ambrus. \. is just what I need, and I shall be using it hard and often! It's my quick positive answers lucky day. Thank you so much.
Regards Graham > -----Original Message----- > From: [email protected] [mailto:programming- > [email protected]] On Behalf Of [email protected] > Sent: 03 March 2010 13:36 > To: [email protected] > Subject: Programming Digest, Vol 54, Issue 6 > > Send Programming mailing list submissions to > [email protected] > > To subscribe or unsubscribe via the World Wide Web, visit > http://jsoftware.com/cgi-bin/mailman/listinfo/programming > or, via email, send a message with subject or body 'help' to > [email protected] > > You can reach the person managing the list at > [email protected] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Programming digest..." > > > Today's Topics: > > 1. Re: convolution (R.E. Boss) > 2. Re: convolution (Zsb?n Ambrus) > 3. Re: convolution (R.E. Boss) > 4. Re: convolution (R.E. Boss) > 5. Efficiency of u/@:|.\ (Graham Parkhouse) > 6. Re: Efficiency of u/@:|.\ (R.E. Boss) > 7. Re: Efficiency of u/@:|.\ (Zsb?n Ambrus) > 8. Re: Efficiency of u/@:|.\ (R.E. Boss) > 9. Re: convolution (Aai) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 3 Mar 2010 08:21:07 +0100 > From: "R.E. Boss" <[email protected]> > Subject: Re: [Jprogramming] convolution > To: "'Programming forum'" <[email protected]> > Message-ID: <[email protected]@planet.nl> > Content-Type: text/plain; charset="US-ASCII" > > If I use the code in http://rosettacode.org/wiki/Deconvolution/1D#J I > get > > g divide f > _8.9987079 _9.79829 _2.8177029 _2.2688657 > > g divide h > _2.4248816 _6.0369603 _1.6137776 7.3469275 _5.1888632 4.2435677 > _1.4563227 > _10.321829 _10.177195 5.4978906 _0.34950258 3.7744154 0.26877438 > _3.8080763 > > > ,.f;g;h > +------------------------------------------------------------+ > |_3 _6 _1 8 _6 3 _1 _9 _9 3 _2 5 2 _2 _7 _1 | > +------------------------------------------------------------+ > |24 75 71 _34 3 22 _45 23 245 25 52 25 _67 _96 96 31 55 36 29| > +------------------------------------------------------------+ > |_8 _9 _3 _1 _6 7 | > +------------------------------------------------------------+ > Ai=: (i...@] =/ i...@[ -/ i.@>:@-)&# > divide=: [ +/ .*~ [:%.&.x: ] +/ .* Ai > > > R.E. Boss > > > > -----Oorspronkelijk bericht----- > > Van: [email protected] [mailto:programming- > > [email protected]] Namens Raul Miller > > Verzonden: dinsdag 2 maart 2010 22:49 > > Aan: Programming forum > > Onderwerp: [Jprogramming] convolution > > > > We can use /. for convolution (+//.@(*/)) of one dimensional > > arrays, but do we have anything that simple for higher > > dimensional arrays? > > > > See also: > > http://rosettacode.org/wiki/Deconvolution/2D%2B > > > > Thanks, > > > > -- > > Raul > > --------------------------------------------------------------------- > - > > For information about J forums see > http://www.jsoftware.com/forums.htm > > > > ------------------------------ > > Message: 2 > Date: Wed, 3 Mar 2010 10:40:59 +0100 > From: Zsb?n Ambrus <[email protected]> > Subject: Re: [Jprogramming] convolution > To: Programming forum <[email protected]> > Message-ID: > <[email protected]> > Content-Type: text/plain; charset=ISO-8859-1 > > On Wed, Mar 3, 2010 at 12:03 AM, Zsb?n Ambrus <[email protected]> > wrote: > > Sure, two dimensional convolution is nothing more complicated than > > just one dimensional, so you can do it with two obliques and throwing > > in a couple of ranks and/or transposes. ?The following is probably > not > > the most elegant way, but it works. > > > > ? ]a =: 10 0 ,: 0 1 > > 10 0 > > ?0 1 > > ? ] b=: 2 2 ,: 1 0 > > 2 2 > > 1 0 > > ? +//. |:"2 +//."3 (|:a) */ b > > 20 10 0 > > 20 ?2 1 > > ?0 ?2 0 > > Right, I knew I was tired last knight. With a clearer head today I get > this: > > +//."2 +//. 1 3 |: a */ b > 20 20 0 > 10 2 2 > 0 1 0 > +//."2 +//. a */"1"1 2 b > 20 20 0 > 10 2 2 > 0 1 0 > > where you might recognize the phrase (|: a */ b) or the equivalent (a > */"1"1 2 b) from the recent mailing list thread about Kronecker > product of matrices. > > Ambrus > > > ------------------------------ > > Message: 3 > Date: Wed, 3 Mar 2010 11:16:09 +0100 > From: "R.E. Boss" <[email protected]> > Subject: Re: [Jprogramming] convolution > To: "'Programming forum'" <[email protected]> > Message-ID: <[email protected]@planet.nl> > Content-Type: text/plain; charset="iso-8859-1" > > 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 > > > > ------------------------------ > > Message: 4 > Date: Wed, 3 Mar 2010 11:18:50 +0100 > From: "R.E. Boss" <[email protected]> > Subject: Re: [Jprogramming] convolution > To: "'Programming forum'" <[email protected]> > Message-ID: <[email protected]@planet.nl> > Content-Type: text/plain; charset="US-ASCII" > > Notice that the definition(s) of convolution was wrong, but is > corrected in > the mean time. > > > R.E. Boss > > > > -----Oorspronkelijk bericht----- > > Van: [email protected] [mailto:programming- > > [email protected]] Namens Raul Miller > > Verzonden: dinsdag 2 maart 2010 22:49 > > Aan: Programming forum > > Onderwerp: [Jprogramming] convolution > > > > We can use /. for convolution (+//.@(*/)) of one dimensional > > arrays, but do we have anything that simple for higher > > dimensional arrays? > > > > See also: > > http://rosettacode.org/wiki/Deconvolution/2D%2B > > > > Thanks, > > > > -- > > Raul > > --------------------------------------------------------------------- > - > > For information about J forums see > http://www.jsoftware.com/forums.htm > > > > ------------------------------ > > Message: 5 > Date: Wed, 3 Mar 2010 10:39:10 -0000 > From: "Graham Parkhouse" <[email protected]> > Subject: [Jprogramming] Efficiency of u/@:|.\ > To: <[email protected]> > Message-ID: <005f01cababd$c9d51250$5d7f36...@[email protected]> > Content-Type: text/plain; charset="us-ascii" > > I have a matrix S of n vectors, s0, s1, s2 etc and a verb u with which > I can > build a matrix T of n vectors, t0, t1, t2 etc by the following > procedure: > > t0=: s0 > t1=: s1 u t0 > t2=: s2 u t1 etc > > T=: u/@:|.\S will do it, but will the interpreter recognize the > quick way > of doing u/@:|.\ (for any verb u)? > > The problem I have described is very common in engineering. I've always > used > a loop before and am now aiming for something tidier. But will it be > efficient? > > Regards > > Graham > > > > > ------------------------------ > > Message: 6 > Date: Wed, 3 Mar 2010 13:26:23 +0100 > From: "R.E. Boss" <[email protected]> > Subject: Re: [Jprogramming] Efficiency of u/@:|.\ > To: "'Programming forum'" <[email protected]> > Message-ID: <[email protected]@planet.nl> > Content-Type: text/plain; charset="US-ASCII" > > u/\.&|.s is probably more efficient. > > s=:i.1000 2 > > ts'plus/@:|.\ s' > 0.42737873 38976 > > ts'plus/\.&.|. s' > 0.00062138806 18496 > > > R.E. Boss > > > -----Oorspronkelijk bericht----- > > Van: [email protected] [mailto:programming- > > [email protected]] Namens Graham Parkhouse > > Verzonden: woensdag 3 maart 2010 11:39 > > Aan: [email protected] > > Onderwerp: [Jprogramming] Efficiency of u/@:|.\ > > > > I have a matrix S of n vectors, s0, s1, s2 etc and a verb u with > which I > > can > > build a matrix T of n vectors, t0, t1, t2 etc by the following > procedure: > > > > t0=: s0 > > t1=: s1 u t0 > > t2=: s2 u t1 etc > > > > T=: u/@:|.\S will do it, but will the interpreter recognize the > quick > > way > > of doing u/@:|.\ (for any verb u)? > > > > The problem I have described is very common in engineering. I've > always > > used > > a loop before and am now aiming for something tidier. But will it be > > efficient? > > > > Regards > > > > Graham > > > > > > --------------------------------------------------------------------- > - > > For information about J forums see > http://www.jsoftware.com/forums.htm > > > > ------------------------------ > > Message: 7 > Date: Wed, 3 Mar 2010 13:27:51 +0100 > From: Zsb?n Ambrus <[email protected]> > Subject: Re: [Jprogramming] Efficiency of u/@:|.\ > To: Programming forum <[email protected]> > Message-ID: > <[email protected]> > Content-Type: text/plain; charset=ISO-8859-1 > > On Wed, Mar 3, 2010 at 11:39 AM, Graham Parkhouse > <[email protected]> wrote: > > T=: u/@:|.\S ? ?will do it, but will the interpreter recognize the > quick way > > of doing u/@:|.\ (for any verb u)? > > Wow, it took quite some time for me to parse this. I brought this up > recently in the other mailing list, and the answer is that the > interpreter already knows how to execute (u/\.) fast, which you can > use to make an equivalent of what you need. Let's see an example. > > p =: '(',')',~[,'*',] > trace =: (3 :('1!:2&5''.''';'y'))@: > p trace/@:|.\ 'abcdefg' > .....................a > (b*a) > (c*(b*a)) > (d*(c*(b*a))) > (e*(d*(c*(b*a)))) > (f*(e*(d*(c*(b*a))))) > (g*(f*(e*(d*(c*(b*a)))))) > p trace/\.&.|. 'abcdefg' > .......a > (b*a) > (c*(b*a)) > (d*(c*(b*a))) > (e*(d*(c*(b*a)))) > (f*(e*(d*(c*(b*a))))) > (g*(f*(e*(d*(c*(b*a)))))) > > You can see that the second phrase computes the same as the first, but > it calls the verb p fewer times. > > Ambrus > > > ------------------------------ > > Message: 8 > Date: Wed, 3 Mar 2010 13:30:09 +0100 > From: "R.E. Boss" <[email protected]> > Subject: Re: [Jprogramming] Efficiency of u/@:|.\ > To: "'Programming forum'" <[email protected]> > Message-ID: <[email protected]@planet.nl> > Content-Type: text/plain; charset="US-ASCII" > > Missing was > > plus=:+ > > (plus/@:|.\ s)-:plus/\.&.|. s > 1 > > > R.E. Boss > > > > -----Oorspronkelijk bericht----- > > Van: [email protected] [mailto:programming- > > [email protected]] Namens R.E. Boss > > Verzonden: woensdag 3 maart 2010 13:26 > > Aan: 'Programming forum' > > Onderwerp: Re: [Jprogramming] Efficiency of u/@:|.\ > > > > u/\.&|.s is probably more efficient. > > > > s=:i.1000 2 > > > > ts'plus/@:|.\ s' > > 0.42737873 38976 > > > > ts'plus/\.&.|. s' > > 0.00062138806 18496 > > > > > > R.E. Boss > > > > > -----Oorspronkelijk bericht----- > > > Van: [email protected] [mailto:programming- > > > [email protected]] Namens Graham Parkhouse > > > Verzonden: woensdag 3 maart 2010 11:39 > > > Aan: [email protected] > > > Onderwerp: [Jprogramming] Efficiency of u/@:|.\ > > > > > > I have a matrix S of n vectors, s0, s1, s2 etc and a verb u with > which I > > > can > > > build a matrix T of n vectors, t0, t1, t2 etc by the following > > procedure: > > > > > > t0=: s0 > > > t1=: s1 u t0 > > > t2=: s2 u t1 etc > > > > > > T=: u/@:|.\S will do it, but will the interpreter recognize the > quick > > > way > > > of doing u/@:|.\ (for any verb u)? > > > > > > The problem I have described is very common in engineering. I've > always > > > used > > > a loop before and am now aiming for something tidier. But will it > be > > > efficient? > > > > > > Regards > > > > > > Graham > > > > > > > > > ------------------------------------------------------------------- > --- > > > For information about J forums see > http://www.jsoftware.com/forums.htm > > > > --------------------------------------------------------------------- > - > > For information about J forums see > http://www.jsoftware.com/forums.htm > > > > ------------------------------ > > Message: 9 > Date: Wed, 03 Mar 2010 14:35:12 +0100 > From: Aai <[email protected]> > Subject: Re: [Jprogramming] convolution > To: Programming forum <[email protected]> > Message-ID: <[email protected]> > Content-Type: text/plain; charset=ISO-8859-1 > > Not a general solution, but the 3 convolutions can be computed as > follows. > > pp=: +//.@(*/) NB. 1D > > ppp=: +//.@(pp"1/) NB. 2D > > pppp=: +//.@(ppp"2/) NB. 3D > > > 1D > h (conv-:pp) f > 1 > > 2D > h (conv-:ppp) f > 1 > > 3D > h (conv-:pppp) h > 1 > > > > -- > Met vriendelijke groet, > =@@i > > > > ------------------------------ > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > > End of Programming Digest, Vol 54, Issue 6 > ****************************************** ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
