Re: Using Fourier and InverseFourier instead of Convolve

*To*: mathgroup at smc.vnet.net*Subject*: [mg85986] Re: Using Fourier and InverseFourier instead of Convolve*From*: "Dana DeLouis" <dana.del at gmail.com>*Date*: Fri, 29 Feb 2008 06:28:12 -0500 (EST)

> dims[[1]]dims[[2]]-dims[[1]]+1)^((dims[[1]]-1)/2)....etc Hi. This does pretty much the same as your code, but uses a different FourierParameters. LC[v_List] := Module[{r, c, m, signal}, signal = FourierParameters -> {1, -1}; {r, c} = Dimensions[v]; m = PadRight[v, {r, r*c - r + 1}]; m = Map[Chop[Fourier[#, signal]] &, m]; m = Times @@ m; m = Chop[InverseFourier[m, signal]]; If[MatrixQ[v, IntegerQ], Round[m], m] ] /; ArrayDepth[v] == 2 v = {{1, 2}, {3, 4}, {5, 6}}; LC[v] {15, 68, 100, 48} Fold[ListConvolve[#1, #2, {1, -1}, 0] &, First[v], Rest[v]] {15, 68, 100, 48} -- HTH :>) Dana DeLouis "Solomon, Joshua" <J.A.Solomon at city.ac.uk> wrote in message news:fq5qp3$l0s$1 at smc.vnet.net... > First, let me thank all who responded to my query! > Second, no, Daniel, your code works fine for me. > Finally, FWIW here is code that does what I really wanted, which was to > quickly convolve a long list of lists (each having the same length). > Possibly not the most elegant code ever, but it works, as I said, FWIW: > > cv[listOfLists_]:=With[{dims=Dimensions[listOfLists]}, > (dims[[1]]dims[[2]]-dims[[1]]+1)^((dims[[1]]-1)/2) > InverseFourier[Times[##]]&@@( > Fourier[PadRight[#,dims[[1]]dims[[2]]-dims[[1]]+1] > ]&/@listOfLists)] > <snip>