Re: Problem: a matrix and a box...
- To: mathgroup at smc.vnet.net
- Subject: [mg27269] Re: Problem: a matrix and a box...
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sun, 18 Feb 2001 02:52:06 -0500 (EST)
- References: <96lcto$gt4@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Bed, Two suggestions: M = {{a1,a2,a3,a4},{b1,b2,b3,b4},{c1,c2,c3,c4}} {{a1,a2,a3,a4},{b1,b2,b3,b4},{c1,c2,c3,c4}}; Drop[M, 1,1]+Drop[M,1,-1]+Drop[M,-1,1]+Drop[M,-1,-1] {{a1+a2+b1+b2,a2+a3+b2+b3,a3+a4+b3+b4}, {b1+b2+c1+c2,b2+b3+c2+c3,b3+b4+c3+c4}} ListConvolve[{{1,1},{1,1}}, M] {{a1+a2+b1+b2,a2+a3+b2+b3,a3+a4+b3+b4}, {b1+b2+c1+c2,b2+b3+c2+c3,b3+b4+c3+c4}} -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Bedrosian Baol" <Bedrosian at MailAndNews.com> wrote in message news:96lcto$gt4 at smc.vnet.net... > Hi > this is the problem: I have a n x m matrix (with n and m ~3000 elements or > more) > > a1 a2 a3.. > b1 b2 b3.. > c1 c2 c3.. > . . . > . . . > > the algorythm is: compute the summ of the the a1, a2, b1 and b2 elements (a > ''gliding box'' 2x2), shifing the ''box'' for 1 column and repeat the sum of > the elements (now a2, a3, b2, b3), and so on... > at the and of the first line, the box return on the second line and > repeat... > > the final resuls would be another matrix like this: > > [a1+a2+b1+b2] [a2+a3+b2+b3]... > [b1+b2+c1+c2] [b2+b3+c2+c3]... > ... > > I'm not very experienced with Math4: there is a simple and easy way for > reach > the result? > > thanks > Bed > >