realroot_doc 0.1.1
|
00001 /******************************************************************* 00002 * This file is part of the source code of the realroot kernel. 00003 * Author(s): B. Mourrain, GALAAD, INRIA 00004 ********************************************************************/ 00005 # ifndef realroot_solver_hpp 00006 # define realroot_solver_hpp 00007 # include <realroot/subdivisor.hpp> 00008 //==================================================================== 00057 //==================================================================== 00058 namespace mmx { 00059 00060 #define solver_default_precision 20 00061 00062 template<class C, class MTH> struct solver_of { 00063 typedef typename MTH::Cell Cell; 00064 typedef typename MTH::Strategy Strategy; 00065 typedef typename MTH::Solutions Solutions; 00066 00067 } ; 00068 00069 template<class C,class M> struct solver { 00070 typedef solver_of<C,M> MTH; 00071 typedef typename MTH::Cell Cell; 00072 typedef typename MTH::Strategy Strategy; 00073 typedef typename MTH::Solutions Solutions; 00074 00075 template<class POL> static Solutions 00076 solve(const POL& p) { 00077 Cell* c = new Cell(p); 00078 subdivisor<Cell, Strategy> slv(c); 00079 slv.run(); 00080 return slv.solutions(); 00081 } 00082 00083 template<class POL, class DOM> static Solutions 00084 solve(const POL& p, const DOM& dmn) { 00085 Cell* c = new Cell(p,dmn); 00086 subdivisor<Cell, Strategy> slv(c); 00087 slv.run(); 00088 return slv.solutions(); 00089 } 00090 }; 00091 00092 struct Isolate 00093 { 00094 static const bool isole=true; 00095 }; 00096 struct Approximate 00097 { 00098 static const bool isole=false; 00099 double eps; 00100 Approximate(): eps(1e-6) {} 00101 Approximate(double e): eps(e) {} 00102 }; 00103 00104 // template<class R, class MTH> struct solver; 00105 00106 template<class POL, class SLV> typename solver<typename POL::Scalar,SLV>::Solutions 00107 solve(const POL& p, const SLV& s) { 00108 typedef solver<typename POL::Scalar,SLV> solver_t; 00109 typename solver<typename POL::Scalar,SLV>::Solutions sol; 00110 solver_t::solve(sol,p); 00111 return sol; 00112 } 00113 00114 template<class POL, class SLV> 00115 typename solver<typename POL::Scalar,SLV>::Solutions 00116 solve(const POL& p, SLV& s) { 00117 typedef solver<typename POL::Scalar,SLV> solver_t; 00118 typename solver<typename POL::Scalar,SLV>::Solutions sol; 00119 solver_t::solve(sol,p); 00120 return sol; 00121 } 00122 00123 00124 template<class POL,class SLV,class Domain> 00125 typename solver<typename POL::Scalar,SLV>::Solutions 00126 solve(const POL& p, const SLV& s, const Domain& D) { 00127 typedef solver<typename POL::Scalar,SLV> solver_t; 00128 typename solver<typename POL::Scalar,SLV>::Solutions sol; 00129 solver_t::solve(sol,p,D); 00130 return sol; 00131 } 00132 00133 template<class POL,class SLV,class Domain1, class Domain2> 00134 typename solver<typename POL::Scalar,SLV>::Solutions 00135 solve(const POL& p, const SLV& s, const Domain1& D1, const Domain2& D2) { 00136 typedef solver<typename POL::Scalar,SLV> solver_t; 00137 typename solver<typename POL::Scalar,SLV>::Solutions sol; 00138 solver_t::solve(sol,p,D1,D2); 00139 return sol; 00140 } 00141 00142 00143 } 00144 //==================================================================== 00145 #endif //realroot_solver_hpp