Benjamin Root
2016-03-29 17:46:45 UTC
Is there a quick-n-easy way to reflect a NxM array that represents a
quadrant into a 2Nx2M array? Essentially, I am trying to reduce the size of
an expensive calculation by taking advantage of the fact that the first
part of the calculation is just computing gaussian weights, which is
radially symmetric.
It doesn't seem like np.tile() could support this (yet?). Maybe we could
allow negative repetitions to mean "reflected"? But I was hoping there was
some existing function or stride trick that could accomplish what I am
trying.
x = np.linspace(-5, 5, 20)
y = np.linspace(-5, 5, 24)
z = np.hypot(x[None, :], y[:, None])
zz = np.hypot(x[None, :int(len(x)//2)], y[:int(len(y)//2), None])
zz = some_mirroring_trick(zz)
assert np.all(z == zz)
What can be my "some_mirroring_trick()"? I am hoping for something a little
better than using hstack()/vstack().
Thanks,
Ben Root
quadrant into a 2Nx2M array? Essentially, I am trying to reduce the size of
an expensive calculation by taking advantage of the fact that the first
part of the calculation is just computing gaussian weights, which is
radially symmetric.
It doesn't seem like np.tile() could support this (yet?). Maybe we could
allow negative repetitions to mean "reflected"? But I was hoping there was
some existing function or stride trick that could accomplish what I am
trying.
x = np.linspace(-5, 5, 20)
y = np.linspace(-5, 5, 24)
z = np.hypot(x[None, :], y[:, None])
zz = np.hypot(x[None, :int(len(x)//2)], y[:int(len(y)//2), None])
zz = some_mirroring_trick(zz)
assert np.all(z == zz)
What can be my "some_mirroring_trick()"? I am hoping for something a little
better than using hstack()/vstack().
Thanks,
Ben Root