Re: ListCorrelate
- To: mathgroup at smc.vnet.net
- Subject: [mg37530] Re: [mg37522] ListCorrelate
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Sun, 3 Nov 2002 02:59:02 -0500 (EST)
- References: <200211020831.DAA04059@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Mike wrote:
>
> I think it is probably possible to use ListCorrelate in the following way:
>
> ListCorrelate[{(j-1)*X, Y,(j+1)*Z},{a,b,c,d,....}]
>
> Where j changes as they move along the row. The change reflects the position
> or part of the element they are operating on. For example initially j =2
> then 3, 4...and the output would be
>
> {(2-1)*X*a+Y*b+(2+1)*Z*c,(3-1)*X*b+Y*c+(3+1)*Z*d, ...}
>
> I've tried to replace Times in ListCorrelate with a function that will do
> this but had no success. If I can get this simple example to work I will
> take this and Map a Matrix onto it:
>
> ListCorrelate[{(j-1)*X, Y,(j+1)*Z},#]&/@ list
>
> This will be part of a larger function which I've written alternatively
> using MapThread and Map but I think it should work a lot faster if I can
> incorporate ListCorrelate.
>
> Thanks
>
> Mike
One approach might be to start with the list correlation result obtained
with j fixed. I will illustrate using a list of 7 elements.
j = 2;
ll = Array[aa,7];
kernel = {(j-1)*X,Y,(j+1)*Z};
l1 = ListCorrelate[kernel, ll];
Now do the list correlate with kernel {1,0,1}:
l2 = ListCorrelate[{X,0,Z}, ll];
We want to add sequential multiples of this to l1. The multiplier is
just the list {0,1,2,...}.
l3 = Range[0,Length[l2]-1];
result = Expand[l1+l2*l3]
Out[24]= {X aa[1] + Y aa[2] + 3 Z aa[3], 2 X aa[2] + Y aa[3] + 4 Z
aa[4],
3 X aa[3] + Y aa[4] + 5 Z aa[5], 4 X aa[4] + Y aa[5] + 6 Z aa[6],
5 X aa[5] + Y aa[6] + 7 Z aa[7]}
Daniel Lichtblau
Wolfram Research
- References:
- ListCorrelate
- From: Mike <mikeh1980@optusnet.com.au>
- ListCorrelate