vtkPolynomialSolversUnivariate Class Reference

#include <vtkPolynomialSolversUnivariate.h>

Inheritance diagram for vtkPolynomialSolversUnivariate:

Inheritance graph
[legend]
Collaboration diagram for vtkPolynomialSolversUnivariate:

Collaboration graph
[legend]

List of all members.


Detailed Description

polynomial solvers

vtkPolynomialSolversUnivariate provides solvers for univariate polynomial equations with real coefficients. The Tartaglia-Cardan and Ferrari solvers work on polynomials of fixed degree 3 and 4, respectively. The Lin-Bairstow and Sturm solvers work on polynomials of arbitrary degree. The Sturm solver is the most robust solver but only reports roots within an interval and does not report multiplicities. The Lin-Bairstow solver reports multiplicities.

For difficult polynomials, you may wish to use FilterRoots to eliminate some of the roots reported by the Sturm solver. FilterRoots evaluates the derivatives near each root to eliminate cases where a local minimum or maximum is close to zero.

Thanks:
Thanks to Philippe Pebay, Korben Rusek, and Maurice Rojas for implementing these solvers.
Tests:
vtkPolynomialSolversUnivariate (Tests)

Definition at line 56 of file vtkPolynomialSolversUnivariate.h.


Public Types

typedef vtkObject Superclass

Public Member Functions

virtual const char * GetClassName ()
virtual int IsA (const char *type)
void PrintSelf (ostream &os, vtkIndent indent)

Static Public Member Functions

static
vtkPolynomialSolversUnivariate
New ()
static int IsTypeOf (const char *type)
static
vtkPolynomialSolversUnivariate
SafeDownCast (vtkObject *o)
static ostream & PrintPolynomial (ostream &os, double *P, int degP)
static int LinBairstowSolve (double *c, int d, double *r, double &tolerance)
static int FerrariSolve (double *c, double *r, int *m, double tol)
static int TartagliaCardanSolve (double *c, double *r, int *m, double tol)
static int HabichtBisectionSolve (double *P, int d, double *a, double *upperBnds, double tol)
static int HabichtBisectionSolve (double *P, int d, double *a, double *upperBnds, double tol, int intervalType)
static int HabichtBisectionSolve (double *P, int d, double *a, double *upperBnds, double tol, int intervalType, bool divideGCD)
static int SturmBisectionSolve (double *P, int d, double *a, double *upperBnds, double tol)
static int SturmBisectionSolve (double *P, int d, double *a, double *upperBnds, double tol, int intervalType)
static int SturmBisectionSolve (double *P, int d, double *a, double *upperBnds, double tol, int intervalType, bool divideGCD)
static int FilterRoots (double *P, int d, double *upperBnds, int rootcount, double diameter)
static void SetDivisionTolerance (double tol)
static double GetDivisionTolerance ()

Protected Member Functions

 vtkPolynomialSolversUnivariate ()
 ~vtkPolynomialSolversUnivariate ()

Static Protected Attributes

static double DivisionTolerance

Member Typedef Documentation

Reimplemented from vtkObject.

Definition at line 60 of file vtkPolynomialSolversUnivariate.h.


Constructor & Destructor Documentation

vtkPolynomialSolversUnivariate::vtkPolynomialSolversUnivariate (  )  [inline, protected]

Definition at line 188 of file vtkPolynomialSolversUnivariate.h.

vtkPolynomialSolversUnivariate::~vtkPolynomialSolversUnivariate (  )  [inline, protected]

Definition at line 189 of file vtkPolynomialSolversUnivariate.h.


Member Function Documentation

static vtkPolynomialSolversUnivariate* vtkPolynomialSolversUnivariate::New (  )  [static]

Create an object with Debug turned off, modified time initialized to zero, and reference counting on.

Reimplemented from vtkObject.

virtual const char* vtkPolynomialSolversUnivariate::GetClassName (  )  [virtual]

Reimplemented from vtkObject.

static int vtkPolynomialSolversUnivariate::IsTypeOf ( const char *  name  )  [static]

Return 1 if this class type is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeRevisionMacro found in vtkSetGet.h.

Reimplemented from vtkObject.

virtual int vtkPolynomialSolversUnivariate::IsA ( const char *  name  )  [virtual]

Return 1 if this class is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeRevisionMacro found in vtkSetGet.h.

Reimplemented from vtkObject.

static vtkPolynomialSolversUnivariate* vtkPolynomialSolversUnivariate::SafeDownCast ( vtkObject o  )  [static]

Reimplemented from vtkObject.

void vtkPolynomialSolversUnivariate::PrintSelf ( ostream &  os,
vtkIndent  indent 
) [virtual]

Methods invoked by print to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkObject.

static ostream& vtkPolynomialSolversUnivariate::PrintPolynomial ( ostream &  os,
double *  P,
int  degP 
) [static]

static int vtkPolynomialSolversUnivariate::HabichtBisectionSolve ( double *  P,
int  d,
double *  a,
double *  upperBnds,
double  tol 
) [static]

Finds all REAL roots (within tolerance tol) of the d -th degree polynomial

\[ P[0] X^d + ... + P[d-1] X + P[d] \]

in ]a[0] ; a[1]] using the Habicht sequence (polynomial coefficients are REAL) and returns the count nr. All roots are bracketed in the first ]upperBnds[i] - tol ; upperBnds[i]] intervals. Returns -1 if anything went wrong (such as: polynomial does not have degree d, the interval provided by the other is absurd, etc.). intervalType specifies the search interval as follows: 0 = 00 = ]a,b[ 1 = 10 = [a,b[ 2 = 01 = ]a,b] 3 = 11 = [a,b] This defaults to 0. The last non-zero item in the Habicht sequence is the gcd of P and P'. The parameter divideGCD specifies whether the program should attempt to divide by the gcd and run again. It works better with polynomials known to have high multiplicities. When divideGCD != 0 then it attempts to divide by the GCD, if applicable. This defaults to 0. Compared to the Sturm solver the Habicht solver is slower, although both are O(d^2). The Habicht solver has the added benefit that it has a built in mechanism to keep the leading coefficients of the result from polynomial division bounded above and below in absolute value. This will tend to keep the coefficients of the polynomials in the sequence from zeroing out prematurely or becoming infinite. Constructing the Habicht sequence is O(d^2) in both time and space. Warning: it is the user's responsibility to make sure the upperBnds array is large enough to contain the maximal number of expected roots. Note that nr is smaller or equal to the actual number of roots in ]a[0] ; a[1]] since roots within are lumped in the same bracket. array is large enough to contain the maximal number of expected upper bounds.

static int vtkPolynomialSolversUnivariate::HabichtBisectionSolve ( double *  P,
int  d,
double *  a,
double *  upperBnds,
double  tol,
int  intervalType 
) [static]

Finds all REAL roots (within tolerance tol) of the d -th degree polynomial

\[ P[0] X^d + ... + P[d-1] X + P[d] \]

in ]a[0] ; a[1]] using the Habicht sequence (polynomial coefficients are REAL) and returns the count nr. All roots are bracketed in the first ]upperBnds[i] - tol ; upperBnds[i]] intervals. Returns -1 if anything went wrong (such as: polynomial does not have degree d, the interval provided by the other is absurd, etc.). intervalType specifies the search interval as follows: 0 = 00 = ]a,b[ 1 = 10 = [a,b[ 2 = 01 = ]a,b] 3 = 11 = [a,b] This defaults to 0. The last non-zero item in the Habicht sequence is the gcd of P and P'. The parameter divideGCD specifies whether the program should attempt to divide by the gcd and run again. It works better with polynomials known to have high multiplicities. When divideGCD != 0 then it attempts to divide by the GCD, if applicable. This defaults to 0. Compared to the Sturm solver the Habicht solver is slower, although both are O(d^2). The Habicht solver has the added benefit that it has a built in mechanism to keep the leading coefficients of the result from polynomial division bounded above and below in absolute value. This will tend to keep the coefficients of the polynomials in the sequence from zeroing out prematurely or becoming infinite. Constructing the Habicht sequence is O(d^2) in both time and space. Warning: it is the user's responsibility to make sure the upperBnds array is large enough to contain the maximal number of expected roots. Note that nr is smaller or equal to the actual number of roots in ]a[0] ; a[1]] since roots within are lumped in the same bracket. array is large enough to contain the maximal number of expected upper bounds.

static int vtkPolynomialSolversUnivariate::HabichtBisectionSolve ( double *  P,
int  d,
double *  a,
double *  upperBnds,
double  tol,
int  intervalType,
bool  divideGCD 
) [static]

Finds all REAL roots (within tolerance tol) of the d -th degree polynomial

\[ P[0] X^d + ... + P[d-1] X + P[d] \]

in ]a[0] ; a[1]] using the Habicht sequence (polynomial coefficients are REAL) and returns the count nr. All roots are bracketed in the first ]upperBnds[i] - tol ; upperBnds[i]] intervals. Returns -1 if anything went wrong (such as: polynomial does not have degree d, the interval provided by the other is absurd, etc.). intervalType specifies the search interval as follows: 0 = 00 = ]a,b[ 1 = 10 = [a,b[ 2 = 01 = ]a,b] 3 = 11 = [a,b] This defaults to 0. The last non-zero item in the Habicht sequence is the gcd of P and P'. The parameter divideGCD specifies whether the program should attempt to divide by the gcd and run again. It works better with polynomials known to have high multiplicities. When divideGCD != 0 then it attempts to divide by the GCD, if applicable. This defaults to 0. Compared to the Sturm solver the Habicht solver is slower, although both are O(d^2). The Habicht solver has the added benefit that it has a built in mechanism to keep the leading coefficients of the result from polynomial division bounded above and below in absolute value. This will tend to keep the coefficients of the polynomials in the sequence from zeroing out prematurely or becoming infinite. Constructing the Habicht sequence is O(d^2) in both time and space. Warning: it is the user's responsibility to make sure the upperBnds array is large enough to contain the maximal number of expected roots. Note that nr is smaller or equal to the actual number of roots in ]a[0] ; a[1]] since roots within are lumped in the same bracket. array is large enough to contain the maximal number of expected upper bounds.

static int vtkPolynomialSolversUnivariate::SturmBisectionSolve ( double *  P,
int  d,
double *  a,
double *  upperBnds,
double  tol 
) [static]

Finds all REAL roots (within tolerance tol) of the d -th degree polynomial P[0] X^d + ... + P[d-1] X + P[d] in ]a[0] ; a[1]] using Sturm's theorem ( polynomial coefficients are REAL ) and returns the count nr. All roots are bracketed in the first ]upperBnds[i] - tol ; upperBnds[i]] intervals. Returns -1 if anything went wrong (such as: polynomial does not have degree d, the interval provided by the other is absurd, etc.). intervalType specifies the search interval as follows: 0 = 00 = ]a,b[ 1 = 10 = [a,b[ 2 = 01 = ]a,b] 3 = 11 = [a,b] This defaults to 0. The last non-zero item in the Sturm sequence is the gcd of P and P'. The parameter divideGCD specifies whether the program should attempt to divide by the gcd and run again. It works better with polynomials known to have high multiplicities. When divideGCD != 0 then it attempts to divide by the GCD, if applicable. This defaults to 0. Constructing the Sturm sequence is O(d^2) in both time and space. Warning: it is the user's responsibility to make sure the upperBnds array is large enough to contain the maximal number of expected roots. Note that nr is smaller or equal to the actual number of roots in ]a[0] ; a[1]] since roots within are lumped in the same bracket. array is large enough to contain the maximal number of expected upper bounds.

static int vtkPolynomialSolversUnivariate::SturmBisectionSolve ( double *  P,
int  d,
double *  a,
double *  upperBnds,
double  tol,
int  intervalType 
) [static]

Finds all REAL roots (within tolerance tol) of the d -th degree polynomial P[0] X^d + ... + P[d-1] X + P[d] in ]a[0] ; a[1]] using Sturm's theorem ( polynomial coefficients are REAL ) and returns the count nr. All roots are bracketed in the first ]upperBnds[i] - tol ; upperBnds[i]] intervals. Returns -1 if anything went wrong (such as: polynomial does not have degree d, the interval provided by the other is absurd, etc.). intervalType specifies the search interval as follows: 0 = 00 = ]a,b[ 1 = 10 = [a,b[ 2 = 01 = ]a,b] 3 = 11 = [a,b] This defaults to 0. The last non-zero item in the Sturm sequence is the gcd of P and P'. The parameter divideGCD specifies whether the program should attempt to divide by the gcd and run again. It works better with polynomials known to have high multiplicities. When divideGCD != 0 then it attempts to divide by the GCD, if applicable. This defaults to 0. Constructing the Sturm sequence is O(d^2) in both time and space. Warning: it is the user's responsibility to make sure the upperBnds array is large enough to contain the maximal number of expected roots. Note that nr is smaller or equal to the actual number of roots in ]a[0] ; a[1]] since roots within are lumped in the same bracket. array is large enough to contain the maximal number of expected upper bounds.

static int vtkPolynomialSolversUnivariate::SturmBisectionSolve ( double *  P,
int  d,
double *  a,
double *  upperBnds,
double  tol,
int  intervalType,
bool  divideGCD 
) [static]

Finds all REAL roots (within tolerance tol) of the d -th degree polynomial P[0] X^d + ... + P[d-1] X + P[d] in ]a[0] ; a[1]] using Sturm's theorem ( polynomial coefficients are REAL ) and returns the count nr. All roots are bracketed in the first ]upperBnds[i] - tol ; upperBnds[i]] intervals. Returns -1 if anything went wrong (such as: polynomial does not have degree d, the interval provided by the other is absurd, etc.). intervalType specifies the search interval as follows: 0 = 00 = ]a,b[ 1 = 10 = [a,b[ 2 = 01 = ]a,b] 3 = 11 = [a,b] This defaults to 0. The last non-zero item in the Sturm sequence is the gcd of P and P'. The parameter divideGCD specifies whether the program should attempt to divide by the gcd and run again. It works better with polynomials known to have high multiplicities. When divideGCD != 0 then it attempts to divide by the GCD, if applicable. This defaults to 0. Constructing the Sturm sequence is O(d^2) in both time and space. Warning: it is the user's responsibility to make sure the upperBnds array is large enough to contain the maximal number of expected roots. Note that nr is smaller or equal to the actual number of roots in ]a[0] ; a[1]] since roots within are lumped in the same bracket. array is large enough to contain the maximal number of expected upper bounds.

static int vtkPolynomialSolversUnivariate::FilterRoots ( double *  P,
int  d,
double *  upperBnds,
int  rootcount,
double  diameter 
) [static]

This uses the derivative sequence to filter possible roots of a polynomial. First it sorts the roots and removes any duplicates. If the number of sign changes of the derivative sequence at a root at upperBnds[i] == that at upperBnds[i] - diameter then the i^th value is removed from upperBnds. It returns the new number of roots.

static int vtkPolynomialSolversUnivariate::LinBairstowSolve ( double *  c,
int  d,
double *  r,
double &  tolerance 
) [static]

Seeks all REAL roots of the d -th degree polynomial c[0] X^d + ... + c[d-1] X + c[d] = 0 equation Lin-Bairstow's method ( polynomial coefficients are REAL ) and stores the nr roots found ( multiple roots are multiply stored ) in r. tolerance is the user-defined solver tolerance; this variable may be relaxed by the iterative solver if needed. Returns nr. Warning: it is the user's responsibility to make sure the r array is large enough to contain the maximal number of expected roots.

static int vtkPolynomialSolversUnivariate::FerrariSolve ( double *  c,
double *  r,
int *  m,
double  tol 
) [static]

Algebraically extracts REAL roots of the quartic polynomial with REAL coefficients X^4 + c[0] X^3 + c[1] X^2 + c[2] X + c[3] and stores them (when they exist) and their respective multiplicities in the r and m arrays, based on Ferrari's method. Some numerical noise can be filtered by the use of a tolerance tol instead of equality with 0 (one can use, e.g., VTK_DBL_EPSILON). Returns the number of roots. Warning: it is the user's responsibility to pass a non-negative tol.

static int vtkPolynomialSolversUnivariate::TartagliaCardanSolve ( double *  c,
double *  r,
int *  m,
double  tol 
) [static]

Algebraically extracts REAL roots of the cubic polynomial with REAL coefficients X^3 + c[0] X^2 + c[1] X + c[2] and stores them (when they exist) and their respective multiplicities in the r and m arrays. Some numerical noise can be filtered by the use of a tolerance tol instead of equality with 0 (one can use, e.g., VTK_DBL_EPSILON). The main differences with SolveCubic are that (1) the polynomial must have unit leading coefficient, (2) complex roots are discarded upfront, (3) non-simple roots are stored only once, along with their respective multiplicities, and (4) some numerical noise is filtered by the use of relative tolerance instead of equality with 0. Returns the number of roots. In memoriam Niccolo Tartaglia (1500 - 1559), unfairly forgotten.

static void vtkPolynomialSolversUnivariate::SetDivisionTolerance ( double  tol  )  [static]

Set/get the tolerance used when performing polynomial Euclidean division to find polynomial roots. This tolerance is used to decide whether the coefficient(s) of a polynomial remainder are close enough to zero to be neglected.

static double vtkPolynomialSolversUnivariate::GetDivisionTolerance (  )  [static]

Set/get the tolerance used when performing polynomial Euclidean division to find polynomial roots. This tolerance is used to decide whether the coefficient(s) of a polynomial remainder are close enough to zero to be neglected.


Member Data Documentation

Definition at line 189 of file vtkPolynomialSolversUnivariate.h.


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

Generated on Wed Jun 3 19:26:33 2009 for VTK by  doxygen 1.5.6