realroot_doc 0.1.1
NISP< C > Struct Template Reference

Negative Inverse Sum bound for positive roots. More...

#include <univariate_bounds.hpp>

List of all members.

Static Public Member Functions


Detailed Description

template<class C>
struct mmx::NISP< C >

Negative Inverse Sum bound for positive roots.

Definition at line 56 of file univariate_bounds.hpp.


Member Function Documentation

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.

Parameters:
pUnivariate polynomials
NISPThe method that we use
See also:
bound_root

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;
    }

The documentation for this struct was generated from the following file: