From 3147e41e614b601108efebbdffe98a73410ef8fd Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 30 Apr 2010 16:25:32 +0000 Subject: [PATCH] Revert that patch: | ------------------------------------------------------------------------ | r55821 | drussel | 2010-04-29 04:19:59 +0200 (Thu, 29 Apr 2010) | 1 line | Changed paths: | M /trunk/Kinetic_data_structures/src/CGAL/numeric_solvers_support.cpp | | use the newish grand unified polynomial internally | ------------------------------------------------------------------------ Reasons are: - it uses C99 dynamic C arrays allocated on the stack instead of std::vector, - C99 dynamic C arrays are not in C++98 (they will probably be in C++0x), - g++ implements that as an extension, - VC++ does not, - that is in libCGAL, and for that reason the whole CGAL testsuite is red under Microsoft VC++. Suggestion (already emailed to Daniel): use std::vector instead of dynamic C arrays, and resubmit the patch. --- .../src/CGAL/numeric_solvers_support.cpp | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/Kinetic_data_structures/src/CGAL/numeric_solvers_support.cpp b/Kinetic_data_structures/src/CGAL/numeric_solvers_support.cpp index c6dcad43d84..e64c301c701 100644 --- a/Kinetic_data_structures/src/CGAL/numeric_solvers_support.cpp +++ b/Kinetic_data_structures/src/CGAL/numeric_solvers_support.cpp @@ -22,9 +22,10 @@ #include #include -#include -#include -#include +#include +#include +#include + /*#ifdef _MSC_VER #pragma warning(disable:1572) #endif*/ @@ -143,11 +144,9 @@ template //if (roots.back() > lb+eps) return; //typedef CGAL_POLYNOMIAL_NS::Polynomial Fn; - typedef Polynomial_type_generator::Type IFn; - typedef Polynomial_traits_d Traits; - Traits::Differentiate dx= Traits::Differentiate(); - Traits::Evaluate eval= Traits::Evaluate(); - Traits::Construct_polynomial construct= Traits::Construct_polynomial(); + + typedef CGAL_POLYNOMIAL_NS::Interval_polynomial IFn; + typedef CGAL_POLYNOMIAL_NS::internal::Derivative Diff; typedef typename IFn::NT INT; @@ -169,21 +168,17 @@ template vi = -*(end-1); } } else { - INT intcoefs[end-begin]; - for (unsigned int i=0; i< end-begin; ++i) { - intcoefs[i]= INT(*(begin+i)); - } - IFn fi= construct(intcoefs, intcoefs+(end-begin)); + IFn fi(begin, end); if (roots.empty()) { Interval_arithmetic_guard guard; if (ub== std::numeric_limits::infinity()) { vi = 10*lb + 1000; } else { - vi = eval(fi, (INT(lb)+INT(ub))/2.0); + vi = fi((INT(lb)+INT(ub))/2.0); } } else { Interval_arithmetic_guard guard; - vi = eval(fi,(INT(last_root)+INT(roots.back()))/2.0); + vi = fi((INT(last_root)+INT(roots.back()))/2.0); } } @@ -200,15 +195,16 @@ template return; } Interval_arithmetic_guard guard; + Diff dx; IFn f(begin, end); IFn d= dx(f); - INT dv= eval(f, roots.back()); + INT dv= d(roots.back()); // switch //while (sign(d(roots.back().representation()))== ZERO) d= dx_(d); while (dv.inf() <= 0 && dv.sup() >= 0) { d= dx(d); - dv= eval(d, roots.back()); + dv= d(roots.back()); } // switch //if (sign(d(roots.back().representation()))==POSITIVE){ @@ -251,11 +247,20 @@ jama_polynomial_compute_cleaned_roots(begin, end, lb, ub, roots); double evaluate_polynomial(const double *b, const double *e, double t) { - typedef Polynomial_type_generator::Type P; - typedef Polynomial_traits_d

Traits; - Traits::Evaluate eval= Traits::Evaluate(); - Traits::Construct_polynomial construct= Traits::Construct_polynomial(); - return eval(construct(b, e), t); +#ifdef POLYNOMIAL_USE_GSL + return gsl_evaluate_polynomial(b, e, t); +#else + if (b==e) return 0.0; + + const double *rit=e-1; + double result = *rit; + --rit; + for (; rit != b-1; --rit) { + result *= t; + result += (*rit); + } + return result; +#endif }