|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r80589 - branches/release/boost/polygon/detail
From: sydorchuk.andriy_at_[hidden]
Date: 2012-09-18 17:13:42
Author: asydorchuk
Date: 2012-09-18 17:13:41 EDT (Tue, 18 Sep 2012)
New Revision: 80589
URL: http://svn.boost.org/trac/boost/changeset/80589
Log:
Polygon: merging recent trunk fixes: removing all static data from the Voronoi headers; fixing lazy sss predicate logic.
Text files modified:
branches/release/boost/polygon/detail/voronoi_ctypes.hpp | 42 ++++++++++++++++-----------------------
branches/release/boost/polygon/detail/voronoi_predicates.hpp | 30 +++++++++++++++++-----------
branches/release/boost/polygon/detail/voronoi_robust_fpt.hpp | 31 ++++++++--------------------
3 files changed, 44 insertions(+), 59 deletions(-)
Modified: branches/release/boost/polygon/detail/voronoi_ctypes.hpp
==============================================================================
--- branches/release/boost/polygon/detail/voronoi_ctypes.hpp (original)
+++ branches/release/boost/polygon/detail/voronoi_ctypes.hpp 2012-09-18 17:13:41 EDT (Tue, 18 Sep 2012)
@@ -74,11 +74,11 @@
class extened_exponent_fpt_traits<fpt64> {
public:
typedef int exp_type;
- static const int kMaxSignificantExpDif;
+ enum {
+ MAX_SIGNIFICANT_EXP_DIF = 54
+ };
};
-const int extened_exponent_fpt_traits<fpt64>::kMaxSignificantExpDif = 54;
-
// Floating point type wrapper. Allows to extend exponent boundaries to the
// integer type range. This class does not handle division by zero, subnormal
// numbers or NaNs.
@@ -115,11 +115,11 @@
extended_exponent_fpt operator+(const extended_exponent_fpt& that) const {
if (this->val_ == 0.0 ||
- that.exp_ > this->exp_ + _traits::kMaxSignificantExpDif) {
+ that.exp_ > this->exp_ + _traits::MAX_SIGNIFICANT_EXP_DIF) {
return that;
}
if (that.val_ == 0.0 ||
- this->exp_ > that.exp_ + _traits::kMaxSignificantExpDif) {
+ this->exp_ > that.exp_ + _traits::MAX_SIGNIFICANT_EXP_DIF) {
return *this;
}
if (this->exp_ >= that.exp_) {
@@ -135,11 +135,11 @@
extended_exponent_fpt operator-(const extended_exponent_fpt& that) const {
if (this->val_ == 0.0 ||
- that.exp_ > this->exp_ + _traits::kMaxSignificantExpDif) {
+ that.exp_ > this->exp_ + _traits::MAX_SIGNIFICANT_EXP_DIF) {
return extended_exponent_fpt(-that.val_, that.exp_);
}
if (that.val_ == 0.0 ||
- this->exp_ > that.exp_ + _traits::kMaxSignificantExpDif) {
+ this->exp_ > that.exp_ + _traits::MAX_SIGNIFICANT_EXP_DIF) {
return *this;
}
if (this->exp_ >= that.exp_) {
@@ -226,9 +226,6 @@
template<std::size_t N>
class extended_int {
public:
- static const uint64 kUInt64LowMask;
- static const uint64 kUInt64HighMask;
-
extended_int() {}
extended_int(int32 that) {
@@ -245,12 +242,12 @@
extended_int(int64 that) {
if (that > 0) {
- this->chunks_[0] = static_cast<uint32>(that & kUInt64LowMask);
+ this->chunks_[0] = static_cast<uint32>(that);
this->chunks_[1] = that >> 32;
this->count_ = this->chunks_[1] ? 2 : 1;
} else if (that < 0) {
that = -that;
- this->chunks_[0] = static_cast<uint32>(that & kUInt64LowMask);
+ this->chunks_[0] = static_cast<uint32>(that);
this->chunks_[1] = that >> 32;
this->count_ = this->chunks_[1] ? -2 : -1;
} else {
@@ -287,12 +284,12 @@
extended_int& operator=(int64 that) {
if (that > 0) {
- this->chunks_[0] = static_cast<uint32>(that & kUInt64LowMask);
+ this->chunks_[0] = static_cast<uint32>(that);
this->chunks_[1] = that >> 32;
this->count_ = this->chunks_[1] ? 2 : 1;
} else if (that < 0) {
that = -that;
- this->chunks_[0] = static_cast<uint32>(that & kUInt64LowMask);
+ this->chunks_[0] = static_cast<uint32>(that);
this->chunks_[1] = that >> 32;
this->count_ = this->chunks_[1] ? -2 : -1;
} else {
@@ -497,16 +494,16 @@
uint64 temp = 0;
for (std::size_t i = 0; i < sz2; ++i) {
temp += static_cast<uint64>(c1[i]) + static_cast<uint64>(c2[i]);
- this->chunks_[i] = static_cast<uint32>(temp & kUInt64LowMask);
+ this->chunks_[i] = static_cast<uint32>(temp);
temp >>= 32;
}
for (std::size_t i = sz2; i < sz1; ++i) {
temp += static_cast<uint64>(c1[i]);
- this->chunks_[i] = static_cast<uint32>(temp & kUInt64LowMask);
+ this->chunks_[i] = static_cast<uint32>(temp);
temp >>= 32;
}
if (temp && (this->count_ != N)) {
- this->chunks_[this->count_] = static_cast<uint32>(temp & kUInt64LowMask);
+ this->chunks_[this->count_] = static_cast<uint32>(temp);
++this->count_;
}
}
@@ -565,14 +562,14 @@
if (second >= sz2)
continue;
tmp = static_cast<uint64>(c1[first]) * static_cast<uint64>(c2[second]);
- cur += tmp & kUInt64LowMask;
+ cur += static_cast<uint32>(tmp);
nxt += tmp >> 32;
}
- this->chunks_[shift] = static_cast<uint32>(cur & kUInt64LowMask);
+ this->chunks_[shift] = static_cast<uint32>(cur);
cur = nxt + (cur >> 32);
}
if (cur && (this->count_ != N)) {
- this->chunks_[this->count_] = static_cast<uint32>(cur & kUInt64LowMask);
+ this->chunks_[this->count_] = static_cast<uint32>(cur);
++this->count_;
}
}
@@ -582,11 +579,6 @@
};
template <std::size_t N>
-const uint64 extended_int<N>::kUInt64LowMask = 0x00000000ffffffffULL;
-template <std::size_t N>
-const uint64 extended_int<N>::kUInt64HighMask = 0xffffffff00000000ULL;
-
-template <std::size_t N>
bool is_pos(const extended_int<N>& that) {
return that.count() > 0;
}
Modified: branches/release/boost/polygon/detail/voronoi_predicates.hpp
==============================================================================
--- branches/release/boost/polygon/detail/voronoi_predicates.hpp (original)
+++ branches/release/boost/polygon/detail/voronoi_predicates.hpp 2012-09-18 17:13:41 EDT (Tue, 18 Sep 2012)
@@ -1390,41 +1390,47 @@
static_cast<int_x2_type>(site1.x0(true)),
static_cast<int_x2_type>(site1.y1(true)) -
static_cast<int_x2_type>(site1.y0(true))), to_fpt(1.0));
- robust_dif_type denom, c_x, c_y, r;
// denom = cross_12 * len3 + cross_23 * len1 + cross_31 * len2.
+ robust_dif_type denom;
denom += cross_12 * len3;
denom += cross_23 * len1;
denom += cross_31 * len2;
// denom * r = (b2 * c_x - a2 * c_y - c2 * denom) / len2.
+ robust_dif_type r;
r -= cross_12 * c3;
r -= cross_23 * c1;
r -= cross_31 * c2;
+ robust_dif_type c_x;
c_x += a1 * c2 * len3;
c_x -= a2 * c1 * len3;
c_x += a2 * c3 * len1;
c_x -= a3 * c2 * len1;
c_x += a3 * c1 * len2;
c_x -= a1 * c3 * len2;
+
+ robust_dif_type c_y;
c_y += b1 * c2 * len3;
c_y -= b2 * c1 * len3;
c_y += b2 * c3 * len1;
c_y -= b3 * c2 * len1;
c_y += b3 * c1 * len2;
c_y -= b1 * c3 * len2;
- robust_dif_type lower_x(c_x + r);
- bool recompute_c_x = c_x.dif().ulp() > ULPS;
- bool recompute_c_y = c_y.dif().ulp() > ULPS;
- bool recompute_lower_x = lower_x.dif().ulp() > ULPS;
- bool recompute_denom = denom.dif().ulp() > ULPS;
- c_event = circle_type(
- c_x.dif().fpv() / denom.dif().fpv(),
- c_y.dif().fpv() / denom.dif().fpv(),
- lower_x.dif().fpv() / denom.dif().fpv());
- if (recompute_c_x || recompute_c_y ||
- recompute_lower_x || recompute_denom) {
+
+ robust_dif_type lower_x = c_x + r;
+
+ robust_fpt_type denom_dif = denom.dif();
+ robust_fpt_type c_x_dif = c_x.dif() / denom_dif;
+ robust_fpt_type c_y_dif = c_y.dif() / denom_dif;
+ robust_fpt_type lower_x_dif = lower_x.dif() / denom_dif;
+
+ bool recompute_c_x = c_x_dif.ulp() > ULPS;
+ bool recompute_c_y = c_y_dif.ulp() > ULPS;
+ bool recompute_lower_x = lower_x_dif.ulp() > ULPS;
+ c_event = circle_type(c_x_dif.fpv(), c_y_dif.fpv(), lower_x_dif.fpv());
+ if (recompute_c_x || recompute_c_y || recompute_lower_x) {
exact_circle_formation_functor_.sss(
site1, site2, site3, c_event,
recompute_c_x, recompute_c_y, recompute_lower_x);
Modified: branches/release/boost/polygon/detail/voronoi_robust_fpt.hpp
==============================================================================
--- branches/release/boost/polygon/detail/voronoi_robust_fpt.hpp (original)
+++ branches/release/boost/polygon/detail/voronoi_robust_fpt.hpp 2012-09-18 17:13:41 EDT (Tue, 18 Sep 2012)
@@ -82,7 +82,9 @@
typedef _fpt relative_error_type;
// Rounding error is at most 1 EPS.
- static const relative_error_type ROUNDING_ERROR;
+ enum {
+ ROUNDING_ERROR = 1
+ };
robust_fpt() : fpv_(0.0), re_(0.0) {}
explicit robust_fpt(floating_point_type fpv) :
@@ -216,10 +218,6 @@
};
template <typename T>
-const typename robust_fpt<T>::relative_error_type
- robust_fpt<T>::ROUNDING_ERROR = 1;
-
-template <typename T>
robust_fpt<T> get_sqrt(const robust_fpt<T>& that) {
return that.sqrt();
}
@@ -435,10 +433,12 @@
template <typename _int, typename _fpt, typename _converter>
class robust_sqrt_expr {
public:
- 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;
+ enum MAX_RELATIVE_ERROR {
+ MAX_RELATIVE_ERROR_EVAL1 = 4,
+ MAX_RELATIVE_ERROR_EVAL2 = 7,
+ MAX_RELATIVE_ERROR_EVAL3 = 16,
+ MAX_RELATIVE_ERROR_EVAL4 = 25
+ };
// Evaluates expression (re = 4 EPS):
// A[0] * sqrt(B[0]).
@@ -499,19 +499,6 @@
_int tB[5];
_converter convert;
};
-
-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
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