Algebraic Tools for Exact Geometric Computing I - Exact Arithmetic and Filtering Michael Hemmer School of Computer Science - University of Tel Aviv 2010, Tel Aviv Michael Hemmer Exact Arithmetic and Filtering
Outline ◮ Motivate Exact Computing ◮ Filtered Predicates ◮ Lazy Constructions ◮ CGAL Kernels Michael Hemmer Exact Arithmetic and Filtering
Outline ◮ Motivate Exact Computing ◮ Filtered Predicates ◮ Lazy Constructions ◮ CGAL Kernels ◮ leda::real and CORE::Expr Michael Hemmer Exact Arithmetic and Filtering
Talk of Kurt Mehlhorn: Classroom Examples of Robustness Problems in Geometric Computations Michael Hemmer Exact Arithmetic and Filtering
Recall Motivation Geometric algorithms are a mix of ◮ Numerical computation (Point coordinates, distances, ...) ◮ Combinatorial techniques (Convex hull, Delaunay Triangulation, ...) ⇒ Small numerical errors can lead to: Inconsistencies, infinite loops, crashes ... Michael Hemmer Exact Arithmetic and Filtering
Exact Geometric-Computation Paradigm Michael Hemmer Exact Arithmetic and Filtering
Exact Geometric-Computation Paradigm Ensure correct control flow of algorithm by: ◮ Exact evaluation of geometric predicates - functions computing discrete results from numerical input - Orientation, Compare xy, ... Michael Hemmer Exact Arithmetic and Filtering
Exact Geometric-Computation Paradigm Ensure correct control flow of algorithm by: ◮ Exact evaluation of geometric predicates - functions computing discrete results from numerical input - Orientation, Compare xy, ... ◮ Enforces exactness of geometric constructions - Intersection, Projection, ... - If there are any ! [C. Yap, T. Dub´ e, 1995] Michael Hemmer Exact Arithmetic and Filtering
The Easy Solution Use exact multi-precision arithmetic ◮ integers, rational (e.g. GMP , CORE, LEDA) ◮ even algebraic numbers (e.g. CORE, LEDA) ◮ exact up to memory limit Disadvantage: TOO SLOW Michael Hemmer Exact Arithmetic and Filtering
The Easy Solution Use exact multi-precision arithmetic ◮ integers, rational (e.g. GMP , CORE, LEDA) ◮ even algebraic numbers (e.g. CORE, LEDA) ◮ exact up to memory limit Disadvantage: TOO SLOW No solution for transcendental numbers! Michael Hemmer Exact Arithmetic and Filtering
Find the Balance ! Requirements of the Real RAM model: ◮ arithmetic operations in constant time ◮ exact computation over the reals The naive solutions: ◮ constant time floating point arithmetic that fails ◮ exact multi precision arithmetic that is too slow Michael Hemmer Exact Arithmetic and Filtering
The Answer are Filters General filter scheme: ◮ try to compute a certified result fast (usually constant time) ◮ if certification fails may try another filter ◮ if nothing helps, use exact arithmetic The hope: ◮ require only constant time for easy instances ◮ amortize cost for hard cases that use exact arithmetic Michael Hemmer Exact Arithmetic and Filtering
General Idea General idea for filtered predicate: ◮ For expression E compute approximation ˜ E and bound B , such that | E − ˜ E | � B or equivalently: E ∈ I = [˜ E − B , ˜ E + B ] ◮ If 0 ∈ I report failure , else return sign (˜ E ) . Michael Hemmer Exact Arithmetic and Filtering
Recall: Floating Point Arithmetic ◮ A double float f uses 64 bits - 1 bit for the sign s - 52 bits for the mantissa m = m 1 . . . m 52 - 11 bits for the exponent e = e 1 . . . e 11 ◮ f = − 1 s · ( 1 + � 1 � i � 52 m i 2 − i ) · 2 e − 2013 , if 0 < e < 2 11 − 1 . . . ◮ for a ∈ R , let fl ( a ) be the closest float to a for a ∈ Z : | a − fl ( a ) | � ε | fl ( a ) | , where ε = 2 − 53 for o ∈ { + , − , ×} : | f 1 of 2 − f 1 ˜ of 2 | � ε | f 1 ˜ of 2 | ◮ floating point arithmetic is monotone e.g.: b � c ⇒ a ⊕ b � a ⊕ c Michael Hemmer Exact Arithmetic and Filtering
Computing B For expression E define d E and mes E recursively: ˜ E E mes E d E a , float fl ( a ) | fl ( a ) | 0 a ∈ Z fl ( a ) | fl ( a ) | 1 X ⊕ ˜ ˜ | ˜ X | ⊕ | ˜ X + Y Y Y | 1 + max ( d X , d Y ) X ⊖ ˜ ˜ | ˜ X | ⊕ | ˜ X − Y Y Y | 1 + max ( d X , d Y ) X ⊗ ˜ ˜ | ˜ X | ⊗ | ˜ X × Y Y Y | 1 + d X + d Y Then B is defined as follows: | E − ˜ E | � B = (( 1 + ε ) d E − 1 ) · mes E [K. Mehlhorn, S.N¨ aher; LEDA BOOK] Michael Hemmer Exact Arithmetic and Filtering
Proof ◮ Monotonicity of floats always guarantees: ˜ E � mes E ◮ First two rows are trivial ◮ Lets proof invariant for addition | ˜ | (˜ X ⊕ ˜ E − E | = Y ) − ( X + Y ) | Michael Hemmer Exact Arithmetic and Filtering
Proof ◮ Monotonicity of floats always guarantees: ˜ E � mes E ◮ First two rows are trivial ◮ Lets proof invariant for addition | ˜ | (˜ X ⊕ ˜ E − E | = Y ) − ( X + Y ) | | (˜ X ⊕ ˜ Y ) − (˜ X + ˜ Y ) | + | X − ˜ X | + | Y − ˜ Y | � Michael Hemmer Exact Arithmetic and Filtering
Proof ◮ Monotonicity of floats always guarantees: ˜ E � mes E ◮ First two rows are trivial ◮ Lets proof invariant for addition | ˜ | (˜ X ⊕ ˜ E − E | = Y ) − ( X + Y ) | | (˜ X ⊕ ˜ Y ) − (˜ X + ˜ Y ) | + | X − ˜ X | + | Y − ˜ Y | � ε · mes E + | X − ˜ X | + | Y − ˜ Y | � Michael Hemmer Exact Arithmetic and Filtering
Proof ◮ Monotonicity of floats always guarantees: ˜ E � mes E ◮ First two rows are trivial ◮ Lets proof invariant for addition | ˜ | (˜ X ⊕ ˜ E − E | = Y ) − ( X + Y ) | | (˜ X ⊕ ˜ Y ) − (˜ X + ˜ Y ) | + | X − ˜ X | + | Y − ˜ Y | � ε · mes E + | X − ˜ X | + | Y − ˜ Y | � ε · mes E + (( 1 + ε ) d X − 1 ) mes X + (( 1 + ε ) d Y − 1 ) mes Y � Michael Hemmer Exact Arithmetic and Filtering
Proof ◮ Monotonicity of floats always guarantees: ˜ E � mes E ◮ First two rows are trivial ◮ Lets proof invariant for addition | ˜ | (˜ X ⊕ ˜ E − E | = Y ) − ( X + Y ) | | (˜ X ⊕ ˜ Y ) − (˜ X + ˜ Y ) | + | X − ˜ X | + | Y − ˜ Y | � ε · mes E + | X − ˜ X | + | Y − ˜ Y | � ε · mes E + (( 1 + ε ) d X − 1 ) mes X + (( 1 + ε ) d Y − 1 ) mes Y � ε · mes E + (( 1 + ε ) max ( d X , d Y ) − 1 ) · mes E � Michael Hemmer Exact Arithmetic and Filtering
Proof ◮ Monotonicity of floats always guarantees: ˜ E � mes E ◮ First two rows are trivial ◮ Lets proof invariant for addition | ˜ | (˜ X ⊕ ˜ E − E | = Y ) − ( X + Y ) | | (˜ X ⊕ ˜ Y ) − (˜ X + ˜ Y ) | + | X − ˜ X | + | Y − ˜ Y | � ε · mes E + | X − ˜ X | + | Y − ˜ Y | � ε · mes E + (( 1 + ε ) d X − 1 ) mes X + (( 1 + ε ) d Y − 1 ) mes Y � ε · mes E + (( 1 + ε ) max ( d X , d Y ) − 1 ) · mes E � (( 1 + ε ) 1 + max ( d X , d Y ) − 1 ) · mes E = B � Michael Hemmer Exact Arithmetic and Filtering
Proof ◮ Monotonicity of floats always guarantees: ˜ E � mes E ◮ First two rows are trivial ◮ Lets proof invariant for addition | ˜ | (˜ X ⊕ ˜ E − E | = Y ) − ( X + Y ) | | (˜ X ⊕ ˜ Y ) − (˜ X + ˜ Y ) | + | X − ˜ X | + | Y − ˜ Y | � ε · mes E + | X − ˜ X | + | Y − ˜ Y | � ε · mes E + (( 1 + ε ) d X − 1 ) mes X + (( 1 + ε ) d Y − 1 ) mes Y � ε · mes E + (( 1 + ε ) max ( d X , d Y ) − 1 ) · mes E � (( 1 + ε ) 1 + max ( d X , d Y ) − 1 ) · mes E = B � Remark: (( 1 + ε ) 1 + d E − 1 ) � ε · ( 1 + d E ) , for d E < � 1 /ε − 1. Michael Hemmer Exact Arithmetic and Filtering
Static and Semi-Static Filter Static Filter: ◮ compute B once for all Michael Hemmer Exact Arithmetic and Filtering
Static and Semi-Static Filter Static Filter: ◮ compute B once for all ⇒ very fast Michael Hemmer Exact Arithmetic and Filtering
Static and Semi-Static Filter Static Filter: ◮ compute B once for all ⇒ very fast ◮ requires an assumption on the range of the input ◮ for many calls this assumption may be to large Michael Hemmer Exact Arithmetic and Filtering
Static and Semi-Static Filter Static Filter: ◮ compute B once for all ⇒ very fast ◮ requires an assumption on the range of the input ◮ for many calls this assumption may be to large Almost-static filter: ◮ initialize B based on optimistic assumption ◮ adjust B if necessary Michael Hemmer Exact Arithmetic and Filtering
Static and Semi-Static Filter Static Filter: ◮ compute B once for all ⇒ very fast ◮ requires an assumption on the range of the input ◮ for many calls this assumption may be to large Almost-static filter: ◮ initialize B based on optimistic assumption ◮ adjust B if necessary Semi-static Filter: ◮ compute B depending on the input of each call Michael Hemmer Exact Arithmetic and Filtering
Static and Semi-Static Filter Static Filter: ◮ compute B once for all ⇒ very fast ◮ requires an assumption on the range of the input ◮ for many calls this assumption may be to large Almost-static filter: ◮ initialize B based on optimistic assumption ◮ adjust B if necessary Semi-static Filter: ◮ compute B depending on the input of each call ◮ still fast, since it essentially only doubles the costs Michael Hemmer Exact Arithmetic and Filtering
Recommend
More recommend