Use CGAL::abs instead of fabs

This commit is contained in:
Andreas Fabri 2011-02-16 15:51:53 +00:00
parent 93238731cd
commit 3326bf5316
7 changed files with 178 additions and 98 deletions

View File

@ -58,7 +58,7 @@ namespace CGAL { namespace internal { namespace Static_filters_predicates {
const FT& w
) const {
CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Compare_squared_radius_3 with 4 points", tmp);
using std::fabs;
Get_approx<Point_3> get_approx; // Identity functor for all points
// but lazy ones.
Get_approx<FT> get_approx_ft; // Identity functor for all FT
@ -115,41 +115,50 @@ namespace CGAL { namespace internal { namespace Static_filters_predicates {
double eps;
double_tmp_result = (((square( num_x ) + square( num_y )) + square( num_z )) - ((alpha * 4.00000000000000000000e+00) * square( den )));
double max1;
double max2 = fabs(qpy);
if( (max2 < fabs(qpz)) )
double aqpy = CGAL::abs(qpy);
double aqpz = CGAL::abs(qpz);
double arpy = CGAL::abs(rpy);
double arpz = CGAL::abs(rpz);
double aspy = CGAL::abs(spy);
double aspz = CGAL::abs(spz);
double max2 = CGAL::abs(qpy);
if( (max2 < aqpz) )
{
max2 = fabs(qpz);
max2 = aqpz;
}
if( (max2 < fabs(rpy)) )
if( (max2 < arpy) )
{
max2 = fabs(rpy);
max2 = arpy;
}
if( (max2 < fabs(rpz)) )
if( (max2 < arpz) )
{
max2 = fabs(rpz);
max2 = arpz;
}
if( (max2 < fabs(spy)) )
if( (max2 < aspy) )
{
max2 = fabs(spy);
max2 = aspy;
}
if( (max2 < fabs(spz)) )
if( (max2 < aspz) )
{
max2 = fabs(spz);
max2 = aspz;
}
max1 = max2;
if( (max1 < fabs(qpx)) )
if( (max1 < aqpx) )
{
max1 = fabs(qpx);
max1 = aqpx;
}
if( (max1 < fabs(rpx)) )
if( (max1 < arpx) )
{
max1 = fabs(rpx);
max1 = arpx;
}
if( (max1 < fabs(spx)) )
if( (max1 < aspx) )
{
max1 = fabs(spx);
max1 = aspx;
}
double max3 = fabs(alpha);
double max3 = aalpha;
double lower_bound_1;
double upper_bound_1;
lower_bound_1 = max1;
@ -204,8 +213,6 @@ namespace CGAL { namespace internal { namespace Static_filters_predicates {
) const {
CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Compare_squared_radius_3 with 3 points", tmp);
using std::fabs;
double px, py, pz, qx, qy, qz, sx, sy, sz, alpha;
if( fit_in_double(p.x(), px) && fit_in_double(p.y(), py) &&
fit_in_double(p.z(), pz) &&
@ -252,29 +259,36 @@ namespace CGAL { namespace internal { namespace Static_filters_predicates {
double eps;
double_tmp_result = (((square( num_x ) + square( num_y )) + square( num_z )) - ((alpha * 4.00000000000000000000e+00) * square( den )));
double max1;
double max2 = fabs(psx);
if( (max2 < fabs(psy)) )
double max2 = CGAL::abs(psx);
double apsy = CGAL::abs(psy);
double apsz = CGAL::abs(psz);
double aqsx = CGAL::abs(qsx);
double aqsy = CGAL::abs(qsy);
double aqsz = CGAL::abs(qsz);
if( (max2 < apsy) )
{
max2 = fabs(psy);
max2 = apsy;
}
if( (max2 < fabs(qsx)) )
if( (max2 < aqsx) )
{
max2 = fabs(qsx);
max2 = aqsx;
}
if( (max2 < fabs(qsy)) )
if( (max2 < aqsy) )
{
max2 = fabs(qsy);
max2 = aqsy;
}
max1 = max2;
if( (max1 < fabs(psz)) )
if( (max1 < apsz) )
{
max1 = fabs(psz);
max1 = apsz;
}
if( (max1 < fabs(qsz)) )
if( (max1 < aqsz) )
{
max1 = fabs(qsz);
max1 = aqsz;
}
double max3 = fabs(alpha);
double max3 = CGAL::abs(alpha);
double lower_bound_1;
double upper_bound_1;
lower_bound_1 = max1;
@ -330,8 +344,6 @@ namespace CGAL { namespace internal { namespace Static_filters_predicates {
) const {
CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Compare_squared_radius_3 with 2 points", tmp);
using std::fabs;
double px, py, pz, qx, qy, qz, alpha;
if( fit_in_double(p.x(), px) && fit_in_double(p.y(), py) &&
fit_in_double(p.z(), pz) &&
@ -348,16 +360,18 @@ namespace CGAL { namespace internal { namespace Static_filters_predicates {
double double_tmp_result;
double eps;
double_tmp_result = (((square( px_qx ) + square( py_qy )) + square( pz_qz )) - (alpha * 4.00000000000000000000e+00));
double max1 = fabs(px_qx);
if( (max1 < fabs(py_qy)) )
double max1 = CGAL::abs(px_qx);
double apy_qy = CGAL::abs(py_qy);
double apz_qz = CGAL::abs(pz_qz);
if( (max1 < apy_qy) )
{
max1 = fabs(py_qy);
max1 = apy_qy;
}
if( (max1 < fabs(pz_qz)) )
if( (max1 < apz_qz) )
{
max1 = fabs(pz_qz);
max1 = apz_qz;
}
double max2 = fabs(alpha);
double max2 = CGAL::abs(alpha);
//handwritten workaround to handle case of alpha=0 (variable alone in its group)
//if( ((max1 < 8.85464260923320109378e-147) || (max2 < 7.84046957372481590760e-293)) )

View File

@ -147,12 +147,19 @@ private:
prx, pry);
// Then semi-static filter.
double maxx = fabs(px);
if (maxx < fabs(qx)) maxx = fabs(qx);
if (maxx < fabs(rx)) maxx = fabs(rx);
double maxy = fabs(py);
if (maxy < fabs(qy)) maxy = fabs(qy);
if (maxy < fabs(ry)) maxy = fabs(ry);
double maxx = CGAL::abs(px);
double maxy = CGAL::abs(py);
double aqx = CGAL::abs(qx);
double aqy = CGAL::abs(qy);
double arx = CGAL::abs(rx);
double ary = CGAL::abs(ry);
if (maxx < aqx) maxx = aqx;
if (maxx < arx) maxx = arx;
if (maxy < aqy) maxy = aqy;
if (maxy < ary) maxy = ary;
double eps = 3.55271e-15 * maxx * maxy;
if (det > eps) return std::make_pair(true, POSITIVE);

View File

@ -105,18 +105,34 @@ public:
vx,vy,vz,v2);
// Compute the semi-static bound.
double maxx = fabs(px);
if (maxx < fabs(qx)) maxx = fabs(qx);
if (maxx < fabs(rx)) maxx = fabs(rx);
if (maxx < fabs(tx)) maxx = fabs(tx);
double maxy = fabs(py);
if (maxy < fabs(qy)) maxy = fabs(qy);
if (maxy < fabs(ry)) maxy = fabs(ry);
if (maxy < fabs(ty)) maxy = fabs(ty);
double maxz = fabs(pz);
if (maxz < fabs(qz)) maxz = fabs(qz);
if (maxz < fabs(rz)) maxz = fabs(rz);
if (maxz < fabs(tz)) maxz = fabs(tz);
double maxx = CGAL::abs(px);
double maxy = CGAL::abs(py);
double maxz = CGAL::abs(pz);
double aqx = CGAL::abs(qx);
double aqy = CGAL::abs(qy);
double aqz = CGAL::abs(qz);
double arx = CGAL::abs(rx);
double ary = CGAL::abs(ry);
double arz = CGAL::abs(rz);
double atx = CGAL::abs(tx);
double aty = CGAL::abs(ty);
double atz = CGAL::abs(tz);
if (maxx < aqx) maxx = aqx;
if (maxx < arx) maxx = arx;
if (maxx < atx) maxx = atx;
if (maxy < aqy) maxy = aqy;
if (maxy < ary) maxy = ary;
if (maxy < aty) maxy = aty;
if (maxz < aqz) maxz = aqz;
if (maxz < arz) maxz = arz;
if (maxz < atz) maxz = atz;
double d = std::max(maxx, std::max(maxy, maxz));
double eps = 3.27418e-11 * d * d * d * d * d * d;

View File

@ -82,10 +82,15 @@ public:
prx, pry);
// Then semi-static filter.
double maxx = std::fabs(pqx);
if (maxx < std::fabs(prx)) maxx = std::fabs(prx);
double maxy = std::fabs(pqy);
if (maxy < std::fabs(pry)) maxy = std::fabs(pry);
double maxx = CGAL::abs(pqx);
double maxy = CGAL::abs(pqy);
double aprx = CGAL::abs(prx);
double apry = CGAL::abs(pry);
if (maxx < aprx) maxx = aprx;
if (maxy < apry) maxy = apry;
// Sort them
if (maxx > maxy) std::swap(maxx, maxy);

View File

@ -69,7 +69,6 @@ public:
{
CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Orientation_3", tmp);
using std::fabs;
Get_approx<Point_3> get_approx; // Identity functor for all points
// but lazy points.
@ -96,16 +95,28 @@ public:
double psy = sy - py;
double psz = sz - pz;
// CGAL::abs uses fabs on platforms where it is faster than (a<0)?-a:a
// Then semi-static filter.
double maxx = fabs(pqx);
if (maxx < fabs(prx)) maxx = fabs(prx);
if (maxx < fabs(psx)) maxx = fabs(psx);
double maxy = fabs(pqy);
if (maxy < fabs(pry)) maxy = fabs(pry);
if (maxy < fabs(psy)) maxy = fabs(psy);
double maxz = fabs(pqz);
if (maxz < fabs(prz)) maxz = fabs(prz);
if (maxz < fabs(psz)) maxz = fabs(psz);
double maxx = CGAL::abs(pqx);
double maxy = CGAL::abs(pqy);
double maxz = CGAL::abs(pqz);
double aprx = CGAL::abs(prx);
double apsx = CGAL::abs(psx);
double apry = CGAL::abs(pry);
double apsy = CGAL::abs(psy);
double aprz = CGAL::abs(prz);
double apsz = CGAL::abs(psz);
if (maxx < aprx) maxx = aprx;
if (maxx < apsx) maxx = apsx;
if (maxy < apry) maxy = apry;
if (maxy < apsy) maxy = apsy;
if (maxz < aprz) maxz = aprz;
if (maxz < apsz) maxz = apsz;
double det = CGAL::determinant(pqx, pqy, pqz,
prx, pry, prz,
psx, psy, psz);

View File

@ -41,7 +41,6 @@ public:
{
CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Side_of_oriented_circle_2", tmp);
using std::fabs;
Get_approx<Point_2> get_approx; // Identity functor for all points
// but lazy points.
@ -70,16 +69,30 @@ public:
qpx*rpy - qpy*rpx, rpx*rqx + rpy*rqy);
// We compute the semi-static bound.
double maxx = fabs(qpx);
if (maxx < fabs(rpx)) maxx = fabs(rpx);
if (maxx < fabs(tpx)) maxx = fabs(tpx);
if (maxx < fabs(tqx)) maxx = fabs(tqx);
if (maxx < fabs(rqx)) maxx = fabs(rqx);
double maxy = fabs(qpy);
if (maxy < fabs(rpy)) maxy = fabs(rpy);
if (maxy < fabs(tpy)) maxy = fabs(tpy);
if (maxy < fabs(tqy)) maxy = fabs(tqy);
if (maxy < fabs(rqy)) maxy = fabs(rqy);
double maxx = CGAL::abs(qpx);
double maxy = CGAL::abs(qpy);
double arpx = CGAL::abs(rpx);
double arpy = CGAL::abs(rpy);
double atqx = CGAL::abs(tqx);
double atqy = CGAL::abs(tqy);
double atpx = CGAL::abs(tpx);
double atpy = CGAL::abs(tpy);
double arqx = CGAL::abs(rqx);
double arqy = CGAL::abs(rqy);
if (maxx < arpx) maxx = arpx;
if (maxx < atpx) maxx = atpx;
if (maxx < atqx) maxx = atqx;
if (maxx < arqx) maxx = arqx;
if (maxy < arpy) maxy = arpy;
if (maxy < atpy) maxy = atpy;
if (maxy < atqy) maxy = atqy;
if (maxy < arqy) maxy = arqy;
if (maxx > maxy) std::swap(maxx, maxy);

View File

@ -42,7 +42,6 @@ public:
{
CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Side_of_oriented_sphere_3", tmp);
using std::fabs;
Get_approx<Point_3> get_approx; // Identity functor for all points
// but lazy points.
@ -74,7 +73,7 @@ public:
double rtx = rx - tx;
double rty = ry - ty;
double rtz = rz - tz;
double rt2 = CGAL_NTS square(rtx) + CGAL_NTS square(rty)
double rt2 = CGAL_NTS square(rtx) + CGAL_NTS square(rty)
+ CGAL_NTS square(rtz);
double stx = sx - tx;
double sty = sy - ty;
@ -83,18 +82,33 @@ public:
+ CGAL_NTS square(stz);
// Compute the semi-static bound.
double maxx = fabs(ptx);
if (maxx < fabs(qtx)) maxx = fabs(qtx);
if (maxx < fabs(rtx)) maxx = fabs(rtx);
if (maxx < fabs(stx)) maxx = fabs(stx);
double maxy = fabs(pty);
if (maxy < fabs(qty)) maxy = fabs(qty);
if (maxy < fabs(rty)) maxy = fabs(rty);
if (maxy < fabs(sty)) maxy = fabs(sty);
double maxz = fabs(ptz);
if (maxz < fabs(qtz)) maxz = fabs(qtz);
if (maxz < fabs(rtz)) maxz = fabs(rtz);
if (maxz < fabs(stz)) maxz = fabs(stz);
double maxx = CGAL::abs(ptx);
double maxy = CGAL::abs(pty);
double maxz = CGAL::abs(ptz);
double aqtx = CGAL::abs(qtx);
double artx = CGAL::abs(rtx);
double astx = CGAL::abs(stx);
double aqty = CGAL::abs(qty);
double arty = CGAL::abs(rty);
double asty = CGAL::abs(sty);
double aqtz = CGAL::abs(qtz);
double artz = CGAL::abs(rtz);
double astz = CGAL::abs(stz);
if (maxx < aqtx) maxx = aqtx;
if (maxx < artx) maxx = artx;
if (maxx < astx) maxx = astx;
if (maxy < aqty) maxy = aqty;
if (maxy < arty) maxy = arty;
if (maxy < asty) maxy = asty;
if (maxz < aqtz) maxz = aqtz;
if (maxz < artz) maxz = artz;
if (maxz < astz) maxz = astz;
// Sort maxx < maxy < maxz.
if (maxx > maxz)