realroot_doc 0.1.1
|
00001 /***************************************************************************** 00002 * M a t h e m a g i x 00003 ***************************************************************************** 00004 * cell for bernstein systems 00005 * 2010-02-16 00006 ***************************************************************************** 00007 * Copyright (C) 2010 INRIA Sophia-Antipolis 00008 ***************************************************************************** 00009 * Comments : 00010 ****************************************************************************/ 00011 # ifndef realroot_subdivisor_mv_binary_hpp 00012 # define realroot_subdivisor_mv_binary_hpp 00013 00014 #include <realroot/tensor_bernstein.hpp> 00015 #include <realroot/subdivisor.hpp> 00016 //==================================================================== 00017 namespace mmx { 00018 00019 struct mv_binary_approx { 00020 00021 static double m_eps; 00022 00023 template<class Cell, class Stack> 00024 static void subdivide(Cell* cl, Stack* stack); 00025 00026 template<class Cell> 00027 static bool reduce(Cell* cl); 00028 00029 template<class Cell> 00030 static bool regular(Cell* cl); 00031 00032 } ; 00033 00034 double mv_binary_approx::m_eps=1e-6; 00035 00036 template<class Cell, class Stack> void 00037 mv_binary_approx::subdivide(Cell* cl, Stack* st) { 00038 //std::cout<<"Subdivide "<<cl->equation(0)<< " "<<cl->domain(0)<<std::endl; 00039 00040 Cell* left = new Cell(*cl); 00041 Cell* right = new Cell(*cl); 00042 00043 unsigned v=0; 00044 typename Cell::Scalar s=cl->domain(0).upper()-cl->domain(0).lower(),s0; 00045 for (unsigned i=0;i<cl->nbvar();i++) 00046 if((s0=cl->domain(i).upper()-cl->domain(i).lower())>s) { 00047 s=s0;v=i; 00048 } 00049 typename Cell::Scalar m=(cl->domain(v).upper()+cl->domain(v).lower())/2; 00050 00051 for (unsigned i=0;i<cl->nbeq();i++) 00052 tensor::split(left->equation(i), right->equation(i), v); 00053 left->domain(v).upper()=m; 00054 right->domain(v).lower()=m; 00055 00056 // std::cout<<"==> "<<left->equation(0)<< " "<<left->domain(0)<<std::endl; 00057 // std::cout<<"==> "<<right->equation(0)<< " "<<right->domain(0)<<std::endl; 00058 // std::cout<<std::endl; 00059 00060 st->push(left); 00061 st->push(right); 00062 }; 00063 00064 template<class Cell> bool 00065 mv_binary_approx::reduce(Cell* cl) { 00066 if(cl->size() < m_eps) return false; 00067 for(unsigned i=0;i<cl->nbeq();i++) 00068 if(!has_sign_variation(cl->equation(i))) return false; 00069 return true; 00070 } 00071 00072 template<class Cell> bool 00073 mv_binary_approx::regular(Cell* cl) { 00074 for(unsigned i=0;i<cl->nbeq();i++) 00075 if(!has_sign_variation(cl->equation(i))) return false; 00076 return true; 00077 } 00078 00079 //-------------------------------------------------------------------- 00080 struct mv_binary_isolate: mv_binary_approx { 00081 00082 template<class Cell> 00083 static bool reduce(Cell* cl); 00084 00085 } ; 00086 00087 template<class Cell> bool 00088 mv_binary_isolate::reduce(Cell* cl) { 00089 if(cl->size() < m_eps) return false; 00090 std::cout<<"isolate"<<std::endl; 00091 for(unsigned i=0;i<cl->nbeq();i++) 00092 if(!has_sign_variation(cl->equation(i))) return false; 00093 00094 return true; 00095 } 00096 00097 //==================================================================== 00098 } // namespace mmx 00099 //==================================================================== 00100 # endif