|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r76489 - in sandbox/gtl: boost/polygon boost/polygon/detail libs/polygon/test
From: sydorchuk.andriy_at_[hidden]
Date: 2012-01-14 10:56:10
Author: asydorchuk
Date: 2012-01-14 10:56:09 EST (Sat, 14 Jan 2012)
New Revision: 76489
URL: http://svn.boost.org/trac/boost/changeset/76489
Log:
Moving almost_equal to ulp_comparison struct.
Removing std::fabs calls.
Text files modified:
sandbox/gtl/boost/polygon/detail/voronoi_calc_utils.hpp | 213 +++++++++++++++++++++++----------------
sandbox/gtl/boost/polygon/detail/voronoi_robust_fpt.hpp | 98 ++++++++++-------
sandbox/gtl/boost/polygon/voronoi_diagram.hpp | 9
sandbox/gtl/libs/polygon/test/voronoi_calc_utils_test.cpp | 8
sandbox/gtl/libs/polygon/test/voronoi_robust_fpt_test.cpp | 4
5 files changed, 194 insertions(+), 138 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-14 10:56:09 EST (Sat, 14 Jan 2012)
@@ -29,6 +29,7 @@
typedef int64 int_x2_type;
typedef uint64 uint_x2_type;
typedef fpt64 fpt_type;
+ typedef ulp_comparison<fpt_type> ulp_cmp_type;
static const unsigned int ULPS;
static const unsigned int ULPSx2;
@@ -165,44 +166,46 @@
}
bool operator()(const site_type &lhs, const circle_type &rhs) const {
- if (almost_equal(static_cast<fpt_type>(lhs.x()),
- static_cast<fpt_type>(rhs.lower_x()), ULPS)) {
- if (almost_equal(static_cast<fpt_type>(lhs.y()),
- static_cast<fpt_type>(rhs.lower_y()), ULPS)) {
- return false;
- }
- return static_cast<fpt_type>(lhs.y()) <
- static_cast<fpt_type>(rhs.lower_y());
- }
- return static_cast<fpt_type>(lhs.x()) <
- static_cast<fpt_type>(rhs.lower_x());
+ ulp_cmp_type::kResult xCmp =
+ ulp_cmp(static_cast<fpt_type>(lhs.x()),
+ static_cast<fpt_type>(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);
+ return yCmp == ulp_cmp_type::LESS;
}
bool operator()(const circle_type &lhs, const site_type &rhs) const {
- if (almost_equal(static_cast<fpt_type>(lhs.lower_x()),
- static_cast<fpt_type>(rhs.x()), ULPS)) {
- if (almost_equal(static_cast<fpt_type>(lhs.lower_y()),
- static_cast<fpt_type>(rhs.y()), ULPS)) {
- return false;
- }
- return static_cast<fpt_type>(lhs.lower_y()) <
- static_cast<fpt_type>(rhs.y());
- }
- return static_cast<fpt_type>(lhs.lower_x()) <
- static_cast<fpt_type>(rhs.x());
+ ulp_cmp_type::kResult xCmp =
+ ulp_cmp(static_cast<fpt_type>(lhs.lower_x()),
+ static_cast<fpt_type>(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);
+ return yCmp == ulp_cmp_type::LESS;
}
bool operator()(const circle_type &lhs, const circle_type &rhs) const {
- if (almost_equal(static_cast<fpt_type>(lhs.lower_x()),
- static_cast<fpt_type>(rhs.lower_x()), ULPSx2)) {
- if (almost_equal(static_cast<fpt_type>(lhs.lower_y()),
- static_cast<fpt_type>(rhs.lower_y()), ULPSx2)) {
- return false;
- }
- return lhs.lower_y() < rhs.lower_y();
- }
- return lhs.lower_x() < rhs.lower_x();
+ ulp_cmp_type::kResult xCmp =
+ ulp_cmp(static_cast<fpt_type>(lhs.lower_x()),
+ static_cast<fpt_type>(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);
+ return yCmp == ulp_cmp_type::LESS;
}
+
+ private:
+ ulp_cmp_type ulp_cmp;
};
template <typename Site>
@@ -370,13 +373,17 @@
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;
- if (!(almost_equal(fast_left_expr, fast_right_expr, 4))) {
- if ((fast_left_expr > fast_right_expr) ^ reverse_order)
+ 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)
return reverse_order ? LESS : MORE;
return UNDEFINED;
}
return UNDEFINED;
}
+
+ private:
+ ulp_cmp_type ulp_cmp;
};
template <typename Node>
@@ -503,7 +510,9 @@
if (!site2.is_inverse() && site3.is_inverse())
return false;
if (site2.is_inverse() == site3.is_inverse() &&
- get_orientation(site2.point0(true), site1.point0(), site3.point1(true)) != RIGHT)
+ get_orientation(site2.point0(true),
+ site1.point0(),
+ site3.point1(true)) != RIGHT)
return false;
}
return true;
@@ -1058,16 +1067,18 @@
fpt_type vec_y = static_cast<fpt_type>(site1.x()) -
static_cast<fpt_type>(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);
- 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);
+ 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);
+ 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);
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;
@@ -1133,21 +1144,25 @@
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);
- 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())) *
- 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);
+ 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);
+ 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())) *
+ 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);
robust_dif_type t;
t -= robust_fpt_type(a1, false) * robust_fpt_type(
(static_cast<fpt_type>(segm_start1.x()) +
@@ -1173,7 +1188,11 @@
static_cast<fpt_type>(segm_start2.y())), false);
c_y += robust_fpt_type(b1, false) * t;
robust_dif_type lower_x(c_x);
- lower_x += robust_fpt_type(0.5, false) * c.fabs() / a.sqrt();
+ if (is_neg(c)) {
+ lower_x -= robust_fpt_type(0.5, false) * c / a.sqrt();
+ } else {
+ lower_x += robust_fpt_type(0.5, false) * c / a.sqrt();
+ }
recompute_c_x = c_x.dif().ulp() > fULPS;
recompute_c_y = c_y.dif().ulp() > fULPS;
recompute_lower_x = lower_x.dif().ulp() > fULPS;
@@ -1187,23 +1206,27 @@
} else {
a = (orientation * orientation) / (sqr_sum1 * sqr_sum2 - a);
}
- 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);
- 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);
+ 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);
+ 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);
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);
- 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);
+ 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);
+ 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);
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;
@@ -1215,12 +1238,14 @@
b += ix * (robust_fpt_type(a2, false) * sqr_sum1);
b += iy * (robust_fpt_type(b1, false) * sqr_sum2);
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);
- 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);
+ 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);
+ 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);
t -= b;
if (point_index == 2) {
t += det.sqrt();
@@ -1237,7 +1262,11 @@
t = -t;
}
robust_dif_type lower_x(c_x);
- lower_x += t * orientation.fabs();
+ if (is_neg(orientation)) {
+ lower_x -= t * orientation;
+ } else {
+ lower_x += t * orientation;
+ }
recompute_c_x = c_x.dif().ulp() > fULPS;
recompute_c_y = c_y.dif().ulp() > fULPS;
recompute_lower_x = lower_x.dif().ulp() > fULPS;
@@ -1258,26 +1287,32 @@
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 c1(robust_cross_product(site1.x0(true), site1.y0(true), site1.x1(true), site1.y1(true)), 1.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 c2(robust_cross_product(site2.x0(true), site2.y0(true), site2.x1(true), site2.y1(true)), 1.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 c3(robust_cross_product(site3.x0(true), site3.y0(true), site3.x1(true), site3.y1(true)), 1.0);
+ robust_fpt_type c3(robust_cross_product(
+ site3.x0(true), site3.y0(true), site3.x1(true), site3.y1(true)), 1.0);
robust_fpt_type len1 = (a1 * a1 + b1 * b1).sqrt();
robust_fpt_type len2 = (a2 * a2 + b2 * b2).sqrt();
robust_fpt_type len3 = (a3 * a3 + b3 * b3).sqrt();
- robust_fpt_type cross_12(robust_cross_product(a1.fpv(), b1.fpv(), a2.fpv(), b2.fpv()), 1.0);
- robust_fpt_type cross_23(robust_cross_product(a2.fpv(), b2.fpv(), a3.fpv(), b3.fpv()), 1.0);
- robust_fpt_type cross_31(robust_cross_product(a3.fpv(), b3.fpv(), a1.fpv(), b1.fpv()), 1.0);
+ robust_fpt_type cross_12(robust_cross_product(
+ a1.fpv(), b1.fpv(), a2.fpv(), b2.fpv()), 1.0);
+ robust_fpt_type cross_23(robust_cross_product(
+ a2.fpv(), b2.fpv(), a3.fpv(), b3.fpv()), 1.0);
+ robust_fpt_type cross_31(robust_cross_product(
+ a3.fpv(), b3.fpv(), a1.fpv(), b1.fpv()), 1.0);
robust_dif_type denom, c_x, c_y, r;
// denom = cross_12 * len3 + cross_23 * len1 + cross_31 * len2.
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-14 10:56:09 EST (Sat, 14 Jan 2012)
@@ -67,32 +67,40 @@
// sign-magnitude integers. Values are considered to be almost equal if
// their integer reinterpretations differ in not more than maxUlps units.
template <typename _fpt>
- bool almost_equal(_fpt a, _fpt b, uint32 ulps);
+ struct ulp_comparison;
- template<>
- bool almost_equal<fpt64>(fpt64 a, fpt64 b, uint32 maxUlps) {
- uint64 ll_a, ll_b;
-
- // Reinterpret double bits as 64-bit signed integer.
- memcpy(&ll_a, &a, sizeof(fpt64));
- memcpy(&ll_b, &b, sizeof(fpt64));
-
- // Positive 0.0 is integer zero. Negative 0.0 is 0x8000000000000000.
- // Map negative zero to an integer zero representation - making it
- // identical to positive zero - the smallest negative number is
- // represented by negative one, and downwards from there.
- if (ll_a < 0x8000000000000000ULL)
- ll_a = 0x8000000000000000ULL - ll_a;
- if (ll_b < 0x8000000000000000ULL)
- ll_b = 0x8000000000000000ULL - ll_b;
-
- // Compare 64-bit signed integer representations of input values.
- // Difference in 1 Ulp is equivalent to a relative error of between
- // 1/4,000,000,000,000,000 and 1/8,000,000,000,000,000.
- if (ll_a > ll_b)
- return ll_a - ll_b <= maxUlps;
- return ll_b - ll_a <= maxUlps;
- }
+ template <>
+ struct ulp_comparison<fpt64> {
+ enum kResult {
+ LESS = -1,
+ EQUAL = 0,
+ MORE = 1
+ };
+
+ kResult operator()(fpt64 a, fpt64 b, unsigned int maxUlps) const {
+ uint64 ll_a, ll_b;
+
+ // Reinterpret double bits as 64-bit signed integer.
+ memcpy(&ll_a, &a, sizeof(fpt64));
+ memcpy(&ll_b, &b, sizeof(fpt64));
+
+ // Positive 0.0 is integer zero. Negative 0.0 is 0x8000000000000000.
+ // Map negative zero to an integer zero representation - making it
+ // identical to positive zero - the smallest negative number is
+ // represented by negative one, and downwards from there.
+ if (ll_a < 0x8000000000000000ULL)
+ ll_a = 0x8000000000000000ULL - ll_a;
+ if (ll_b < 0x8000000000000000ULL)
+ ll_b = 0x8000000000000000ULL - ll_b;
+
+ // Compare 64-bit signed integer representations of input values.
+ // Difference in 1 Ulp is equivalent to a relative error of between
+ // 1/4,000,000,000,000,000 and 1/8,000,000,000,000,000.
+ if (ll_a > ll_b)
+ return (ll_a - ll_b <= maxUlps) ? EQUAL : LESS;
+ return (ll_b - ll_a <= maxUlps) ? EQUAL : MORE;
+ }
+ };
template <typename T>
fpt64 get_d(const T& that) {
@@ -170,7 +178,10 @@
else {
floating_point_type temp =
(this->fpv_ * this->re_ - that.fpv_ * that.re_) / fpv;
- this->re_ = std::fabs(temp) + ROUNDING_ERROR;
+ if (is_neg(temp)) {
+ temp = -temp;
+ }
+ this->re_ = temp + ROUNDING_ERROR;
}
this->fpv_ = fpv;
return *this;
@@ -184,7 +195,10 @@
else {
floating_point_type temp =
(this->fpv_ * this->re_ + that.fpv_ * that.re_) / fpv;
- this->re_ = std::fabs(temp) + ROUNDING_ERROR;
+ if (is_neg(temp)) {
+ temp = -temp;
+ }
+ this->re_ = temp + ROUNDING_ERROR;
}
this->fpv_ = fpv;
return *this;
@@ -211,7 +225,10 @@
else {
floating_point_type temp =
(this->fpv_ * this->re_ - that.fpv_ * that.re_) / fpv;
- re = std::fabs(temp) + ROUNDING_ERROR;
+ if (is_neg(temp)) {
+ temp = -temp;
+ }
+ re = temp + ROUNDING_ERROR;
}
return robust_fpt(fpv, re);
}
@@ -225,7 +242,10 @@
else {
floating_point_type temp =
(this->fpv_ * this->re_ + that.fpv_ * that.re_) / fpv;
- re = std::fabs(temp) + ROUNDING_ERROR;
+ if (is_neg(temp)) {
+ temp = -temp;
+ }
+ re = temp + ROUNDING_ERROR;
}
return robust_fpt(fpv, re);
}
@@ -248,10 +268,6 @@
ROUNDING_ERROR);
}
- robust_fpt fabs() const {
- return (!is_neg(fpv_)) ? *this : -(*this);
- }
-
private:
floating_point_type fpv_;
relative_error_type re_;
@@ -1155,10 +1171,10 @@
class robust_sqrt_expr {
public:
typedef type_converter<_int, _fpt> converter;
- static const uint32 EVAL1_MAX_RELATIVE_ERROR;
- static const uint32 EVAL2_MAX_RELATIVE_ERROR;
- static const uint32 EVAL3_MAX_RELATIVE_ERROR;
- static const uint32 EVAL4_MAX_RELATIVE_ERROR;
+ static const unsigned int EVAL1_MAX_RELATIVE_ERROR;
+ static const unsigned int EVAL2_MAX_RELATIVE_ERROR;
+ static const unsigned int EVAL3_MAX_RELATIVE_ERROR;
+ static const unsigned int EVAL4_MAX_RELATIVE_ERROR;
// Evaluates expression (re = 4 EPS):
// A[0] * sqrt(B[0]).
@@ -1220,13 +1236,13 @@
};
template <typename _int, typename _fpt>
- const uint32 robust_sqrt_expr<_int, _fpt>::EVAL1_MAX_RELATIVE_ERROR = 4;
+ const unsigned int robust_sqrt_expr<_int, _fpt>::EVAL1_MAX_RELATIVE_ERROR = 4;
template <typename _int, typename _fpt>
- const uint32 robust_sqrt_expr<_int, _fpt>::EVAL2_MAX_RELATIVE_ERROR = 7;
+ const unsigned int robust_sqrt_expr<_int, _fpt>::EVAL2_MAX_RELATIVE_ERROR = 7;
template <typename _int, typename _fpt>
- const uint32 robust_sqrt_expr<_int, _fpt>::EVAL3_MAX_RELATIVE_ERROR = 16;
+ const unsigned int robust_sqrt_expr<_int, _fpt>::EVAL3_MAX_RELATIVE_ERROR = 16;
template <typename _int, typename _fpt>
- const uint32 robust_sqrt_expr<_int, _fpt>::EVAL4_MAX_RELATIVE_ERROR = 25;
+ const unsigned int robust_sqrt_expr<_int, _fpt>::EVAL4_MAX_RELATIVE_ERROR = 25;
} // detail
} // polygon
} // boost
Modified: sandbox/gtl/boost/polygon/voronoi_diagram.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/voronoi_diagram.hpp (original)
+++ sandbox/gtl/boost/polygon/voronoi_diagram.hpp 2012-01-14 10:56:09 EST (Sat, 14 Jan 2012)
@@ -1007,10 +1007,10 @@
const voronoi_vertex_type *v2 = edge_it1->vertex1();
// Make epsilon robust check.
- if (detail::almost_equal(v1->vertex().x(),
- v2->vertex().x(), 256) &&
- detail::almost_equal(v1->vertex().y(),
- v2->vertex().y(), 256)) {
+ if (ulp_cmp(v1->vertex().x(), v2->vertex().x(), 256) ==
+ detail::ulp_comparison<T>::EQUAL &&
+ ulp_cmp(v1->vertex().y(), v2->vertex().y(), 256) ==
+ detail::ulp_comparison<T>::EQUAL) {
// Decrease number of cell's incident edges.
edge_it1->cell()->dec_num_incident_edges();
edge_it1->twin()->cell()->dec_num_incident_edges();
@@ -1154,6 +1154,7 @@
int num_vertex_records_;
BRect<coordinate_type> voronoi_rect_;
+ detail::ulp_comparison<T> ulp_cmp;
// Disallow copy constructor and operator=
voronoi_diagram(const voronoi_diagram&);
Modified: sandbox/gtl/libs/polygon/test/voronoi_calc_utils_test.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/test/voronoi_calc_utils_test.cpp (original)
+++ sandbox/gtl/libs/polygon/test/voronoi_calc_utils_test.cpp 2012-01-14 10:56:09 EST (Sat, 14 Jan 2012)
@@ -16,6 +16,8 @@
#include "boost/polygon/detail/voronoi_calc_utils.hpp"
using namespace boost::polygon::detail;
+ulp_comparison<double> ulp_cmp;
+
typedef voronoi_calc_utils<int> VCU;
typedef point_2d<int> point_type;
typedef site_event<int> site_type;
@@ -58,9 +60,9 @@
}
#define CHECK_CIRCLE(circle, c_x, c_y, l_x) \
- BOOST_CHECK_EQUAL(almost_equal(c1.x(), c_x, 10), true); \
- BOOST_CHECK_EQUAL(almost_equal(c1.y(), c_y, 10), true); \
- BOOST_CHECK_EQUAL(almost_equal(c1.lower_x(), l_x, 10), true)
+ BOOST_CHECK_EQUAL(ulp_cmp(c1.x(), c_x, 10), ulp_comparison<double>::EQUAL); \
+ BOOST_CHECK_EQUAL(ulp_cmp(c1.y(), c_y, 10), ulp_comparison<double>::EQUAL); \
+ BOOST_CHECK_EQUAL(ulp_cmp(c1.lower_x(), l_x, 10), ulp_comparison<double>::EQUAL)
#define CHECK_CIRCLE_EXISTENCE(s1, s2, s3, RES) \
{ circle_type c1; \
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-14 10:56:09 EST (Sat, 14 Jan 2012)
@@ -563,13 +563,15 @@
}
}
fpt64 received_val = get_d(sqrt_expr_.eval4(A, B));
- ret_val &= almost_equal(expected_val, received_val, 25);
+ ret_val &= ulp_cmp(expected_val, received_val, 25) ==
+ ulp_comparison<fpt64>::EQUAL;
}
return ret_val;
}
private:
robust_sqrt_expr<_int, _fpt> sqrt_expr_;
+ ulp_comparison<fpt64> ulp_cmp;
_int A[MX_SQRTS];
_int B[MX_SQRTS];
int64 a[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