#include <Newton.h>
Inheritance diagram for Newton:

This module searches an N-dimensional Box for roots of an equation. It does this by first employing a simple subdivision to get rid of regions of space that definitely don't contain roots. It then subdivides those regions that might contain roots into small enough pieces to be handled by a Newton's Method solver. So there are two parts of the search algorithm that you must concern yourself with: subdivision and equation solving.
This module solves N equations in N variables, over a given bounding box, and is guaranteed to find all solutions within that bounding box because it uses interval arithmetic. Basically, it finds all of the roots of a set of equations.
In matrix notation, this class solves A*(Y - Xc) - b = 0 where A is an an NxN IMatrix (ie. a matrix of intervals), Xc is an N-dimensional vector (of doubles), and b and Y are N-dimensional Boxes (ie. vectors of intervals). Xc represents an initial guess for the root, ie. the center of the interval used in Newton's method. Y represents the variable we are solving for since we are trying to find a Box containing a root. The tricky part is that YOU must provide A and b. These values are set in the NewtonEquation() method. You will have to override this method if you want to do something other than the default here (which is nothing).
HOW TO USE THIS CLASS AND WHAT METHODS TO OVERRIDE
(1) NewtonSubdivisionBreak() is called on a given Box region during the simple subdivision phase. This method should return true if you know for sure that there is NOT a root in that region, false if there might be a root in the region. Since the default NewtonSubdivisionBreak() method always returns false, the root finding won't stop until the Box size has reached fWidthTolerance.
(2) NewtonEquation() is called during the Newton's Method phase to set the variables A and b in the equation A(Y-Xc) = b. So if you want to use Newton's method to refine the root finding once the Box size has reached fNewtonTolerance, be sure to override this method and return true.
(3) NewtonBreak() is called on the Box in ALL phases of the root finding process to see if we can stop searching for roots in the Box. The default method performs two checks: 1: Have we found the maximum number of roots allowed? 2: Is the box small enough to say that two roots in the box can be considered as a single root, and if so does this box already contain a root? If either of these tests is true, then we return true to indicate that we want to stop searching this box for more roots. You may want to override this behavior if you have additional information on the Box in question (for example, using the gradient can we determine if there is definitely no root in the Box in question).
(4) NewtonOutput() is called every time we find a root. This method in turn calls NewtonPostProcess() which allows you to take action on the root in question prior to actually saving it. You may want to override NewtonOutput() if you want to store the roots someplace other than the default location fRoots, a list of Points.
(5) NewtonPostProcess() is called by NewtonOutput() and allows you to take action on the root in question prior to actually saving it. You could override this method if you have more conditions that the root must meet if it will be stored. The default method prevents duplicates roots from being output.
(6) FindZeros() is the method you call to actually find roots over an initial domain. Simple subdivision is used down to a resolution of fNewtonTolerance, and then Newton's method takes over, which provides quadratic convergence for most cases.
Definition at line 101 of file Newton.h.
Public Member Functions | |
| Newton () | |
| Default constructor. | |
| void | FindZeros (Box< double > &IX) |
| Front end for finding zeros. | |
Public Attributes | |
| double | fWidthTolerance |
| Maximum error of final roots (width of the bounding box). | |
| double | fSameTolerance |
| Two roots this close together are considered the same. | |
| unsigned int | fMaxRoots |
| The maximum number of roots we are allowed to save. | |
| int | fUseNewton |
| Flag for FindZeros to use Newton iteration. | |
| double | fNewtonTolerance |
| FindZeros uses subdivision on large intervals, then hones in using Newton when the interval is smaller than fNewtonTolerance. | |
| PointList | fRoots |
| List of roots saved by NewtonOutput(). | |
| PointList::iterator | plIter |
| Convenient iterator over PointList. | |
Static Public Attributes | |
| const double | STANDARD_WIDTH_TOLERANCE = 0.0001 |
| How wide the divisions can be before quitting. | |
| const int | STANDARD_MAX_ROOTS = 20 |
| Maximum number of roots we can find - prevents problems with degenerates. | |
Protected Member Functions | |
| virtual bool | NewtonSubdivisionBreak (Box< double > &X) |
| During the subdivsion phase, this method should return true if you know for sure that there isn't a root in this box and you want to exclude it from further searching during the subdivision phase. | |
| virtual bool | NewtonEquation (Box< double > &X, IMatrix &A, Box< double > &b) |
| Setup the system of equations to solve for during the Newton's Method phase. | |
| virtual bool | NewtonPostProcess (Box< double > &X) |
| This method is called just before we call NewtonOutput and allows you to do extra stuff to the root (in the Box) before it gets output. | |
| virtual void | NewtonOutput (Box< double > &X) |
| Outputs a root found during the search. | |
| virtual bool | NewtonBreak (Box< double > &X) |
| User definable test to determine if root search in current interval can be terminated. | |
| bool | SameRoot (Box< double > &IX) |
| Determins if root already found before. | |
| void | AddRoot (Box< double > IX) |
| Add a root to the found root list. | |
Private Member Functions | |
| void | FindZerosDivide (Box< double > &IX) |
| This method iterates through the given Box region looking for roots. | |
| void | NewtonDriver () |
| Performs the Newton zero search on whatever is in the stack. | |
| NewtonResult | INewton (Box< double > &IX) |
| Interval newton method for solving simultaneous equations of the form A*(Y-XC) - b = 0. | |
| int | SolveSeidel (Box< double > &X, Point Xc, IMatrix &M, Box< double > &b, int *unique) |
| Solve the interval matrix problem M(Y-Xc) + b = 0 for Y. | |
| int | GaussSeidelRow (Box< double > &X, Point &Xc, IMatrix &M, Box< double > &b, int row, int *unique) |
| Perform a step in the Gauss-Seidel iteration for a given row. | |
Private Attributes | |
| std::stack< Box< double > > | boxes |
| Stack of boxes used when root finding requires subdivision. | |
|
|
Default constructor. It initializes the algorithm variables. Definition at line 26 of file Newton.cpp. References fMaxRoots, fNewtonTolerance, fSameTolerance, fUseNewton, fWidthTolerance, STANDARD_MAX_ROOTS, and STANDARD_WIDTH_TOLERANCE. |
|
|
Add a root to the found root list.
Definition at line 65 of file Newton.cpp. References Box< Float >::center(), and fRoots. Referenced by NewtonOutput(). |
|
|
Front end for finding zeros. This is the method to call when you want to look for roots in the given region Box.
Definition at line 362 of file Newton.cpp. References FindZerosDivide(), fRoots, and X. Referenced by SearchDegenerate::search(), and SearchCritical::search(). |
|
|
This method iterates through the given Box region looking for roots. It first uses a simple subdivision method to search for roots. If fUseNewton is set, it switches over to Newton's Method when the Box is sufficiently small (set by fNewtonTolerance).
Definition at line 322 of file Newton.cpp. References boxes, fNewtonTolerance, fUseNewton, fWidthTolerance, NewtonBreak(), NewtonDriver(), NewtonOutput(), NewtonPostProcess(), NewtonSubdivisionBreak(), and X. Referenced by FindZeros(). |
|
||||||||||||||||||||||||||||
|
Perform a step in the Gauss-Seidel iteration for a given row.
Definition at line 85 of file Newton.cpp. References boxes, IDinf(), ISPLIT, and X. Referenced by SolveSeidel(). |
|
|
Interval newton method for solving simultaneous equations of the form A*(Y-XC) - b = 0.
Definition at line 213 of file Newton.cpp. References KEEP_TRYING, NewtonEquation(), NewtonResult, NO_PROGRESS, NO_ROOTS, SolveSeidel(), UNIQUE_ROOT, Box< Float >::width(), and X. Referenced by NewtonDriver(). |
|
|
User definable test to determine if root search in current interval can be terminated. The default method performs the following checks:
Definition at line 225 of file Newton.h. References fMaxRoots, fRoots, fSameTolerance, SameRoot(), and X. Referenced by FindZerosDivide(), and NewtonDriver(). |
|
|
Performs the Newton zero search on whatever is in the stack.
Definition at line 247 of file Newton.cpp. References BAD_INVERSE, boxes, fWidthTolerance, INewton(), KEEP_TRYING, NewtonBreak(), NewtonOutput(), NewtonPostProcess(), NewtonResult, NO_PROGRESS, NO_ROOTS, UNIQUE_ROOT, and X. Referenced by FindZerosDivide(). |
|
||||||||||||||||
|
Setup the system of equations to solve for during the Newton's Method phase. X is the input N-dimensional Box that you want to use when finding roots. Newton's method phase. You must set values for the parameters A and b. Also, you must return true if you want Newton solver to actually do anything. If you return false, then it assumes that you haven't set up A and b and insteads uses simple subdivision for the entire process.
Reimplemented in NewtonCritical, and NewtonDegenerate. Definition at line 167 of file Newton.h. Referenced by INewton(). |
|
|
Outputs a root found during the search. The input point (actually a Box which gets converted to a point using the Box::center()) is checked against the current list of roots (fRoots). If it is not found in the list, then it is added to the list.
Definition at line 204 of file Newton.h. Referenced by FindZerosDivide(), and NewtonDriver(). |
|
|
This method is called just before we call NewtonOutput and allows you to do extra stuff to the root (in the Box) before it gets output. If you return false from here, NewtonOutput will NOT be called, in effect not saving the root. So if you want to save the root, be sure to return true. The default method checks to see if the box in question has already been output. If so, then we return false since we don't want it added again.
Reimplemented in SearchCritical, and SearchDegenerate. Definition at line 185 of file Newton.h. References SameRoot(), and X. Referenced by FindZerosDivide(), and NewtonDriver(). |
|
|
During the subdivsion phase, this method should return true if you know for sure that there isn't a root in this box and you want to exclude it from further searching during the subdivision phase.
Reimplemented in NewtonCritical, and NewtonDegenerate. Definition at line 148 of file Newton.h. Referenced by FindZerosDivide(). |
|
|
Determins if root already found before. The "sameness" is determined by the member fSameTolerance which is related to fWidthTolerance.
Definition at line 41 of file Newton.cpp. References Box< Float >::center(), fRoots, fSameTolerance, and plIter. Referenced by NewtonBreak(), SearchDegenerate::NewtonPostProcess(), SearchCritical::NewtonPostProcess(), and NewtonPostProcess(). |
|
||||||||||||||||||||||||
|
Solve the interval matrix problem M(Y-Xc) + b = 0 for Y. Set X = Intersection(X,Y). Split X and push a sub-box if necessary.
Definition at line 163 of file Newton.cpp. References GaussSeidelRow(), and X. Referenced by INewton(). |
|
|
Stack of boxes used when root finding requires subdivision.
Definition at line 259 of file Newton.h. Referenced by FindZerosDivide(), GaussSeidelRow(), and NewtonDriver(). |
|
|
The maximum number of roots we are allowed to save.
Definition at line 117 of file Newton.h. Referenced by Newton(), NewtonBreak(), SearchDegenerate::NewtonPostProcess(), SearchCritical::NewtonPostProcess(), SearchDegenerate::search(), and SearchCritical::search(). |
|
|
FindZeros uses subdivision on large intervals, then hones in using Newton when the interval is smaller than fNewtonTolerance.
Definition at line 128 of file Newton.h. Referenced by FindZerosDivide(), Newton(), SearchDegenerate::search(), and SearchCritical::search(). |
|
|
List of roots saved by NewtonOutput().
Definition at line 130 of file Newton.h. Referenced by AddRoot(), SearchCritical::classify(), CriticalPointInterrogator::cleanup(), SearchCritical::display(), FindZeros(), NewtonBreak(), SearchDegenerate::NewtonPostProcess(), SearchCritical::NewtonPostProcess(), SearchDegenerate::print(), SearchCritical::print(), and SameRoot(). |
|
|
Two roots this close together are considered the same.
Definition at line 114 of file Newton.h. Referenced by Newton(), NewtonBreak(), SearchDegenerate::NewtonPostProcess(), SearchCritical::NewtonPostProcess(), SameRoot(), SearchDegenerate::search(), and SearchCritical::search(). |
|
|
Flag for FindZeros to use Newton iteration. If false, then FindZeros uses simple subdivision for the entire root finding process. Definition at line 123 of file Newton.h. Referenced by CriticalPointInterrogator::findCriticalPoints(), FindZerosDivide(), CriticalMesh::initialMesh(), and Newton(). |
|
|
Maximum error of final roots (width of the bounding box).
Definition at line 111 of file Newton.h. Referenced by FindZerosDivide(), Newton(), and NewtonDriver(). |
|
|
Convenient iterator over PointList.
Definition at line 132 of file Newton.h. Referenced by SearchCritical::display(), SearchDegenerate::print(), SearchCritical::print(), and SameRoot(). |
|
|
Maximum number of roots we can find - prevents problems with degenerates.
Definition at line 22 of file Newton.cpp. Referenced by Newton(). |
|
|
How wide the divisions can be before quitting.
Definition at line 21 of file Newton.cpp. Referenced by Newton(). |
1.3.4