malcolmw / pykonal

Travel-time calculator based on the fast-marching method solution to the Eikonal equation.
https://malcolmw.github.io/pykonal-docs/
GNU General Public License v3.0
147 stars 54 forks source link

Simplify trace_ray, remove heap mallocs #27

Closed jobh closed 1 year ago

jobh commented 1 year ago

First, thanks for a very nice and usable library.

In my effort to understand the trace_ray algorithm, I rewrote it a bit to remove explicit heap allocations. In my opinion, the result is a bit simpler, so it might be worthwhile to merge.

Briefly, the ray std::vector now stores coordinates rather than pointers to coordinate triples. A memoryview is used to alias the active/last point in ray.

It is probably a bit faster. I think there is also a slight difference in behaviour in that the endpoint itself is checked for NaN value, whereas before only the first step was checked.

malcolmw commented 1 year ago

Thanks for your contributions @jobh, and I am glad you find the package useful! I am merging this for testing now.