timholy/Grid.jl — pull request #38 by timholy (2014-07-23 17:38:44+00:00)
Title: WIP: metaprogramming-based interpolation

OK, here's a prototype of the kind of thing I had in mind with #36. You can test by checking out the cartesian branch and then, from the `test/` directory saying
```
julia> include("newinterp.jl")
BCnil
elapsed time: 0.832196552 seconds (16 bytes allocated)
elapsed time: 0.212113778 seconds (16 bytes allocated)
elapsed time: 1.359122945 seconds (16 bytes allocated)
elapsed time: 0.422922048 seconds (16 bytes allocated)
BCnan
elapsed time: 0.902566273 seconds (16 bytes allocated)
elapsed time: 0.248787426 seconds (16 bytes allocated)
elapsed time: 1.421108665 seconds (16 bytes allocated)
elapsed time: 0.461047829 seconds (16 bytes allocated)
BCna
elapsed time: 1.070271096 seconds (16 bytes allocated)
elapsed time: 0.197870166 seconds (16 bytes allocated)
elapsed time: 1.362531069 seconds (16 bytes allocated)
elapsed time: 0.334651534 seconds (16 bytes allocated)
BCperiodic
elapsed time: 1.345538871 seconds (16 bytes allocated)
elapsed time: 0.435039454 seconds (16 bytes allocated)
elapsed time: 2.308907927 seconds (16 bytes allocated)
elapsed time: 0.728555211 seconds (16 bytes allocated)
BCnearest
elapsed time: 0.812522817 seconds (16 bytes allocated)
elapsed time: 0.187141129 seconds (16 bytes allocated)
elapsed time: 1.222788721 seconds (16 bytes allocated)
elapsed time: 0.359194482 seconds (16 bytes allocated)
```
In each case, old is on top and new is on the bottom. The first pair is for 1d, the second for 2d.

The improvement is not as large as I expected, but it's still substantial. Bounds-checking takes more time than the actual computation, at least in 1 & 2 dimensions. (You can profile to see that.)

I didn't implement all the boundary conditions, but only because I'm out of time for working on this further. I don't foresee any obstacles, though.