Re: Discrete Convolution
- To: mathgroup at smc.vnet.net
- Subject: [mg19015] Re: Discrete Convolution
- From: Bruno Daniel <bruno.daniel at hadiko.de>
- Date: Tue, 3 Aug 1999 13:44:50 -0400
- Organization: University of Karlsruhe
- References: <7nrddv$i60@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Alister
Why not just the direct implementation?
\!\(Conv[a_List, b_List] :=
Module[\n\t\t{la = Length[a], lb = Length[b]}, \n\t\t
Table[\[Sum]\+\(i = Max[1, k - la]\)\%\(Min[lb, k - 1]\)a
\[LeftDoubleBracket]k - i\[RightDoubleBracket]
b\[LeftDoubleBracket]i\[RightDoubleBracket], {k, 2, la + lb}]]\)
or expressed in InputForm:
Conv[a_List, b_List] :=
Module[{la = Length[a], lb = Length[b]},
Table[Sum[a[[k - i]]*b[[i]],
{i, Max[1, k - la], Min[lb, k - 1]}], {k, 2, la + lb}]]
Example:
In[40]:=Conv[{a,b,c},{e,f}]
Out[40]= {a e, b e + a f, c e + b f, c f}
Yours sincerely
Bruno