<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Hi Foad</div><div> </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"><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></blockquote><div><br></div><div>I saw that, but you seemed to imply there that it was limited to 1 and 2 dimensions, when it works for arbitrary dimensions.</div><div> </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"><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></ol></div></div></blockquote><div>I showed an example of a simple four-dimensional convolution in my original response.</div><div> </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"><div><ol><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></ol></div></div></blockquote><div>By design, scipy.signal.convolve and scipy.signal.fftconvolve produce the same results. The difference is that the latter uses an FFT to compute the results, which is generally faster than direct convolution for large inputs. astropy.convolve_fft is similar to scipy.signal.fftconvolve, with a few differences listed<a href="http://docs.astropy.org/en/stable/api/astropy.convolution.convolve_fft.html"> in the documentation</a>.<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"><div><ol><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.<wbr>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></div></blockquote><div>At a glance, I'm not certain if your formula or implementation is correct, and I don't have the time to dig-in at the moment.</div><div><br></div><div>Perhaps someone else can help with that part.</div><div><br></div><div>Best of luck,</div><div>   Jake</div><div> </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"><div><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><div class="gmail-h5"><div dir="ltr">On Sat, Aug 11, 2018 at 1:56 AM Adam Ginsburg <<a href="mailto:adam.g.ginsburg@gmail.com" target="_blank">adam.g.ginsburg@gmail.com</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-h5"><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_-2042190378414187278gmail-m_4303587398696360019gmail_signature"><div dir="ltr"><div><div dir="ltr"></div></div></div></div>
</div></div></div></div><span class="gmail-">
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/astropy</a><br>
</span></blockquote></div></div>
<br>______________________________<wbr>_________________<br>
AstroPy mailing list<br>
<a href="mailto:AstroPy@python.org">AstroPy@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/astropy" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/astropy</a><br>
<br></blockquote></div><br></div></div>