Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76568 - in sandbox/gtl: boost/polygon/detail libs/polygon/test
From: sydorchuk.andriy_at_[hidden]
Date: 2012-01-17 17:35:12


Author: asydorchuk
Date: 2012-01-17 17:35:11 EST (Tue, 17 Jan 2012)
New Revision: 76568
URL: http://svn.boost.org/trac/boost/changeset/76568

Log:
Renaming get_d function to to_fpt.
Moving type converters to a separate structure that will be specified using voronoi builder traits.
Text files modified:
   sandbox/gtl/boost/polygon/detail/voronoi_calc_utils.hpp | 301 ++++++++++++++++-----------------------
   sandbox/gtl/boost/polygon/detail/voronoi_robust_fpt.hpp | 70 +++-----
   sandbox/gtl/libs/polygon/test/voronoi_robust_fpt_test.cpp | 99 ++++++------
   3 files changed, 202 insertions(+), 268 deletions(-)

Modified: sandbox/gtl/boost/polygon/detail/voronoi_calc_utils.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/detail/voronoi_calc_utils.hpp (original)
+++ sandbox/gtl/boost/polygon/detail/voronoi_calc_utils.hpp 2012-01-17 17:35:11 EST (Tue, 17 Jan 2012)
@@ -30,20 +30,14 @@
     typedef uint64 uint_x2_type;
     typedef fpt64 fpt_type;
     typedef ulp_comparison<fpt_type> ulp_cmp_type;
+ typedef type_converter_fpt to_fpt_converter;
+ typedef type_converter_efpt to_efpt_converter;
 
     static const unsigned int ULPS;
     static const unsigned int ULPSx2;
     static const fpt_type fULPS;
     static const fpt_type fULPSx2;
 
- // Represents the result of the epsilon robust predicate.
- // If the result is undefined some further processing is usually required.
- enum kPredicateResult {
- LESS = -1,
- UNDEFINED = 0,
- MORE = 1
- };
-
     // Represents orientation test result.
     enum kOrientation {
         RIGHT = -1,
@@ -167,45 +161,40 @@
 
         bool operator()(const site_type &lhs, const circle_type &rhs) const {
             ulp_cmp_type::kResult xCmp =
- ulp_cmp(static_cast<fpt_type>(lhs.x()),
- static_cast<fpt_type>(rhs.lower_x()), ULPS);
+ ulp_cmp(to_fpt(lhs.x()), to_fpt(rhs.lower_x()), ULPS);
             if (xCmp != ulp_cmp_type::EQUAL) {
                 return xCmp == ulp_cmp_type::LESS;
             }
             ulp_cmp_type::kResult yCmp =
- ulp_cmp(static_cast<fpt_type>(lhs.y()),
- static_cast<fpt_type>(rhs.lower_y()), ULPS);
+ ulp_cmp(to_fpt(lhs.y()), to_fpt(rhs.lower_y()), ULPS);
             return yCmp == ulp_cmp_type::LESS;
         }
 
         bool operator()(const circle_type &lhs, const site_type &rhs) const {
             ulp_cmp_type::kResult xCmp =
- ulp_cmp(static_cast<fpt_type>(lhs.lower_x()),
- static_cast<fpt_type>(rhs.x()), ULPS);
+ ulp_cmp(to_fpt(lhs.lower_x()), to_fpt(rhs.x()), ULPS);
             if (xCmp != ulp_cmp_type::EQUAL) {
                 return xCmp == ulp_cmp_type::LESS;
             }
             ulp_cmp_type::kResult yCmp =
- ulp_cmp(static_cast<fpt_type>(lhs.lower_y()),
- static_cast<fpt_type>(rhs.y()), ULPS);
+ ulp_cmp(to_fpt(lhs.lower_y()), to_fpt(rhs.y()), ULPS);
             return yCmp == ulp_cmp_type::LESS;
         }
 
         bool operator()(const circle_type &lhs, const circle_type &rhs) const {
             ulp_cmp_type::kResult xCmp =
- ulp_cmp(static_cast<fpt_type>(lhs.lower_x()),
- static_cast<fpt_type>(rhs.lower_x()), ULPS);
+ ulp_cmp(to_fpt(lhs.lower_x()), to_fpt(rhs.lower_x()), ULPS);
             if (xCmp != ulp_cmp_type::EQUAL) {
                 return xCmp == ulp_cmp_type::LESS;
             }
             ulp_cmp_type::kResult yCmp =
- ulp_cmp(static_cast<fpt_type>(lhs.lower_y()),
- static_cast<fpt_type>(rhs.lower_y()), ULPS);
+ ulp_cmp(to_fpt(lhs.lower_y()), to_fpt(rhs.lower_y()), ULPS);
             return yCmp == ulp_cmp_type::LESS;
         }
 
     private:
         ulp_cmp_type ulp_cmp;
+ to_fpt_converter to_fpt;
     };
 
     template <typename Site>
@@ -234,7 +223,15 @@
             }
         }
 
- private:
+ private:
+ // Represents the result of the epsilon robust predicate. If the
+ // result is undefined some further processing is usually required.
+ enum kPredicateResult {
+ LESS = -1,
+ UNDEFINED = 0,
+ MORE = 1
+ };
+
         typedef typename Site::point_type point_type;
 
         // Robust predicate, avoids using high-precision libraries.
@@ -301,34 +298,27 @@
 
         fpt_type find_distance_to_point_arc(const site_type &site,
                                             const point_type &point) const {
- fpt_type dx = static_cast<fpt_type>(site.x()) -
- static_cast<fpt_type>(point.x());
- fpt_type dy = static_cast<fpt_type>(site.y()) -
- static_cast<fpt_type>(point.y());
+ fpt_type dx = to_fpt(site.x()) - to_fpt(point.x());
+ fpt_type dy = to_fpt(site.y()) - to_fpt(point.y());
             // The relative error is atmost 3EPS.
- return (dx * dx + dy * dy) / (static_cast<fpt_type>(2.0) * dx);
+ return (dx * dx + dy * dy) / (to_fpt(2.0) * dx);
         }
 
         fpt_type find_distance_to_segment_arc(const site_type &site,
                                               const point_type &point) const {
             if (is_vertical(site)) {
- return (static_cast<fpt_type>(site.x()) - static_cast<fpt_type>(point.x())) *
- static_cast<fpt_type>(0.5);
+ return (to_fpt(site.x()) - to_fpt(point.x())) * to_fpt(0.5);
             } else {
                 const point_type &segment0 = site.point0(true);
                 const point_type &segment1 = site.point1(true);
- fpt_type a1 = static_cast<fpt_type>(segment1.x()) -
- static_cast<fpt_type>(segment0.x());
- fpt_type b1 = static_cast<fpt_type>(segment1.y()) -
- static_cast<fpt_type>(segment0.y());
- fpt_type a3 = static_cast<fpt_type>(point.x()) -
- static_cast<fpt_type>(segment0.x());
- fpt_type b3 = static_cast<fpt_type>(point.y()) -
- static_cast<fpt_type>(segment0.y());
+ fpt_type a1 = to_fpt(segment1.x()) - to_fpt(segment0.x());
+ fpt_type b1 = to_fpt(segment1.y()) - to_fpt(segment0.y());
+ fpt_type a3 = to_fpt(point.x()) - to_fpt(segment0.x());
+ fpt_type b3 = to_fpt(point.y()) - to_fpt(segment0.y());
                 fpt_type k = get_sqrt(a1 * a1 + b1 * b1);
                 // Avoid substraction while computing k.
                 if (!is_neg(b1)) {
- k = static_cast<fpt_type>(1.0) / (b1 + k);
+ k = to_fpt(1.0) / (b1 + k);
                 } else {
                     k = (k - b1) / (a1 * a1);
                 }
@@ -347,14 +337,10 @@
                 return (!right_site.is_inverse()) ? LESS : MORE;
             }
 
- fpt_type dif_x = static_cast<fpt_type>(new_point.x()) -
- static_cast<fpt_type>(site_point.x());
- fpt_type dif_y = static_cast<fpt_type>(new_point.y()) -
- static_cast<fpt_type>(site_point.y());
- fpt_type a = static_cast<fpt_type>(segment_end.x()) -
- static_cast<fpt_type>(segment_start.x());
- fpt_type b = static_cast<fpt_type>(segment_end.y()) -
- static_cast<fpt_type>(segment_start.y());
+ fpt_type dif_x = to_fpt(new_point.x()) - to_fpt(site_point.x());
+ fpt_type dif_y = to_fpt(new_point.y()) - to_fpt(site_point.y());
+ fpt_type a = to_fpt(segment_end.x()) - to_fpt(segment_start.x());
+ fpt_type b = to_fpt(segment_end.y()) - to_fpt(segment_start.y());
 
             if (is_vertical(right_site)) {
                 if (new_point.y() < site_point.y() && !reverse_order)
@@ -372,7 +358,7 @@
             }
 
             fpt_type fast_left_expr = a * (dif_y + dif_x) * (dif_y - dif_x);
- fpt_type fast_right_expr = (static_cast<fpt_type>(2) * b) * dif_x * dif_y;
+ fpt_type fast_right_expr = (to_fpt(2.0) * b) * dif_x * dif_y;
             ulp_cmp_type::kResult expr_cmp = ulp_cmp(fast_left_expr, fast_right_expr, 4);
             if (expr_cmp != ulp_cmp_type::EQUAL) {
                 if ((expr_cmp == ulp_cmp_type::MORE) ^ reverse_order)
@@ -384,6 +370,7 @@
 
     private:
         ulp_cmp_type ulp_cmp;
+ to_fpt_converter to_fpt;
     };
 
     template <typename Node>
@@ -537,7 +524,7 @@
         typedef typename Site::point_type point_type;
         typedef Site site_type;
         typedef Circle circle_type;
- typedef robust_sqrt_expr<eint4096, efpt64> robust_sqrt_expr_type;
+ typedef robust_sqrt_expr<eint4096, efpt64, to_efpt_converter> robust_sqrt_expr_type;
 
         void ppp(const site_type &site1,
                  const site_type &site2,
@@ -568,20 +555,20 @@
                        static_cast<int_x2_type>(site2.y());
             sum_y[1] = static_cast<int_x2_type>(site2.y()) +
                        static_cast<int_x2_type>(site3.y());
- fpt_type inv_denom = 0.5 / get_d(dif_x[0] * dif_y[1] - dif_x[1] * dif_y[0]);
+ fpt_type inv_denom = 0.5 / to_fpt(dif_x[0] * dif_y[1] - dif_x[1] * dif_y[0]);
             eint numer1 = dif_x[0] * sum_x[0] + dif_y[0] * sum_y[0];
             eint numer2 = dif_x[1] * sum_x[1] + dif_y[1] * sum_y[1];
 
             if (recompute_c_x || recompute_lower_x) {
                 eint c_x = numer1 * dif_y[1] - numer2 * dif_y[0];
- circle.x(get_d(c_x) * inv_denom);
+ circle.x(to_fpt(c_x) * inv_denom);
 
                 if (recompute_lower_x) {
                     // Evaluate radius of the circle.
                     eint sqr_r = (dif_x[0] * dif_x[0] + dif_y[0] * dif_y[0]) *
                                  (dif_x[1] * dif_x[1] + dif_y[1] * dif_y[1]) *
                                  (dif_x[2] * dif_x[2] + dif_y[2] * dif_y[2]);
- fpt_type r = get_sqrt(get_d(sqr_r));
+ fpt_type r = get_sqrt(to_fpt(sqr_r));
 
                     // If c_x >= 0 then lower_x = c_x + r,
                     // else lower_x = (c_x * c_x - r * r) / (c_x - r).
@@ -594,8 +581,8 @@
                         }
                     } else {
                         eint numer = c_x * c_x - sqr_r;
- fpt_type lower_x = get_d(numer) * inv_denom /
- (get_d(c_x) + r);
+ fpt_type lower_x = to_fpt(numer) * inv_denom /
+ (to_fpt(c_x) + r);
                         circle.lower_x(lower_x);
                     }
                 }
@@ -603,7 +590,7 @@
 
             if (recompute_c_y) {
                 eint c_y = numer2 * dif_x[0] - numer1 * dif_x[1];
- circle.y(get_d(c_y) * inv_denom);
+ circle.y(to_fpt(c_y) * inv_denom);
             }
         }
 
@@ -654,22 +641,22 @@
                 cA[1] = denom * sum_AB * 2 + numer * teta;
                 cB[1] = 1;
                 cA[2] = denom * sum_y * 2 + numer * vec_y;
- fpt_type inv_denom = 1.0 / get_d(denom);
+ fpt_type inv_denom = 1.0 / to_fpt(denom);
                 if (recompute_c_x) {
- c_event.x(0.25 * get_d(cA[0]) * inv_denom);
+ c_event.x(0.25 * to_fpt(cA[0]) * inv_denom);
                 }
                 if (recompute_c_y) {
- c_event.y(0.25 * get_d(cA[2]) * inv_denom);
+ c_event.y(0.25 * to_fpt(cA[2]) * inv_denom);
                 }
                 if (recompute_lower_x) {
- c_event.lower_x(0.25 * get_d(sqrt_expr_.eval2(cA, cB)) * inv_denom /
- get_sqrt(get_d(segm_len)));
+ c_event.lower_x(0.25 * to_fpt(sqrt_expr_.eval2(cA, cB)) * inv_denom /
+ get_sqrt(to_fpt(segm_len)));
                 }
                 return;
             }
 
             eint det = (teta * teta + denom * denom) * A * B * 4;
- fpt_type inv_denom_sqr = 1.0 / get_d(denom);
+ fpt_type inv_denom_sqr = 1.0 / to_fpt(denom);
             inv_denom_sqr *= inv_denom_sqr;
 
             if (recompute_c_x || recompute_lower_x) {
@@ -678,7 +665,7 @@
                 cA[1] = (segment_index == 2) ? -vec_x : vec_x;
                 cB[1] = det;
                 if (recompute_c_x) {
- c_event.x(0.5 * get_d(sqrt_expr_.eval2(cA, cB)) * inv_denom_sqr);
+ c_event.x(0.5 * to_fpt(sqrt_expr_.eval2(cA, cB)) * inv_denom_sqr);
                 }
             }
 
@@ -688,7 +675,7 @@
                 cA[3] = (segment_index == 2) ? -vec_y : vec_y;
                 cB[3] = det;
                 if (recompute_c_y) {
- c_event.y(0.5 * get_d(sqrt_expr_.eval2(&cA[2], &cB[2])) *
+ c_event.y(0.5 * to_fpt(sqrt_expr_.eval2(&cA[2], &cB[2])) *
                               inv_denom_sqr);
                 }
             }
@@ -700,8 +687,8 @@
                 cB[2] = 1;
                 cA[3] = (segment_index == 2) ? -teta : teta;
                 cB[3] = det;
- c_event.lower_x(0.5 * get_d(sqrt_expr_.eval4(cA, cB)) * inv_denom_sqr /
- get_sqrt(get_d(segm_len)));
+ c_event.lower_x(0.5 * to_fpt(sqrt_expr_.eval4(cA, cB)) * inv_denom_sqr /
+ get_sqrt(to_fpt(segm_len)));
             }
         }
 
@@ -730,7 +717,7 @@
                    static_cast<int_x2_type>(segm_start2.y());
             eint orientation = a[1] * b[0] - a[0] * b[1];
             if (is_zero(orientation)) {
- fpt_type denom = get_d(a[0] * a[0] + b[0] * b[0]) * 2;
+ fpt_type denom = to_fpt(a[0] * a[0] + b[0] * b[0]) * 2;
                 c[0] = b[0] * (static_cast<int_x2_type>(segm_start2.x()) -
                                static_cast<int_x2_type>(segm_start1.x())) -
                        a[0] * (static_cast<int_x2_type>(segm_start2.y()) -
@@ -754,7 +741,7 @@
                                            static_cast<int_x2_type>(segm_start2.x()) -
                                            static_cast<int_x2_type>(site1.x()) * 2) +
                             b[0] * b[0] * (static_cast<int_x2_type>(site1.y()) * 2);
- fpt_type c_y = get_d(sqrt_expr_.eval2(cA, cB));
+ fpt_type c_y = to_fpt(sqrt_expr_.eval2(cA, cB));
                     c_event.y(c_y / denom);
                 }
 
@@ -768,14 +755,14 @@
                             a[0] * a[0] * (static_cast<int_x2_type>(site1.x()) * 2);
 
                     if (recompute_c_x) {
- fpt_type c_x = get_d(sqrt_expr_.eval2(cA, cB));
+ fpt_type c_x = to_fpt(sqrt_expr_.eval2(cA, cB));
                         c_event.x(c_x / denom);
                     }
 
                     if (recompute_lower_x) {
                         cA[2] = is_neg(c[0]) ? -c[0] : c[0];
                         cB[2] = a[0] * a[0] + b[0] * b[0];
- fpt_type lower_x = get_d(sqrt_expr_.eval3(cA, cB));
+ fpt_type lower_x = to_fpt(sqrt_expr_.eval3(cA, cB));
                         c_event.lower_x(lower_x / denom);
                     }
                 }
@@ -790,9 +777,9 @@
             eint dx = ix - orientation * site1.x();
             eint dy = iy - orientation * site1.y();
             if (is_zero(dx) && is_zero(dy)) {
- fpt_type denom = get_d(orientation);
- fpt_type c_x = get_d(ix) / denom;
- fpt_type c_y = get_d(iy) / denom;
+ fpt_type denom = to_fpt(orientation);
+ fpt_type c_x = to_fpt(ix) / denom;
+ fpt_type c_y = to_fpt(iy) / denom;
                 c_event = circle_type(c_x, c_y, c_x);
                 return;
             }
@@ -806,14 +793,14 @@
             cB[1] = a[1] * a[1] + b[1] * b[1];
             cB[2] = a[0] * a[1] + b[0] * b[1];
             cB[3] = (a[0] * dy - b[0] * dx) * (a[1] * dy - b[1] * dx) * -2;
- fpt_type temp = get_d(sqrt_expr_evaluator_pss4<eint, efpt64>(cA, cB));
- fpt_type denom = temp * get_d(orientation);
+ fpt_type temp = to_fpt(sqrt_expr_evaluator_pss4<eint, efpt64>(cA, cB));
+ fpt_type denom = temp * to_fpt(orientation);
 
             if (recompute_c_y) {
                 cA[0] = b[1] * (dx * dx + dy * dy) - iy * (dx * a[1] + dy * b[1]);
                 cA[1] = b[0] * (dx * dx + dy * dy) - iy * (dx * a[0] + dy * b[0]);
                 cA[2] = iy * sign;
- fpt_type cy = get_d(sqrt_expr_evaluator_pss4<eint, efpt64>(cA, cB));
+ fpt_type cy = to_fpt(sqrt_expr_evaluator_pss4<eint, efpt64>(cA, cB));
                 c_event.y(cy / denom);
             }
 
@@ -823,13 +810,13 @@
                 cA[2] = ix * sign;
 
                 if (recompute_c_x) {
- fpt_type cx = get_d(sqrt_expr_evaluator_pss4<eint, efpt64>(cA, cB));
+ fpt_type cx = to_fpt(sqrt_expr_evaluator_pss4<eint, efpt64>(cA, cB));
                     c_event.x(cx / denom);
                 }
 
                 if (recompute_lower_x) {
                     cA[3] = orientation * (dx * dx + dy * dy) * (is_neg(temp) ? -1 : 1);
- fpt_type lower_x = get_d(sqrt_expr_evaluator_pss4<eint, efpt64>(cA, cB));
+ fpt_type lower_x = to_fpt(sqrt_expr_evaluator_pss4<eint, efpt64>(cA, cB));
                     c_event.lower_x(lower_x / denom);
                 }
             }
@@ -883,7 +870,7 @@
                 int k = (i+2) % 3;
                 cA[i] = a[j] * b[k] - a[k] * b[j];
             }
- fpt_type denom = get_d(sqrt_expr_.eval3(cA, cB));
+ fpt_type denom = to_fpt(sqrt_expr_.eval3(cA, cB));
 
             if (recompute_c_y) {
                 for (int i = 0; i < 3; ++i) {
@@ -891,7 +878,7 @@
                     int k = (i+2) % 3;
                     cA[i] = b[j] * c[k] - b[k] * c[j];
                 }
- fpt_type c_y = get_d(sqrt_expr_.eval3(cA, cB));
+ fpt_type c_y = to_fpt(sqrt_expr_.eval3(cA, cB));
                 c_event.y(c_y / denom);
             }
 
@@ -907,13 +894,13 @@
                 }
 
                 if (recompute_c_x) {
- fpt_type c_x = get_d(sqrt_expr_.eval3(cA, cB));
+ fpt_type c_x = to_fpt(sqrt_expr_.eval3(cA, cB));
                     c_event.x(c_x / denom);
                 }
 
                 if (recompute_lower_x) {
                     cB[3] = 1;
- fpt_type lower_x = get_d(sqrt_expr_.eval4(cA, cB));
+ fpt_type lower_x = to_fpt(sqrt_expr_.eval4(cA, cB));
                     c_event.lower_x(lower_x / denom);
                 }
             }
@@ -989,6 +976,7 @@
         }
 
         robust_sqrt_expr_type sqrt_expr_;
+ to_fpt_converter to_fpt;
     };
 
     template <typename Site, typename Circle>
@@ -1006,28 +994,18 @@
                  const site_type &site2,
                  const site_type &site3,
                  circle_type &c_event) {
- fpt_type dif_x1 = static_cast<fpt_type>(site1.x()) -
- static_cast<fpt_type>(site2.x());
- fpt_type dif_x2 = static_cast<fpt_type>(site2.x()) -
- static_cast<fpt_type>(site3.x());
- fpt_type dif_y1 = static_cast<fpt_type>(site1.y()) -
- static_cast<fpt_type>(site2.y());
- fpt_type dif_y2 = static_cast<fpt_type>(site2.y()) -
- static_cast<fpt_type>(site3.y());
+ fpt_type dif_x1 = to_fpt(site1.x()) - to_fpt(site2.x());
+ fpt_type dif_x2 = to_fpt(site2.x()) - to_fpt(site3.x());
+ fpt_type dif_y1 = to_fpt(site1.y()) - to_fpt(site2.y());
+ fpt_type dif_y2 = to_fpt(site2.y()) - to_fpt(site3.y());
             fpt_type orientation = robust_cross_product(dif_x1, dif_y1, dif_x2, dif_y2);
             robust_fpt_type inv_orientation(0.5 / orientation, 2.0);
- fpt_type sum_x1 = static_cast<fpt_type>(site1.x()) +
- static_cast<fpt_type>(site2.x());
- fpt_type sum_x2 = static_cast<fpt_type>(site2.x()) +
- static_cast<fpt_type>(site3.x());
- fpt_type sum_y1 = static_cast<fpt_type>(site1.y()) +
- static_cast<fpt_type>(site2.y());
- fpt_type sum_y2 = static_cast<fpt_type>(site2.y()) +
- static_cast<fpt_type>(site3.y());
- fpt_type dif_x3 = static_cast<fpt_type>(site1.x()) -
- static_cast<fpt_type>(site3.x());
- fpt_type dif_y3 = static_cast<fpt_type>(site1.y()) -
- static_cast<fpt_type>(site3.y());
+ fpt_type sum_x1 = to_fpt(site1.x()) + to_fpt(site2.x());
+ fpt_type sum_x2 = to_fpt(site2.x()) + to_fpt(site3.x());
+ fpt_type sum_y1 = to_fpt(site1.y()) + to_fpt(site2.y());
+ fpt_type sum_y2 = to_fpt(site2.y()) + to_fpt(site3.y());
+ fpt_type dif_x3 = to_fpt(site1.x()) - to_fpt(site3.x());
+ fpt_type dif_y3 = to_fpt(site1.y()) - to_fpt(site3.y());
             robust_dif_type c_x, c_y;
             c_x += robust_fpt_type(dif_x1 * sum_x1 * dif_y2, 2.0);
             c_x += robust_fpt_type(dif_y1 * sum_y1 * dif_y2, 2.0);
@@ -1058,27 +1036,21 @@
                  const site_type &site3,
                  int segment_index,
                  circle_type &c_event) {
- fpt_type line_a = static_cast<fpt_type>(site3.point1(true).y()) -
- static_cast<fpt_type>(site3.point0(true).y());
- fpt_type line_b = static_cast<fpt_type>(site3.point0(true).x()) -
- static_cast<fpt_type>(site3.point1(true).x());
- fpt_type vec_x = static_cast<fpt_type>(site2.y()) -
- static_cast<fpt_type>(site1.y());
- fpt_type vec_y = static_cast<fpt_type>(site1.x()) -
- static_cast<fpt_type>(site2.x());
+ fpt_type line_a = to_fpt(site3.point1(true).y()) - to_fpt(site3.point0(true).y());
+ fpt_type line_b = to_fpt(site3.point0(true).x()) - to_fpt(site3.point1(true).x());
+ fpt_type vec_x = to_fpt(site2.y()) - to_fpt(site1.y());
+ fpt_type vec_y = to_fpt(site1.x()) - to_fpt(site2.x());
             robust_fpt_type teta(robust_cross_product(line_a, line_b, -vec_y, vec_x), 1.0);
             robust_fpt_type A(robust_cross_product(
                 line_a, line_b,
- static_cast<fpt_type>(site3.point1().y()) -
- static_cast<fpt_type>(site1.y()),
- static_cast<fpt_type>(site1.x()) -
- static_cast<fpt_type>(site3.point1().x())), 1.0);
+ to_fpt(site3.point1().y()) - to_fpt(site1.y()),
+ to_fpt(site1.x()) - to_fpt(site3.point1().x())),
+ 1.0);
             robust_fpt_type B(robust_cross_product(
                 line_a, line_b,
- static_cast<fpt_type>(site3.point1().y()) -
- static_cast<fpt_type>(site2.y()),
- static_cast<fpt_type>(site2.x()) -
- static_cast<fpt_type>(site3.point1().x())), 1.0);
+ to_fpt(site3.point1().y()) - to_fpt(site2.y()),
+ to_fpt(site2.x()) - to_fpt(site3.point1().x())),
+ 1.0);
             robust_fpt_type denom(robust_cross_product(vec_x, vec_y, line_a, line_b), 1.0);
             robust_fpt_type inv_segm_len(1.0 / get_sqrt(sqr_distance(line_a, line_b)), 3.0);
             robust_dif_type t;
@@ -1095,13 +1067,9 @@
                 t += teta * (A + B) / (robust_fpt_type(2.0, false) * denom * denom);
             }
             robust_dif_type c_x, c_y;
- c_x += robust_fpt_type(0.5 * (
- static_cast<fpt_type>(site1.x()) +
- static_cast<fpt_type>(site2.x())), false);
+ c_x += robust_fpt_type(0.5 * (to_fpt(site1.x()) + to_fpt(site2.x())), false);
             c_x += robust_fpt_type(vec_x, false) * t;
- c_y += robust_fpt_type(0.5 * (
- static_cast<fpt_type>(site1.y()) +
- static_cast<fpt_type>(site2.y())), false);
+ c_y += robust_fpt_type(0.5 * (to_fpt(site1.y()) + to_fpt(site2.y())), false);
             c_y += robust_fpt_type(vec_y, false) * t;
             robust_dif_type r, lower_x(c_x);
             r -= robust_fpt_type(line_a, false) * robust_fpt_type(site3.x0(), false);
@@ -1132,46 +1100,36 @@
             const point_type &segm_end1 = site2.point0(true);
             const point_type &segm_start2 = site3.point0(true);
             const point_type &segm_end2 = site3.point1(true);
- fpt_type a1 = static_cast<fpt_type>(segm_end1.x()) -
- static_cast<fpt_type>(segm_start1.x());
- fpt_type b1 = static_cast<fpt_type>(segm_end1.y()) -
- static_cast<fpt_type>(segm_start1.y());
- fpt_type a2 = static_cast<fpt_type>(segm_end2.x()) -
- static_cast<fpt_type>(segm_start2.x());
- fpt_type b2 = static_cast<fpt_type>(segm_end2.y()) -
- static_cast<fpt_type>(segm_start2.y());
+ fpt_type a1 = to_fpt(segm_end1.x()) - to_fpt(segm_start1.x());
+ fpt_type b1 = to_fpt(segm_end1.y()) - to_fpt(segm_start1.y());
+ fpt_type a2 = to_fpt(segm_end2.x()) - to_fpt(segm_start2.x());
+ fpt_type b2 = to_fpt(segm_end2.y()) - to_fpt(segm_start2.y());
             bool recompute_c_x, recompute_c_y, recompute_lower_x;
             robust_fpt_type orientation(robust_cross_product(b1, a1, b2, a2), 1.0);
             if (get_orientation(orientation) == COLLINEAR) {
                 robust_fpt_type a(a1 * a1 + b1 * b1, 2.0);
                 robust_fpt_type c(robust_cross_product(
                     b1, a1,
- static_cast<fpt_type>(segm_start2.y()) -
- static_cast<fpt_type>(segm_start1.y()),
- static_cast<fpt_type>(segm_start2.x()) -
- static_cast<fpt_type>(segm_start1.x())), 1.0);
+ to_fpt(segm_start2.y()) - to_fpt(segm_start1.y()),
+ to_fpt(segm_start2.x()) - to_fpt(segm_start1.x())),
+ 1.0);
                 robust_fpt_type det(
                     robust_cross_product(
                         a1, b1,
- static_cast<fpt_type>(site1.x()) -
- static_cast<fpt_type>(segm_start1.x()),
- static_cast<fpt_type>(site1.y()) -
- static_cast<fpt_type>(segm_start1.y())) *
+ to_fpt(site1.x()) - to_fpt(segm_start1.x()),
+ to_fpt(site1.y()) - to_fpt(segm_start1.y())) *
                     robust_cross_product(
                         b1, a1,
- static_cast<fpt_type>(site1.y()) -
- static_cast<fpt_type>(segm_start2.y()),
- static_cast<fpt_type>(site1.x()) -
- static_cast<fpt_type>(segm_start2.x())), 3.0);
+ to_fpt(site1.y()) - to_fpt(segm_start2.y()),
+ to_fpt(site1.x()) - to_fpt(segm_start2.x())),
+ 3.0);
                 robust_dif_type t;
                 t -= robust_fpt_type(a1, false) * robust_fpt_type(
- (static_cast<fpt_type>(segm_start1.x()) +
- static_cast<fpt_type>(segm_start2.x())) * 0.5 -
- static_cast<fpt_type>(site1.x()), false);
+ (to_fpt(segm_start1.x()) + to_fpt(segm_start2.x())) * 0.5 -
+ to_fpt(site1.x()), false);
                 t -= robust_fpt_type(b1, false) * robust_fpt_type((
- static_cast<fpt_type>(segm_start1.y()) +
- static_cast<fpt_type>(segm_start2.y())) * 0.5 -
- static_cast<fpt_type>(site1.y()), false);
+ to_fpt(segm_start1.y()) + to_fpt(segm_start2.y())) * 0.5 -
+ to_fpt(site1.y()), false);
                 if (point_index == 2) {
                     t += det.sqrt();
                 } else {
@@ -1180,12 +1138,10 @@
                 t /= a;
                 robust_dif_type c_x, c_y;
                 c_x += robust_fpt_type(0.5 * (
- static_cast<fpt_type>(segm_start1.x()) +
- static_cast<fpt_type>(segm_start2.x())), false);
+ to_fpt(segm_start1.x()) + to_fpt(segm_start2.x())), false);
                 c_x += robust_fpt_type(a1, false) * t;
                 c_y += robust_fpt_type(0.5 * (
- static_cast<fpt_type>(segm_start1.y()) +
- static_cast<fpt_type>(segm_start2.y())), false);
+ to_fpt(segm_start1.y()) + to_fpt(segm_start2.y())), false);
                 c_y += robust_fpt_type(b1, false) * t;
                 robust_dif_type lower_x(c_x);
                 if (is_neg(c)) {
@@ -1208,25 +1164,19 @@
                 }
                 robust_fpt_type or1(robust_cross_product(
                     b1, a1,
- static_cast<fpt_type>(segm_end1.y()) -
- static_cast<fpt_type>(site1.y()),
- static_cast<fpt_type>(segm_end1.x()) -
- static_cast<fpt_type>(site1.x())), 1.0);
+ to_fpt(segm_end1.y()) - to_fpt(site1.y()),
+ to_fpt(segm_end1.x()) - to_fpt(site1.x())), 1.0);
                 robust_fpt_type or2(robust_cross_product(
                     a2, b2,
- static_cast<fpt_type>(segm_end2.x()) -
- static_cast<fpt_type>(site1.x()),
- static_cast<fpt_type>(segm_end2.y()) -
- static_cast<fpt_type>(site1.y())), 1.0);
+ to_fpt(segm_end2.x()) - to_fpt(site1.x()),
+ to_fpt(segm_end2.y()) - to_fpt(site1.y())), 1.0);
                 robust_fpt_type det = robust_fpt_type(2.0, false) * a * or1 * or2;
                 robust_fpt_type c1(robust_cross_product(
                     b1, a1,
- static_cast<fpt_type>(segm_end1.y()),
- static_cast<fpt_type>(segm_end1.x())), 1.0);
+ to_fpt(segm_end1.y()), to_fpt(segm_end1.x())), 1.0);
                 robust_fpt_type c2(robust_cross_product(
                     a2, b2,
- static_cast<fpt_type>(segm_end2.x()),
- static_cast<fpt_type>(segm_end2.y())), 1.0);
+ to_fpt(segm_end2.x()), to_fpt(segm_end2.y())), 1.0);
                 robust_fpt_type inv_orientation = robust_fpt_type(1.0, false) / orientation;
                 robust_dif_type t, b, ix, iy;
                 ix += robust_fpt_type(a2, false) * c1 * inv_orientation;
@@ -1240,12 +1190,10 @@
                 b += iy * (robust_fpt_type(b2, false) * sqr_sum1);
                 b -= sqr_sum1 * robust_fpt_type(robust_cross_product(
                     a2, b2,
- static_cast<fpt_type>(-site1.y()),
- static_cast<fpt_type>(site1.x())), 1.0);
+ to_fpt(-site1.y()), to_fpt(site1.x())), 1.0);
                 b -= sqr_sum2 * robust_fpt_type(robust_cross_product(
                     a1, b1,
- static_cast<fpt_type>(-site1.y()),
- static_cast<fpt_type>(site1.x())), 1.0);
+ to_fpt(-site1.y()), to_fpt(site1.x())), 1.0);
                 t -= b;
                 if (point_index == 2) {
                     t += det.sqrt();
@@ -1283,24 +1231,18 @@
                  const site_type &site2,
                  const site_type &site3,
                  circle_type &c_event) {
- robust_fpt_type a1(static_cast<fpt_type>(site1.x1(true)) -
- static_cast<fpt_type>(site1.x0(true)), 0.0);
- robust_fpt_type b1(static_cast<fpt_type>(site1.y1(true)) -
- static_cast<fpt_type>(site1.y0(true)), 0.0);
+ robust_fpt_type a1(to_fpt(site1.x1(true)) - to_fpt(site1.x0(true)), 0.0);
+ robust_fpt_type b1(to_fpt(site1.y1(true)) - to_fpt(site1.y0(true)), 0.0);
             robust_fpt_type c1(robust_cross_product(
                 site1.x0(true), site1.y0(true), site1.x1(true), site1.y1(true)), 1.0);
 
- robust_fpt_type a2(static_cast<fpt_type>(site2.x1(true)) -
- static_cast<fpt_type>(site2.x0(true)), 0.0);
- robust_fpt_type b2(static_cast<fpt_type>(site2.y1(true)) -
- static_cast<fpt_type>(site2.y0(true)), 0.0);
+ robust_fpt_type a2(to_fpt(site2.x1(true)) - to_fpt(site2.x0(true)), 0.0);
+ robust_fpt_type b2(to_fpt(site2.y1(true)) - to_fpt(site2.y0(true)), 0.0);
             robust_fpt_type c2(robust_cross_product(
                 site2.x0(true), site2.y0(true), site2.x1(true), site2.y1(true)), 1.0);
 
- robust_fpt_type a3(static_cast<fpt_type>(site3.x1(true)) -
- static_cast<fpt_type>(site3.x0(true)), 0.0);
- robust_fpt_type b3(static_cast<fpt_type>(site3.y1(true)) -
- static_cast<fpt_type>(site3.y0(true)), 0.0);
+ robust_fpt_type a3(to_fpt(site3.x1(true)) - to_fpt(site3.x0(true)), 0.0);
+ robust_fpt_type b3(to_fpt(site3.y1(true)) - to_fpt(site3.y0(true)), 0.0);
             robust_fpt_type c3(robust_cross_product(
                 site3.x0(true), site3.y0(true), site3.x1(true), site3.y1(true)), 1.0);
 
@@ -1354,6 +1296,7 @@
 
     private:
         exact_circle_formation_functor_type exact_circle_formation_functor_;
+ to_fpt_converter to_fpt;
     };
 
     template <typename Site,

Modified: sandbox/gtl/boost/polygon/detail/voronoi_robust_fpt.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/detail/voronoi_robust_fpt.hpp (original)
+++ sandbox/gtl/boost/polygon/detail/voronoi_robust_fpt.hpp 2012-01-17 17:35:11 EST (Tue, 17 Jan 2012)
@@ -103,11 +103,6 @@
     };
 
     template <typename T>
- fpt64 get_d(const T& that) {
- return static_cast<fpt64>(that);
- }
-
- template <typename T>
     T get_sqrt(const T& that) {
         return (std::sqrt)(that);
     }
@@ -666,7 +661,7 @@
                 exp = fea::kMinExponent;
             }
             fea::set_exponent(ret_val, exp);
- return get_d(ret_val);
+ return ret_val;
         }
 
     private:
@@ -681,11 +676,6 @@
     }
 
     template <typename _fpt>
- fpt64 get_d(const extended_exponent_fpt<_fpt>& that) {
- return that.d();
- }
-
- template <typename _fpt>
     bool is_pos(const extended_exponent_fpt<_fpt>& that) {
         return that.is_pos();
     }
@@ -1123,11 +1113,6 @@
     typedef extended_int<1024> eint32768;
 
     template <size_t N>
- fpt64 get_d(const extended_int<N>& that) {
- return that.d();
- }
-
- template <size_t N>
     bool is_pos(const extended_int<N>& that) {
         return that.count() > 0;
     }
@@ -1142,23 +1127,26 @@
         return !that.count();
     }
 
- template <typename typeA, typename typeB>
- struct type_converter {
- static typeB convert(const typeA& that) {
- return static_cast<typeB>(that);
+ struct type_converter_fpt {
+ template <typename T>
+ fpt64 operator()(const T& that) const {
+ return static_cast<fpt64>(that);
         }
- };
 
- template <typename typeA>
- struct type_converter<typeA, fpt64> {
- static fpt64 convert(const typeA& that) {
- return get_d(that);
+ template <size_t N>
+ fpt64 operator()(const extended_int<N>& that) const {
+ return that.d();
+ }
+
+ template <>
+ fpt64 operator()< extended_exponent_fpt<fpt64> >(const extended_exponent_fpt<fpt64>& that) const {
+ return that.d();
         }
     };
 
- template <size_t N>
- struct type_converter< extended_int<N>, extended_exponent_fpt<fpt64> > {
- static extended_exponent_fpt<fpt64> convert(const extended_int<N>& that) {
+ struct type_converter_efpt {
+ template <size_t N>
+ extended_exponent_fpt<fpt64> operator()(const extended_int<N>& that) const {
             std::pair<fpt64, int64> p = that.p();
             return extended_exponent_fpt<fpt64>(p.first, p.second);
         }
@@ -1167,10 +1155,9 @@
     // Used to compute expressions that operate with sqrts with predefined
     // relative error. Evaluates expressions of the next type:
     // sum(i = 1 .. n)(A[i] * sqrt(B[i])), 1 <= n <= 4.
- template <typename _int, typename _fpt>
+ template <typename _int, typename _fpt, typename _converter>
     class robust_sqrt_expr {
     public:
- typedef type_converter<_int, _fpt> converter;
         static const unsigned int EVAL1_MAX_RELATIVE_ERROR;
         static const unsigned int EVAL2_MAX_RELATIVE_ERROR;
         static const unsigned int EVAL3_MAX_RELATIVE_ERROR;
@@ -1179,8 +1166,8 @@
         // Evaluates expression (re = 4 EPS):
         // A[0] * sqrt(B[0]).
         _fpt eval1(_int *A, _int *B) {
- _fpt a = converter::convert(A[0]);
- _fpt b = converter::convert(B[0]);
+ _fpt a = convert(A[0]);
+ _fpt b = convert(B[0]);
             return a * get_sqrt(b);
         }
 
@@ -1192,7 +1179,7 @@
             if ((!is_neg(a) && !is_neg(b)) ||
                 (!is_pos(a) && !is_pos(b)))
                 return a + b;
- return converter::convert(A[0] * A[0] * B[0] - A[1] * A[1] * B[1]) / (a - b);
+ return convert(A[0] * A[0] * B[0] - A[1] * A[1] * B[1]) / (a - b);
         }
 
         // Evaluates expression (re = 16 EPS):
@@ -1233,16 +1220,17 @@
     private:
         _int tA[5];
         _int tB[5];
+ _converter convert;
     };
 
- template <typename _int, typename _fpt>
- const unsigned int robust_sqrt_expr<_int, _fpt>::EVAL1_MAX_RELATIVE_ERROR = 4;
- template <typename _int, typename _fpt>
- const unsigned int robust_sqrt_expr<_int, _fpt>::EVAL2_MAX_RELATIVE_ERROR = 7;
- template <typename _int, typename _fpt>
- const unsigned int robust_sqrt_expr<_int, _fpt>::EVAL3_MAX_RELATIVE_ERROR = 16;
- template <typename _int, typename _fpt>
- const unsigned int robust_sqrt_expr<_int, _fpt>::EVAL4_MAX_RELATIVE_ERROR = 25;
+ template <typename _int, typename _fpt, typename _converter>
+ const unsigned int robust_sqrt_expr<_int, _fpt, _converter>::EVAL1_MAX_RELATIVE_ERROR = 4;
+ template <typename _int, typename _fpt, typename _converter>
+ const unsigned int robust_sqrt_expr<_int, _fpt, _converter>::EVAL2_MAX_RELATIVE_ERROR = 7;
+ template <typename _int, typename _fpt, typename _converter>
+ const unsigned int robust_sqrt_expr<_int, _fpt, _converter>::EVAL3_MAX_RELATIVE_ERROR = 16;
+ template <typename _int, typename _fpt, typename _converter>
+ const unsigned int robust_sqrt_expr<_int, _fpt, _converter>::EVAL4_MAX_RELATIVE_ERROR = 25;
 } // detail
 } // polygon
 } // boost

Modified: sandbox/gtl/libs/polygon/test/voronoi_robust_fpt_test.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/test/voronoi_robust_fpt_test.cpp (original)
+++ sandbox/gtl/libs/polygon/test/voronoi_robust_fpt_test.cpp 2012-01-17 17:35:11 EST (Tue, 17 Jan 2012)
@@ -20,6 +20,9 @@
 using namespace boost::polygon::detail;
 
 typedef robust_fpt<double> rfpt_type;
+typedef type_converter_fpt to_fpt_type;
+typedef type_converter_efpt to_efpt_type;
+type_converter_fpt to_fpt;
 
 BOOST_AUTO_TEST_CASE(robust_fpt_constructors_test1) {
     rfpt_type a = rfpt_type();
@@ -254,10 +257,10 @@
         efpt64 sum = eea + eeb;
         efpt64 dif = eea - eeb;
         efpt64 mul = eea * eeb;
- BOOST_CHECK_EQUAL(get_d(neg), -a);
- BOOST_CHECK_EQUAL(get_d(sum), a + b);
- BOOST_CHECK_EQUAL(get_d(dif), a - b);
- BOOST_CHECK_EQUAL(get_d(mul), a * b);
+ BOOST_CHECK_EQUAL(to_fpt(neg), -a);
+ BOOST_CHECK_EQUAL(to_fpt(sum), a + b);
+ BOOST_CHECK_EQUAL(to_fpt(dif), a - b);
+ BOOST_CHECK_EQUAL(to_fpt(mul), a * b);
     }
 }
 
@@ -276,11 +279,11 @@
         efpt64 dif = eea - eeb;
         efpt64 mul = eea * eeb;
         efpt64 div = eea / eeb;
- BOOST_CHECK_EQUAL(get_d(neg), -a);
- BOOST_CHECK_EQUAL(get_d(sum), a + b);
- BOOST_CHECK_EQUAL(get_d(dif), a - b);
- BOOST_CHECK_EQUAL(get_d(mul), a * b);
- BOOST_CHECK_EQUAL(get_d(div), a / b);
+ BOOST_CHECK_EQUAL(to_fpt(neg), -a);
+ BOOST_CHECK_EQUAL(to_fpt(sum), a + b);
+ BOOST_CHECK_EQUAL(to_fpt(dif), a - b);
+ BOOST_CHECK_EQUAL(to_fpt(mul), a * b);
+ BOOST_CHECK_EQUAL(to_fpt(div), a / b);
     }
 }
 
@@ -299,11 +302,11 @@
         efpt64 dif = eea - eeb;
         efpt64 mul = eea * eeb;
         efpt64 div = eea / eeb;
- BOOST_CHECK_EQUAL(get_d(neg), -a);
- BOOST_CHECK_EQUAL(get_d(sum), a + b);
- BOOST_CHECK_EQUAL(get_d(dif), a - b);
- BOOST_CHECK_EQUAL(get_d(mul), a * b);
- BOOST_CHECK_EQUAL(get_d(div), a / b);
+ BOOST_CHECK_EQUAL(to_fpt(neg), -a);
+ BOOST_CHECK_EQUAL(to_fpt(sum), a + b);
+ BOOST_CHECK_EQUAL(to_fpt(dif), a - b);
+ BOOST_CHECK_EQUAL(to_fpt(mul), a * b);
+ BOOST_CHECK_EQUAL(to_fpt(div), a / b);
     }
 }
 
@@ -319,11 +322,11 @@
         efpt64 dif = eea - eeb;
         efpt64 mul = eea * eeb;
         efpt64 div = eea / eeb;
- BOOST_CHECK_EQUAL(get_d(neg), -a);
- BOOST_CHECK_EQUAL(get_d(sum), a + b);
- BOOST_CHECK_EQUAL(get_d(dif), a - b);
- BOOST_CHECK_EQUAL(get_d(mul), a * b);
- BOOST_CHECK_EQUAL(get_d(div), a / b);
+ BOOST_CHECK_EQUAL(to_fpt(neg), -a);
+ BOOST_CHECK_EQUAL(to_fpt(sum), a + b);
+ BOOST_CHECK_EQUAL(to_fpt(dif), a - b);
+ BOOST_CHECK_EQUAL(to_fpt(mul), a * b);
+ BOOST_CHECK_EQUAL(to_fpt(div), a / b);
     }
 }
 
@@ -331,32 +334,32 @@
     for (int i = 0; i < 100; ++i) {
         efpt64 a(static_cast<fpt64>(i * i));
         efpt64 b = a.sqrt();
- BOOST_CHECK_EQUAL(get_d(b), static_cast<fpt64>(i));
+ BOOST_CHECK_EQUAL(to_fpt(b), static_cast<fpt64>(i));
     }
 }
 
 BOOST_AUTO_TEST_CASE(extended_int_test1) {
     eint32 e1(0), e2(32), e3(-32);
     BOOST_CHECK_EQUAL(e1.count(), 0);
- BOOST_CHECK_EQUAL(e1.chunks()[0], 0);
- BOOST_CHECK_EQUAL(e1.size(), 0);
+ BOOST_CHECK_EQUAL(e1.chunks()[0], 0u);
+ BOOST_CHECK_EQUAL(e1.size(), 0u);
     BOOST_CHECK_EQUAL(e2.count(), 1);
- BOOST_CHECK_EQUAL(e2.chunks()[0], 32);
- BOOST_CHECK_EQUAL(e2.size(), 1);
+ BOOST_CHECK_EQUAL(e2.chunks()[0], 32u);
+ BOOST_CHECK_EQUAL(e2.size(), 1u);
     BOOST_CHECK_EQUAL(e3.count(), -1);
- BOOST_CHECK_EQUAL(e3.chunks()[0], 32);
- BOOST_CHECK_EQUAL(e3.size(), 1);
+ BOOST_CHECK_EQUAL(e3.chunks()[0], 32u);
+ BOOST_CHECK_EQUAL(e3.size(), 1u);
 }
 
 BOOST_AUTO_TEST_CASE(extended_int_test2) {
     int64 val64 = 0x7fffffffffffffffLL;
     eint64 e1(0LL), e2(32LL), e3(-32LL), e4(val64), e5(-val64);
     BOOST_CHECK_EQUAL(e1.count(), 0);
- BOOST_CHECK_EQUAL(e1.chunks()[0], 0);
+ BOOST_CHECK_EQUAL(e1.chunks()[0], 0u);
     BOOST_CHECK_EQUAL(e2.count(), 1);
- BOOST_CHECK_EQUAL(e2.chunks()[0], 32);
+ BOOST_CHECK_EQUAL(e2.chunks()[0], 32u);
     BOOST_CHECK_EQUAL(e3.count(), -1);
- BOOST_CHECK_EQUAL(e3.chunks()[0], 32);
+ BOOST_CHECK_EQUAL(e3.chunks()[0], 32u);
     BOOST_CHECK_EQUAL(e4.count(), 2);
     BOOST_CHECK_EQUAL(e4.chunks()[0], 0xffffffff);
     BOOST_CHECK_EQUAL(e4.chunks()[1], val64 >> 32);
@@ -371,11 +374,11 @@
     chunks.push_back(2);
     eint64 e1(chunks, true), e2(chunks, false);
     BOOST_CHECK_EQUAL(e1.count(), 2);
- BOOST_CHECK_EQUAL(e1.chunks()[0], 2);
- BOOST_CHECK_EQUAL(e1.chunks()[1], 1);
+ BOOST_CHECK_EQUAL(e1.chunks()[0], 2u);
+ BOOST_CHECK_EQUAL(e1.chunks()[1], 1u);
     BOOST_CHECK_EQUAL(e2.count(), -2);
- BOOST_CHECK_EQUAL(e2.chunks()[0], 2);
- BOOST_CHECK_EQUAL(e2.chunks()[1], 1);
+ BOOST_CHECK_EQUAL(e2.chunks()[0], 2u);
+ BOOST_CHECK_EQUAL(e2.chunks()[1], 1u);
 }
 
 BOOST_AUTO_TEST_CASE(extended_int_test4) {
@@ -416,8 +419,8 @@
     eint32 e1(32);
     eint32 e2 = -e1;
     BOOST_CHECK_EQUAL(e2.count(), -1);
- BOOST_CHECK_EQUAL(e2.size(), 1);
- BOOST_CHECK_EQUAL(e2.chunks()[0], 32);
+ BOOST_CHECK_EQUAL(e2.size(), 1u);
+ BOOST_CHECK_EQUAL(e2.chunks()[0], 32u);
 }
 
 BOOST_AUTO_TEST_CASE(extended_int_test7) {
@@ -458,8 +461,8 @@
         int64 i1 = static_cast<int64>(gen()) >> 20;
         int64 i2 = i1 >> 32;
         eint64 e1(i1), e2(i2);
- BOOST_CHECK(get_d(e1) == static_cast<fpt64>(i1));
- BOOST_CHECK(get_d(e2) == static_cast<fpt64>(i2));
+ BOOST_CHECK(to_fpt(e1) == static_cast<fpt64>(i1));
+ BOOST_CHECK(to_fpt(e2) == static_cast<fpt64>(i2));
     }
 }
 
@@ -473,56 +476,56 @@
 }
 
 BOOST_AUTO_TEST_CASE(robust_sqrt_expr_test1) {
- robust_sqrt_expr<int32, fpt64> sqrt_expr;
+ robust_sqrt_expr<int32, fpt64, to_fpt_type> sqrt_expr;
     int32 A[1] = {10};
     int32 B[1] = {100};
     BOOST_CHECK_EQUAL(sqrt_expr.eval1(A, B), 100.0);
 }
 
 BOOST_AUTO_TEST_CASE(robust_sqrt_expr_test2) {
- robust_sqrt_expr<int32, fpt64> sqrt_expr;
+ robust_sqrt_expr<int32, fpt64, to_fpt_type> sqrt_expr;
     int32 A[2] = {10, 30};
     int32 B[2] = {400, 100};
     BOOST_CHECK_EQUAL(sqrt_expr.eval2(A, B), 500.0);
 }
 
 BOOST_AUTO_TEST_CASE(robust_sqrt_expr_test3) {
- robust_sqrt_expr<int32, fpt64> sqrt_expr;
+ robust_sqrt_expr<int32, fpt64, to_fpt_type> sqrt_expr;
     int32 A[2] = {10, -30};
     int32 B[2] = {400, 100};
     BOOST_CHECK_EQUAL(sqrt_expr.eval2(A, B), -100.0);
 }
 
 BOOST_AUTO_TEST_CASE(robust_sqrt_expr_test4) {
- robust_sqrt_expr<int32, fpt64> sqrt_expr;
+ robust_sqrt_expr<int32, fpt64, to_fpt_type> sqrt_expr;
     int32 A[3] = {10, 30, 20};
     int32 B[3] = {4, 1, 9};
     BOOST_CHECK_EQUAL(sqrt_expr.eval3(A, B), 110.0);
 }
 
 BOOST_AUTO_TEST_CASE(robust_sqrt_expr_test5) {
- robust_sqrt_expr<int32, fpt64> sqrt_expr;
+ robust_sqrt_expr<int32, fpt64, to_fpt_type> sqrt_expr;
     int32 A[3] = {10, 30, -20};
     int32 B[3] = {4, 1, 9};
     BOOST_CHECK_EQUAL(sqrt_expr.eval3(A, B), -10.0);
 }
 
 BOOST_AUTO_TEST_CASE(robust_sqrt_expr_test6) {
- robust_sqrt_expr<int32, fpt64> sqrt_expr;
+ robust_sqrt_expr<int32, fpt64, to_fpt_type> sqrt_expr;
     int32 A[4] = {10, 30, 20, 5};
     int32 B[4] = {4, 1, 9, 16};
     BOOST_CHECK_EQUAL(sqrt_expr.eval4(A, B), 130.0);
 }
 
 BOOST_AUTO_TEST_CASE(robust_sqrt_expr_test7) {
- robust_sqrt_expr<int32, fpt64> sqrt_expr;
+ robust_sqrt_expr<int32, fpt64, to_fpt_type> sqrt_expr;
     int32 A[4] = {10, 30, -20, -5};
     int32 B[4] = {4, 1, 9, 16};
     BOOST_CHECK_EQUAL(sqrt_expr.eval4(A, B), -30.0);
 }
 
 BOOST_AUTO_TEST_CASE(robust_sqrt_expr_test8) {
- robust_sqrt_expr<eint512, efpt64> sqrt_expr;
+ robust_sqrt_expr<eint512, efpt64, to_efpt_type> sqrt_expr;
     int32 A[4] = {1000, 3000, -2000, -500};
     int32 B[4] = {400, 100, 900, 1600};
     eint512 AA[4], BB[4];
@@ -530,7 +533,7 @@
         AA[i] = A[i];
         BB[i] = B[i];
     }
- BOOST_CHECK_EQUAL(get_d(sqrt_expr.eval4(AA, BB)), -30000.0);
+ BOOST_CHECK_EQUAL(to_fpt(sqrt_expr.eval4(AA, BB)), -30000.0);
 }
 
 template <typename _int, typename _fpt>
@@ -562,7 +565,7 @@
                                     sqrt(static_cast<fpt64>(b[j]));
                 }
             }
- fpt64 received_val = get_d(sqrt_expr_.eval4(A, B));
+ fpt64 received_val = to_fpt(sqrt_expr_.eval4(A, B));
             ret_val &= ulp_cmp(expected_val, received_val, 25) ==
                        ulp_comparison<fpt64>::EQUAL;
         }
@@ -570,7 +573,7 @@
     }
 
 private:
- robust_sqrt_expr<_int, _fpt> sqrt_expr_;
+ robust_sqrt_expr<_int, _fpt, to_efpt_type> sqrt_expr_;
     ulp_comparison<fpt64> ulp_cmp;
     _int A[MX_SQRTS];
     _int B[MX_SQRTS];


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk