Help: Generalized convolution using ListConvolve
- To: mathgroup at smc.vnet.net
- Subject: [mg47296] Help: Generalized convolution using ListConvolve
- From: kzhang at flashmail.com (Kezhao Zhang)
- Date: Fri, 2 Apr 2004 03:31:48 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
I tried to use ListConvolve to calculate the convolution of a 2x2x3x3 tensor and a 2x2x3 tensor. The kernel (2x2x3x3 tensor) is a 2x2 array of 3x3 matrices. The list is a 2x2 array of vectors of length 3. The operation between the element in the kernel and the element in the list is Dot product between a matrix and a vector. I used the general form of ListConvolve: ListConvolve[kernel, lst, {1, 1}, {}, Dot, Plus, 2] and expected the output to be a 2x2 array of vectors of length 3. But only one element of the output array is vector and the rest are matrices. Could someone please help me find out what went wrong. Thanks for your help. The sample code is listed below. K. Zhang --------------- In[1]:=kernel Out[1]={{{{-0.333333, 0, 0}, {0, -0.333333, 0}, {0, 0, -0.333333}}, {{-0.0675086, 0, 0}, {0, 0.135017, 0}, {0, 0, -0.0675086}}}, {{{0.135017, 0, 0}, {0, -0.0675086, 0}, { 0, 0, -0.0675086}}, {{0.0137858, 0.0530667, -0.0170824}, {0.0530667, \ 0.0137858, 0}, {-0.0170824, 0, -0.0275715}}}} In[2]:=lst=Table[{1,0,0},{2},{2}] Out[2]={{{1, 0, 0}, {1, 0, 0}}, {{1, 0, 0}, {1, 0, 0}}} In[3]:=ListConvolve[kernel, lst, {1, 1}, {}, Dot, Plus, 2] Out[3]={{{{-0.252039, -0.280267, -0.350416}, {0.0530667, 0.0812944, 0.}, {-0.0170824, 0., -0.162589}}, {{-0.252039, -0.347775, \ -0.417924}, {0.0530667, -0.0537228, 0.}, {-0.0170824, 0., -0.0950801}}}, {{{-0.252039, -0.145249, \ -0.215399}, {0.0530667, 0.148803, 0.}, {-0.0170824, 0., -0.0950801}}, \ {-0.252039, 0.0530667, -0.0170824}}}