$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r76414 - sandbox/gtl/boost/polygon/detail
From: sydorchuk.andriy_at_[hidden]
Date: 2012-01-11 15:43:33
Author: asydorchuk
Date: 2012-01-11 15:43:32 EST (Wed, 11 Jan 2012)
New Revision: 76414
URL: http://svn.boost.org/trac/boost/changeset/76414
Log:
Defining all the 0 comparisons (<,==,>) using functors (is_pos, is_zero, is_neg).
Text files modified: 
   sandbox/gtl/boost/polygon/detail/voronoi_calc_utils.hpp |    22 +++++++++++-----------                  
   sandbox/gtl/boost/polygon/detail/voronoi_robust_fpt.hpp |    40 +++++++++++++++++++++-------------------
   2 files changed, 32 insertions(+), 30 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-11 15:43:32 EST (Wed, 11 Jan 2012)
@@ -63,22 +63,22 @@
     // with epsilon relative error equal to 1EPS.
     template <typename T>
     static fpt_type robust_cross_product(T a1_, T b1_, T a2_, T b2_) {
-        uint_x2_type a1 = static_cast<uint_x2_type>((a1_ < 0) ? -a1_ : a1_);
-        uint_x2_type b1 = static_cast<uint_x2_type>((b1_ < 0) ? -b1_ : b1_);
-        uint_x2_type a2 = static_cast<uint_x2_type>((a2_ < 0) ? -a2_ : a2_);
-        uint_x2_type b2 = static_cast<uint_x2_type>((b2_ < 0) ? -b2_ : b2_);
+        uint_x2_type a1 = static_cast<uint_x2_type>(is_neg(a1_) ? -a1_ : a1_);
+        uint_x2_type b1 = static_cast<uint_x2_type>(is_neg(b1_) ? -b1_ : b1_);
+        uint_x2_type a2 = static_cast<uint_x2_type>(is_neg(a2_) ? -a2_ : a2_);
+        uint_x2_type b2 = static_cast<uint_x2_type>(is_neg(b2_) ? -b2_ : b2_);
 
         uint_x2_type l = a1 * b2;
         uint_x2_type r = b1 * a2;
 
-        if ((a1_ > 0) ^ (b2_ > 0)) {
-            if ((a2_ > 0) ^ (b1_ > 0))
+        if (is_neg(a1_) ^ is_neg(b2_)) {
+            if (is_neg(a2_) ^ is_neg(b1_))
                 return (l > r) ? -static_cast<fpt_type>(l - r) :
                                   static_cast<fpt_type>(r - l);
             else
                 return -static_cast<fpt_type>(l + r);
         } else {
-            if ((a2_ > 0) ^ (b1_ > 0))
+            if (is_neg(a2_) ^ is_neg(b1_))
                 return static_cast<fpt_type>(l + r);
             else
                 return (l < r) ? -static_cast<fpt_type>(r - l) :
@@ -251,9 +251,9 @@
                 if (new_point.y() >= right_point.y())
                     return true;
             } else {
-                return static_cast<fpt_type>(left_point.y()) +
-                       static_cast<fpt_type>(right_point.y()) <
-                       2.0 * static_cast<fpt_type>(new_point.y());
+                return static_cast<int_x2_type>(left_point.y()) +
+                       static_cast<int_x2_type>(right_point.y()) <
+                       static_cast<int_x2_type>(new_point.y()) * 2;
             }
 
             fpt_type dist1 = find_distance_to_point_arc(left_site, new_point);
@@ -819,7 +819,7 @@
                 }
 
                 if (recompute_lower_x) {
-                    cA[3] = orientation * (dx * dx + dy * dy) * (temp < 0 ? -1 : 1);
+                    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));
                     c_event.lower_x(lower_x / denom);
                 }
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-11 15:43:32 EST (Wed, 11 Jan 2012)
@@ -146,16 +146,16 @@
                 return *this;
         }
 
-        bool is_pos() const {
-            return fpv_ > 0.0;
+        bool has_pos_value() const {
+            return is_pos(fpv_);
         }
 
-        bool is_neg() const {
-            return fpv_ < 0.0;
+        bool has_neg_value() const {
+            return is_neg(fpv_);
         }
 
-        bool is_zero() const {
-            return fpv_ == 0.0;
+        bool has_zero_value() const {
+            return is_zero(fpv_);
         }
 
         robust_fpt operator-() const {
@@ -164,8 +164,8 @@
 
         robust_fpt& operator+=(const robust_fpt &that) {
             floating_point_type fpv = this->fpv_ + that.fpv_;
-            if ((this->fpv_ >= 0 && that.fpv_ >= 0) ||
-                (this->fpv_ <= 0 && that.fpv_ <= 0))
+            if ((!is_neg(this->fpv_) && !is_neg(that.fpv_)) ||
+                (!is_pos(this->fpv_) && !is_pos(that.fpv_)))
                 this->re_ = (std::max)(this->re_, that.re_) + ROUNDING_ERROR;
             else {
                 floating_point_type temp =
@@ -178,8 +178,8 @@
 
         robust_fpt& operator-=(const robust_fpt &that) {
             floating_point_type fpv = this->fpv_ - that.fpv_;
-            if ((this->fpv_ >= 0 && that.fpv_ <= 0) ||
-                (this->fpv_ <= 0 && that.fpv_ >= 0))
+            if ((!is_neg(this->fpv_) && !is_pos(that.fpv_)) ||
+                (!is_pos(this->fpv_) && !is_neg(that.fpv_)))
                 this->re_ = (std::max)(this->re_, that.re_) + ROUNDING_ERROR;
             else {
                 floating_point_type temp =
@@ -205,8 +205,8 @@
         robust_fpt operator+(const robust_fpt &that) const {
             floating_point_type fpv = this->fpv_ + that.fpv_;
             relative_error_type re;
-            if ((this->fpv_ >= 0 && that.fpv_ >= 0) ||
-                (this->fpv_ <= 0 && that.fpv_ <= 0))
+            if ((!is_neg(this->fpv_) && !is_neg(that.fpv_)) ||
+                (!is_pos(this->fpv_) && !is_pos(that.fpv_)))
                 re = (std::max)(this->re_, that.re_) + ROUNDING_ERROR;
             else {
                 floating_point_type temp =
@@ -219,8 +219,8 @@
         robust_fpt operator-(const robust_fpt &that) const {
             floating_point_type fpv = this->fpv_ - that.fpv_;
             relative_error_type re;
-            if ((this->fpv_ >= 0 && that.fpv_ <= 0) ||
-                (this->fpv_ <= 0 && that.fpv_ >= 0))
+            if ((!is_neg(this->fpv_) && !is_pos(that.fpv_)) ||
+                (!is_pos(this->fpv_) && !is_neg(that.fpv_)))
                 re = (std::max)(this->re_, that.re_) + ROUNDING_ERROR;
             else {
                 floating_point_type temp =
@@ -243,11 +243,13 @@
         }
 
         robust_fpt sqrt() const {
-            return robust_fpt(get_sqrt(fpv_), re_ * 0.5 + ROUNDING_ERROR);
+            return robust_fpt(get_sqrt(fpv_),
+                              re_ * static_cast<relative_error_type>(0.5) +
+                              ROUNDING_ERROR);
         }
 
         robust_fpt fabs() const {
-            return (fpv_ >= 0) ? *this : -(*this);
+            return (!is_neg(fpv_)) ? *this : -(*this);
         }
 
     private:
@@ -266,17 +268,17 @@
 
     template <typename T>
     bool is_pos(const robust_fpt<T>& that) {
-        return that.is_pos();
+        return that.has_pos_value();
     }
 
     template <typename T>
     bool is_neg(const robust_fpt<T>& that) {
-        return that.is_neg();
+        return that.has_neg_value();
     }
 
     template <typename T>
     bool is_zero(const robust_fpt<T>& that) {
-        return that.is_zero();
+        return that.has_zero_value();
     }
 
     // robust_dif consists of two not negative values: value1 and value2.