[GRASS-dev] Add GMP library to GRASS

Росен Матев r.matev at gmail.com
Sat Aug 9 17:02:54 EDT 2008

Hi all,

As I was writing the new v.buffer module, I came along some problems
connected to the inacurate floating point maths. To be more specific,
I needed to rewrite Vect_segment_intersection(), so that it behaved
correctly all the time. At first, I thought that incorporating a
"tolerance" feature in Vect_segment_intersection() (in order to avoid
doing exact fp comparisons) will solve the problems. However, it
turned out that there is no way to set a correct tolerance, even if it
is calculated dynamically from input. Vect_segment_intersection() kept
reporting inexisting intersections or missed existing ones. That is a
problem for correct topology extraction in some inputs. So I decided I
should use the multi-precision library http://gmplib.org/ . At first,
v.parallel ran 30 times slower with the correct
Vect_segment_intersection() than with the existing one. After some
optimizations I managed to make it ~4 times slower than the original.
This, however, doesn't mean that the correct
Vect_segment_intersection() is 4 times slower than the original (I
haven't done separate benchmarks). (Also have in mind that v.buffer is
currently suboptimal in the place where I use
Briefly, my v.buffer/v.parallel module doesn't work correctly on some
inputs with the original Vect_segment_intersection(). With GMP
everything is just fine and just a bit slower.
I hope everyone agrees that we need library like GMP in GRASS. I'm
willing to rewrite the parts of the code which generate most of the
inaccuracies and thus avoid all that cleaning, snapping, pruning, etc.

Rosen Matev

More information about the grass-dev mailing list