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