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