<div dir="ltr">Hi Adam and Jakub,<div><br></div><div>Thanks a lot for the reply. I have indeed seen scipy.ndimage.convolve and have mentioned it in the <a href="https://stackoverflow.com/questions/51794274/convolution-of-numpy-arrays-of-arbitrary-dimension-for-cauchy-product-of-multiva" target="_blank">OP</a>. but some questions:</div><div><br></div><div><ol><li>although there is nothing about the dimension limit of the ndarrays in <a href="https://docs.scipy.org/doc/scipy-0.16.1/reference/generated/scipy.ndimage.filters.convolve.html" target="_blank">its official page</a>, but I haven't seen any examples showing it works with higher dimensions.</li><li>what is the difference between astropy.convolve_fft and scipy.signal.convolve? It seems to me they are for <a href="https://en.wikipedia.org/wiki/Convolution" target="_blank">function analysis</a> not array arithmetics. </li><li>As I can see the term convolution, even for array arithmetics is used for different purposes. For example there is also scipy.ndimage.filters.convolve which apparently calculates different things. My final goal is to do finite multivariate formal power series multiplication (Cauchy product). I think I have figured the formula out <a href="https://math.stackexchange.com/questions/2877478/cauchy-product-of-multivariate-formal-power-series" target="_blank">here</a>, but I'm not sure if it is correct completely. questions are:</li><ol><li>is my formula correct? </li><ul><li>if not what is the correct one?<br></li></ul><li>if yes has this been done before?<br></li><ul><li>if yes where? does any of the above functions do the job?<br></li></ul><li>regardless of the correctness of the formula and existence of other implementations, is my implementation correct so far?</li><li>how to finish the final step to populate the ndarray using the conv function? </li></ol></ol><div>Thanks a gain and looking forwards to hearing back.</div></div><div><br></div><div>Best,</div><div>Foad</div><br><div class="gmail_quote"><div dir="ltr">On Sat, Aug 11, 2018 at 1:56 AM Adam Ginsburg <<a href="mailto:adam.g.ginsburg@gmail.com">adam.g.ginsburg@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 10, 2018 at 5:51 PM, Jacob Vanderplas <span dir="ltr"><<a href="mailto:jakevdp@cs.washington.edu" target="_blank">jakevdp@cs.washington.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Foad,<div>I'm sorry if I'm misunderstanding something, but does <font face="monospace, monospace">scipy.ndimage.convolve</font> not address your use case? It implements N-dimensional convolution:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><pre style="color:rgb(0,0,0);text-decoration-style:initial;text-decoration-color:initial;background:rgb(255,255,255)"><pre style="text-decoration-style:initial;text-decoration-color:initial;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><pre style="text-decoration-style:initial;text-decoration-color:initial;background:rgb(255,255,255)"><span style="color:rgb(128,0,0);font-weight:bold">from</span> scipy<span style="color:rgb(128,128,48)">.</span>ndimage <span style="color:rgb(128,0,0);font-weight:bold">import</span> convolve
<span style="color:rgb(128,0,0);font-weight:bold">import</span> numpy <span style="color:rgb(128,0,0);font-weight:bold">as</span> np

x <span style="color:rgb(128,128,48)">=</span> np<span style="color:rgb(128,128,48)">.</span>random<span style="color:rgb(128,128,48)">.</span>rand<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(0,140,0)">10</span><span style="color:rgb(128,128,48)">,</span> <span style="color:rgb(0,140,0)">10</span><span style="color:rgb(128,128,48)">,</span> <span style="color:rgb(0,140,0)">10</span><span style="color:rgb(128,128,48)">,</span> <span style="color:rgb(0,140,0)">10</span><span style="color:rgb(128,128,48)">)</span>
w <span style="color:rgb(128,128,48)">=</span> np<span style="color:rgb(128,128,48)">.</span>ones<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">(</span><span style="color:rgb(0,140,0)">3</span><span style="color:rgb(128,128,48)">,</span> <span style="color:rgb(0,140,0)">3</span><span style="color:rgb(128,128,48)">,</span> <span style="color:rgb(0,140,0)">3</span><span style="color:rgb(128,128,48)">,</span> <span style="color:rgb(0,140,0)">3</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,128,48)">)</span>

result <span style="color:rgb(128,128,48)">=</span> convolve<span style="color:rgb(128,128,48)">(</span>x<span style="color:rgb(128,128,48)">,</span> w<span style="color:rgb(128,128,48)">)</span></pre></pre></pre></blockquote></div></blockquote><div>For completeness, astropy's convolve_fft supports this same operation since it's doing an nd fft under the hood, but the direct convolution (astropy.convolution.convolve) does not, since we had to hard-code the direct convolution operations in each dimension and so far there has been no demand for an n-dimensional convolution with n>3.</div></div><div class="gmail-m_4303587398696360019gmail_signature"><div dir="ltr"><div><div dir="ltr"></div></div></div></div>
</div></div>
_______________________________________________<br>
AstroPy mailing list<br>
<a href="mailto:AstroPy@python.org" target="_blank">AstroPy@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/astropy" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/astropy</a><br>
</blockquote></div></div>