BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Polynomial/internal/interval_arithmetic.h
Go to the documentation of this file.
00001 // Copyright (c) 2005  Stanford University (USA).
00002 // All rights reserved.
00003 //
00004 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License as
00006 // published by the Free Software Foundation; version 2.1 of the License.
00007 // See the file LICENSE.LGPL distributed with CGAL.
00008 //
00009 // Licensees holding a valid commercial license may use this file in
00010 // accordance with the commercial license agreement provided with the software.
00011 //
00012 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014 //
00015 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Kinetic_data_structures/include/CGAL/Polynomial/internal/interval_arithmetic.h $
00016 // $Id: interval_arithmetic.h 35777 2007-01-23 17:02:20Z drussel $
00017 // 
00018 //
00019 // Author(s)     : Daniel Russel <drussel@alumni.princeton.edu>
00020 
00021 #ifndef CGAL_POLYNOMIAL_TOOLS_INTERVAL_ARITHMETIC_H
00022 #define CGAL_POLYNOMIAL_TOOLS_INTERVAL_ARITHMETIC_H
00023 #include <CGAL/Polynomial/basic.h>
00024 #include <utility>
00025 
00032 #ifdef CGAL_POLYNOMIAL_USE_CGAL
00033 #include <CGAL/Interval_nt.h>
00034 #include <CGAL/double.h>
00035 #include <CGAL/int.h>
00036 
00037 CGAL_POLYNOMIAL_BEGIN_NAMESPACE
00039 
00043 typedef CGAL::Interval_nt_advanced Interval_nt;
00044 
00046 
00050 struct Interval_arithmetic_guard: public CGAL::Protect_FPU_rounding<true>{};
00051 /*struct Interval_arithmetic_guard {
00053   Interval_arithmetic_guard() {
00054     bk_= FPU_get_and_set_cw(CGAL_FE_UPWARD);
00055   };
00056   Interval_arithmetic_guard(bool b) {
00057     if (b){
00058       bk_= FPU_get_and_set_cw(CGAL_FE_UPWARD);
00059     } else {
00060       bk_= CGAL_FE_UPWARD;
00061     }
00062 }
00063 ~Interval_arithmetic_guard(){
00064 FPU_set_cw(bk_);
00065 }
00066 bool enabled() const {
00067 return bk_== CGAL_FE_UPWARD;
00068 }
00069 void set_enabled(bool ft) {
00070 if (ft != enabled()) {
00071 bk_= FPU_get_and_set_cw(bk_);
00072 }
00073 }
00074 protected:
00075 FPU_CW_t bk_;
00076 };*/
00077 
00078 template <class NT>
00079 class To_interval: public CGAL::To_interval<NT>
00080 {
00081     public:
00082         To_interval(){}
00083 };
00084 
00085 /*template <class NT>
00086 std::pair<double,double> to_interval(const NT&a){
00087   return CGAL::to_interval(a);
00088 }
00089 
00090 std::pair<double,double> to_interval(double d){
00091   return CGAL::to_interval(d);
00092   }*/
00093 
00094 //#define CGAL_POLYNOMIAL_TO_INTERVAL(nt) CGAL::to_interval(nt)
00095 /*template <class NT>
00096 std::pair<double, double> to_interval(const NT &nt){
00097   //bool to_interval_general;
00098   return CGAL::to_interval(nt);
00099   }*/
00100 //using CGAL::to_interval;
00101 
00102 namespace internal
00103 {
00104     template <class Traits> class Simple_interval_root;
00105     template <class R1, class R2> class Lazy_upper_bound_root_stack_root;
00106     template <class R> class Explicit_root;
00107 }
00108 
00109 
00110 CGAL_POLYNOMIAL_END_NAMESPACE
00111 
00112 
00113 #elif POLYNOMIAL_USE_BOOST_INTERVAL
00114 
00115 Not implemented yet.
00116 
00117 #else
00118 
00119 No interval arithmetic support.
00120 #endif
00121 
00122 CGAL_POLYNOMIAL_BEGIN_NAMESPACE
00123 
00124 inline Extended_sign extended_sign(const Interval_nt &i)
00125 {
00126     if (i.inf() == 0 && i.sup() ==0) return EXTENDED_ZERO;
00127     else if (i.inf() <=0 && i.sup() >=0) {
00128         return EXTENDED_UNKNOWN;
00129     }
00130     else if (i.inf() >0 ) {
00131         return EXTENDED_POSITIVE;
00132     }
00133     else {
00134         return EXTENDED_NEGATIVE;
00135     }
00136 }
00137 
00138 
00139 CGAL_POLYNOMIAL_END_NAMESPACE
00140 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines