scipy/scipy — pull request #503 by juliantaylor (2013-04-08 20:10:46+00:00)
Title: Ni interpolation performance improvements

performance improvements for ndimage interpolation.
Gain is about 5-10% with the default order and I think the code gets a bit clearer.

In both NI_GeometricTransform and NI_ZoomShift have two inner loops which can be merged removing some unnecessary looping operations and the need for the idxs temporary variable.
Also I moved the switch statement out of the inner loop as due to the many unrestricted pointers the (gcc) compiler is not can't do it (unlike the non pointer order conditional in the loop below).

Then I also added branch prediction hints which improve performance for larger 2d (or higher) images on a core2duo and a amd phenom X2.
The number of edge points mostly always be much than the regular pixels on dimensions > 1.
You could certainly produce cases in which the hint is wrong, so I'm open to drop that commit.

I also ran the skimage testsuite successfully which uses these functions a bit more.
very simple benchmark:

```
Nx, Ny = 500, 1703
numpy.random.seed(23)
d = scipy.rand(Ny*Nx)
d.shape = Ny, Nx
ind = numpy.indices(d.shape, numpy.float64)
ind -= 1.7
%timeit -n 20 ndimage.map_coordinates(d, ind)
%timeit -n 20 ndimage.shift(d, 0.5)
```