MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Discrete Convolution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19019] Re: Discrete Convolution
  • From: dtharvat at brain.uccs.edu (Dave Harvatin)
  • Date: Tue, 3 Aug 1999 13:44:52 -0400
  • Organization: University of Colorado at Boulder
  • References: <7nrddv$i60@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Mark,

Have a look at the HankelMatrix command in the package
LinearAlgebra`MatrixManipulation`.  You should be able to manipulate your
data so that the the convolution of list x with list y can be represented by
the dot product of a vector formed from list x with a Hankel matrix formed
from list y (or perhaps list y in reverse order).  I hope this helps.

Dave Harvatin

Alister McAlister <alisterq at psy.uwa.edu.au> wrote in message
news:7nrddv$i60 at smc.vnet.net...
> I want a function that mimics Matlab's "conv" function for doing a
discrete
> convolution of two lists.
>
>  CONV Convolution and polynomial multiplication.
>     C = CONV(A, B) convolves vectors A and B.  The resulting
>     vector is length LENGTH(A)+LENGTH(B)-1.
>     If A and B are vectors of polynomial coefficients, convolving
>     them is equivalent to multiplying the two polynomials.
>
>
> I wrote the following, but is there a way of either of
> (1) speeding up the code by changing the algorithm ...
>       ignoring simple things like the multiple evaluations
>       of Length and so forth which I have left
>       in only for what I hope is clarity; or
> (2) Using a built in function (possibly connected with polynomials) to do
> the same thing?
>
> Mark R Diamond
> No spam email: markd at psy dot uwa dot edu dot au
> --------------------------------------------------------
>
> convolve[a_List,b_List]:=Module[
>   {
>        (* reverse one of the lists prior to the convolution *)
>        ra=Reverse[a],
>
>        (* A variable that collects the indices of lists ra and b,
> respectively *)
>        (* that will be Dot[ ]-ed together. *)
>        indices
>   },
>
>   (* Create the table of indices *)
>   indices=Table[
>    {
>     {
>       Max[Length[a]+1-i,1],
>       Min[Length[a],Length[a]+Length[b]-i]
>     },
>      {
>       Max[1,i-Length[a]+1],Min[Length[b],i]
>      }
>    },
>    {i,Length[a]+Length[b]-1}
>   ];
>
>   (* Create a list of the appropriate pairs of dot products *)
>    Map[(Take[ra,#[[1]] ].Take[ b,#[[2]] ])&, indices]
>  ]  /;  (VectorQ[a,NumberQ]\[And]VectorQ[b,NumberQ])
>
>
>


  • Prev by Date: Re: Discrete Convolution
  • Next by Date: Re: Removing Graphics3D polygon edges
  • Previous by thread: Re: Discrete Convolution
  • Next by thread: Re: Discrete Convolution