<div dir="ltr"><div><div>Along those lines, yes, but you have to be careful of even/odd dimension lengths. Would be nice if it was some sort of stride trick so that I don't have to allocate a new array twice as we do in the concatenation steps.<br><br></div>Cheers!<br><br></div>Ben Root<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 29, 2016 at 1:58 PM, Joseph Fox-Rabinovitz <span dir="ltr"><<a href="mailto:jfoxrabinovitz@gmail.com" target="_blank">jfoxrabinovitz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Mar 29, 2016 at 1:46 PM, Benjamin Root <<a href="mailto:ben.v.root@gmail.com">ben.v.root@gmail.com</a>> wrote:<br>
> Is there a quick-n-easy way to reflect a NxM array that represents a<br>
> quadrant into a 2Nx2M array? Essentially, I am trying to reduce the size of<br>
> an expensive calculation by taking advantage of the fact that the first part<br>
> of the calculation is just computing gaussian weights, which is radially<br>
> symmetric.<br>
><br>
> It doesn't seem like np.tile() could support this (yet?). Maybe we could<br>
> allow negative repetitions to mean "reflected"? But I was hoping there was<br>
> some existing function or stride trick that could accomplish what I am<br>
> trying.<br>
><br>
> x = np.linspace(-5, 5, 20)<br>
> y = np.linspace(-5, 5, 24)<br>
> z = np.hypot(x[None, :], y[:, None])<br>
> zz = np.hypot(x[None, :int(len(x)//2)], y[:int(len(y)//2), None])<br>
> zz = some_mirroring_trick(zz)<br>
<br>
</span>Are you looking for something like this:<br>
<br>
zz = np.hypot.outer(y[:len(y)//2], x[:len(x)//2])<br>
zz = np.concatenate((zz[:, ::-1], zz), axis=1)<br>
zz = np.concatenate((zz, zz[::-1, :]))<br>
<span class=""><br>
> assert np.all(z == zz)<br>
><br>
> What can be my "some_mirroring_trick()"? I am hoping for something a little<br>
> better than using hstack()/vstack().<br>
><br>
> Thanks,<br>
> Ben Root<br>
><br>
</span>> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
> <a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
><br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div><br></div>