Negative Inverse Sum bound for positive roots. More...
#include <univariate_bounds.hpp>
Negative Inverse Sum bound for positive roots.
Definition at line 57 of file univariate_bounds.hpp.
static C lower_bound | ( | const POLY & | p | ) | [inline, static] |
Definition at line 114 of file univariate_bounds.hpp.
References C, mmx::degree(), mmx::univariate::degree(), mmx::denominator(), mmx::numerator(), mmx::reverse(), and NISP< C >::upper_bound().
00115 { 00116 typedef typename texp::rationalof<C>::T rational; 00117 using univariate::degree; 00118 00119 POLY r(p); 00120 reverse(r,degree(r)); 00121 rational m = NISP<rational>::upper_bound(r); 00122 return denominator(m)/numerator(m); 00123 }
static C upper_bound | ( | const POLY & | p | ) | [inline, static] |
Computes the "Negative Inverse Sum" bound for the positive roots.
p | Univariate polynomials |
Definition at line 68 of file univariate_bounds.hpp.
References C, mmx::max(), and mmx::vctops::sum().
Referenced by NISP< C >::lower_bound().
00069 { 00070 typedef typename texp::rationalof<C>::T rational; 00071 // typedef typename NTR::T FT; 00072 //typedef double FT; 00073 C max(0), sum(0); 00074 00075 unsigned i; 00076 unsigned n = p.size(); 00077 00078 // check the degree 00079 i = n; while ( p[--i] == 0 ) ; n = i+1; 00080 if ( p[i] > 0 ) 00081 { 00082 i = 0; 00083 while ( p[i] > 0 && i < n ) i++; 00084 if ( i == n ) return 0; 00085 00086 for ( unsigned k = i+1; k < n; k ++ ) 00087 if ( p[k] > 0 ) sum += p[k]; 00088 00089 for ( unsigned k = i; k < n; k ++ ) 00090 { 00091 if ( p[k] < 0 ) 00092 { rational tmp = -p[k]/sum; if ( tmp > max ) max = tmp; } 00093 else 00094 sum -= p[k]; 00095 }; 00096 } 00097 else 00098 { 00099 i = 0; 00100 while ( p[i] < 0 && i < n ) i++; 00101 if ( i == n ) return 0; 00102 for ( unsigned k = i+1; k < n; k ++ ) 00103 if ( p[k] < 0 ) sum += p[k]; 00104 for ( unsigned k = i; k < n; k ++ ) 00105 if ( p[k] > 0 ) { rational tmp = -p[k]/sum; if ( tmp > max ) max = tmp; } 00106 else sum -= p[k]; 00107 }; 00108 max += 1; 00109 return max; 00110 }