00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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