synaps/usolve/Algebraic.h

00001 // Copyright (c) 2003  INRIA Sophia-Antipolis (France) and
00002 //                     Department of Informatics and Telecommunications
00003 //                     University of Athens (Greece).
00004 // All rights reserved.
00005 //
00006 // Authors : Elias P. TSIGARIDAS <et@di.uoa.gr>
00007 //           Athanasios Kakargias <grad0460@di.uoa.gr>
00008 
00009 // Partially supported by INRIA's project <CALAMATA>, a
00010 // bilateral collaboration with National Kapodistrian University of
00011 // Athens.
00012 // Partially supported by the IST Programme of the EU as a Shared-cost
00013 // RTD (FET Open) Project under Contract No  IST-2000-26473
00014 // (ECG - Effective Computational Geometry for Curves and Surfaces)
00015 //
00016 
00017 #ifndef synaps_arithm_Algebraic_h
00018 #define synaps_arithm_Algebraic_h
00019 
00020 #include <synaps/init.h>
00021 #include <synaps/arithm/gmp.h>
00022 #include <synaps/usolve/Exclusion.h>
00023 #include <synaps/base/Seq.h>
00024 #include <map>
00025 
00026 #include <synaps/usolve/algebraic/Algebraic_config.h>
00027 #include <synaps/usolve/algebraic/root_of.h>
00028 #include <synaps/usolve/algebraic/Comparison.h>
00029 #include <synaps/usolve/algebraic/comparison/Compare_operators.h>
00030 #include <synaps/usolve/algebraic/comparison/Compare_RT_operators.h>
00031 #include <synaps/usolve/algebraic/comparison/Compare_FT_operators.h>
00032 
00033 #include <synaps/usolve/algebraic/sign_fct.h>
00034 #include <synaps/usolve/algebraic/MPoly_2_2.h>
00035 #include <synaps/usolve/algebraic/sign_fct_2.h>
00036 #include <synaps/usolve/algebraic/Method_name.h>
00037 #include <synaps/usolve/Sturm.h>
00038 #include <synaps/msolve/BSolver.h>
00039 #include <synaps/usolve/algebraic/Construct_rootof.h>
00040 
00041 
00042 #include <synaps/arithm/Interval.h>
00043 #include <synaps/arithm/traits.h>
00044 #include <synaps/upol/UPolDse.h>
00045 #include <synaps/usolve/sturm/solve_sturm.h>
00046 
00047 __BEGIN_NAMESPACE_SYNAPS
00048 
00049 
00050 template < class NT >
00051 struct Algebraic : public Small_degree<NT>
00052 {
00053     typedef Algebraic          self_t;
00054 };
00055 
00056 //----------------------------------------------------------------------
00057 template < class NT > inline
00058 Seq< typename Algebraic<NT>::RO_t > 
00059 solve( const typename Algebraic<NT>::Poly& f,
00060        Algebraic<NT>)
00061 {
00062     typedef Algebraic<NT>          K;
00063     typedef typename K::RO_t       RO_t;
00064     
00065     Seq<RO_t> sol;
00066    
00067     ALGEBRAIC::solve_sturm(f, std::back_inserter(sol.rep()), K());
00068 
00069     std::stable_sort( sol.begin(), sol.end(), ALGEBRAIC::Refine_compare());
00070     return sol;
00071 }
00072 
00073 
00074 template < class NT,
00075            class OutputIterator> inline
00076 OutputIterator
00077 solve( const typename Algebraic<NT>::Poly& f,
00078        OutputIterator it,
00079        Algebraic<NT>)
00080 {
00081     typedef Algebraic<NT>          K;
00082 
00083     return ALGEBRAIC::solve_sturm(f, it, K());
00084 }
00085 
00086 
00087 //----------------------------------------------------------------------
00088 template < class NT >  inline
00089 typename Algebraic<NT>::RO_t 
00090 solve( const typename Algebraic<NT>::Poly& f,  Algebraic<NT>, unsigned i)
00091 {
00092    typedef Algebraic<NT>          K;
00093    return solve( f, K())[i];
00094 }
00095 
00096 //----------------------------------------------------------------------
00097 template < class NT >  inline
00098 typename Sturm<NT>::RO_t 
00099 RootOf( const typename Algebraic<NT>::Poly& f, unsigned i, Algebraic<NT>)
00100 {
00101    typedef Algebraic<NT>          K;
00102    return solve( f, K())[i];
00103 }
00104 //----------------------------------------------------------------------
00105 
00106 template < class NT > inline
00107 int
00108 count_real_roots( const typename Algebraic<NT>::Poly& f, Algebraic<NT>)
00109 {
00110     typedef Algebraic<NT>          K;
00111     typedef typename K::RT            RT;
00112     typedef typename K::FT            FT;
00113     typedef typename K::FIT           FIT;
00114 
00115     SturmSeq<RT> sth( f, UPOLDAR::diff(f), SUBRES());
00116     FT b = bound<FT>( f, Cauchy());
00117     FT a = -b;
00118 
00119     return ( variation( sth, a) - variation( sth, b) );
00120 }
00121 
00122 __END_NAMESPACE_SYNAPS
00123 #endif // _SYNAPS_SOLVE_STURM_H_
00124 

SYNAPS DOCUMENTATION
logo