1 -- Created on: 1991-03-14
2 -- Created by: Laurent PAINNOT
3 -- Copyright (c) 1991-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
6 -- This file is part of Open CASCADE Technology software library.
8 -- This library is free software; you can redistribute it and/or modify it under
9 -- the terms of the GNU Lesser General Public License version 2.1 as published
10 -- by the Free Software Foundation, with special exception defined in the file
11 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 -- distribution for complete text of the license and disclaimer of any warranty.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 class BissecNewton from math
19 -- This class implements a combination of Newton-Raphson and bissection
20 -- methods to find the root of the function between two bounds.
21 -- Knowledge of the derivative is required.
23 uses Vector from math,
25 FunctionWithDerivative from math,
29 raises NotDone from StdFail
34 Perform(me: in out; F: out FunctionWithDerivative;
36 NbIterations: Integer)
41 Create(F: in out FunctionWithDerivative;
42 Bound1, Bound2, TolX: Real;
43 NbIterations: Integer = 100)
45 -- A combination of Newton-Raphson and bissection methods is done to find
46 -- the root of the function F between the bounds Bound1 and Bound2.
48 -- The tolerance required on the root is given by TolX.
49 -- The solution is found when :
50 -- abs(Xi - Xi-1) <= TolX and F(Xi) * F(Xi-1) <= 0
51 -- The maximum number of iterations allowed is given by NbIterations.
55 ---C++: alias " Standard_EXPORT virtual ~math_BissecNewton();"
57 IsSolutionReached(me: in out; F: out FunctionWithDerivative)
59 -- This method is called at the end of each iteration to check if the
60 -- solution has been found.
61 -- It can be redefined in a sub-class to implement a specific test to
62 -- stop the iterations.
69 ---Purpose: Tests is the root has been successfully found.
76 ---Purpose: returns the value of the root.
77 -- Exception NotDone is raised if the minimum was not found.
84 ---Purpose: returns the value of the derivative at the root.
85 -- Exception NotDone is raised if the minimum was not found.
94 ---Purpose: returns the value of the function at the root.
95 -- Exception NotDone is raised if the minimum was not found.
103 Dump(me; o: in out OStream)
104 ---Purpose: Prints on the stream o information on the current state
106 -- Is used to redifine the operator <<.
114 TheStatus: Status is protected;
115 XTol: Real is protected;
116 x: Real is protected;
117 dx: Real is protected;
118 f: Real is protected;
119 df: Real is protected;