realroot_doc 0.1.1
|
Negative Inverse Sum bound for positive roots. More...
#include <univariate_bounds.hpp>
Negative Inverse Sum bound for positive roots.
Definition at line 56 of file univariate_bounds.hpp.
static C lower_bound | ( | const POLY & | p | ) | [inline, static] |
Definition at line 114 of file univariate_bounds.hpp.
References mmx::degree(), mmx::denominator(), mmx::numerator(), mmx::reverse(), and NISP< C >::upper_bound().
{ typedef typename texp::rationalof<C>::T rational; using univariate::degree; POLY r(p); reverse(r,degree(r)); rational m = NISP<rational>::upper_bound(r); return denominator(m)/numerator(m); }
static C upper_bound | ( | const POLY & | p | ) | [inline, static] |
Computes the "Negative Inverse Sum" bound for the positive roots.
p | Univariate polynomials |
NISP | The method that we use |
Definition at line 68 of file univariate_bounds.hpp.
References mmx::max(), and mmx::vctops::sum().
Referenced by NISP< C >::lower_bound().
{ typedef typename texp::rationalof<C>::T rational; // typedef typename NTR::T FT; //typedef double FT; C max(0), sum(0); unsigned i; unsigned n = p.size(); // check the degree i = n; while ( p[--i] == 0 ) ; n = i+1; if ( p[i] > 0 ) { i = 0; while ( p[i] > 0 && i < n ) i++; if ( i == n ) return 0; for ( unsigned k = i+1; k < n; k ++ ) if ( p[k] > 0 ) sum += p[k]; for ( unsigned k = i; k < n; k ++ ) { if ( p[k] < 0 ) { rational tmp = -p[k]/sum; if ( tmp > max ) max = tmp; } else sum -= p[k]; }; } else { i = 0; while ( p[i] < 0 && i < n ) i++; if ( i == n ) return 0; for ( unsigned k = i+1; k < n; k ++ ) if ( p[k] < 0 ) sum += p[k]; for ( unsigned k = i; k < n; k ++ ) if ( p[k] > 0 ) { rational tmp = -p[k]/sum; if ( tmp > max ) max = tmp; } else sum -= p[k]; }; max += 1; return max; }