timholy / Grid.jl

Interpolation and related operations on grids
MIT License
47 stars 26 forks source link

Subarrays as second argument #62

Closed matthieugomez closed 9 years ago

matthieugomez commented 9 years ago

From a matrix A

A = rand(10, 10)

I can interpolate with respect to the first dimension

 CoordInterpGrid(1:10, A[:, 1], BCnearest, InterpLinear)

However, I can't interpolate with respect to the second dimension, i.e. do something like

 CoordInterpGrid(1:10, A[1, :], BCnearest, InterpLinear)
 CoordInterpGrid(1:10, slice(A, 1, :), BCnearest, InterpLinear)

The only solution is to transpose A so that the order of dimensions is inverted. However, adding a support for subarray would probably be faster, no?

timholy commented 9 years ago

Even faster would be to use Interpolations :smile:. Your timing is impeccable; I just pushed the new README, with benchmarks, a few minutes ago.

Interpolations already supports SubArrays (or should).

matthieugomez commented 9 years ago

It's even better - you implemented lookup wrt some dimension. Exactly what I was looking for.

matthieugomez commented 9 years ago

:v: