0032969: Coding - get rid of unused headers [IMeshData to PLib]
[occt.git] / src / math / math_BracketedRoot.hxx
1 // Created on: 1991-05-14
2 // Created by: Laurent Painnot
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _math_BracketedRoot_HeaderFile
18 #define _math_BracketedRoot_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Real.hxx>
25 #include <Standard_OStream.hxx>
26 class math_Function;
27
28
29 //! This class implements the Brent method to find the root of a function
30 //! located within two bounds. No knowledge of the derivative is required.
31 class math_BracketedRoot 
32 {
33 public:
34
35   DEFINE_STANDARD_ALLOC
36
37   
38
39   //! The Brent method is used to find the root of the function F between
40   //! the bounds Bound1 and Bound2 on the function F.
41   //! If F(Bound1)*F(Bound2) >0 the Brent method fails.
42   //! The tolerance required for the root is given by Tolerance.
43   //! The solution is found when :
44   //! abs(Xi - Xi-1) <= Tolerance;
45   //! The maximum number of iterations allowed is given by NbIterations.
46   Standard_EXPORT math_BracketedRoot(math_Function& F, const Standard_Real Bound1, const Standard_Real Bound2, const Standard_Real Tolerance, const Standard_Integer NbIterations = 100, const Standard_Real ZEPS = 1.0e-12);
47   
48   //! Returns true if the computations are successful, otherwise returns false.
49     Standard_Boolean IsDone() const;
50   
51   //! returns the value of the root.
52   //! Exception NotDone is raised if the minimum was not found.
53     Standard_Real Root() const;
54   
55   //! returns the value of the function at the root.
56   //! Exception NotDone is raised if the minimum was not found.
57     Standard_Real Value() const;
58   
59   //! returns the number of iterations really done during the
60   //! computation of the Root.
61   //! Exception NotDone is raised if the minimum was not found.
62     Standard_Integer NbIterations() const;
63   
64   //! Prints on the stream o information on the current state
65   //! of the object.
66   Standard_EXPORT void Dump (Standard_OStream& o) const;
67
68
69
70
71 protected:
72
73
74
75
76
77 private:
78
79
80
81   Standard_Boolean Done;
82   Standard_Real TheRoot;
83   Standard_Real TheError;
84   Standard_Integer NbIter;
85
86
87 };
88
89
90 #include <math_BracketedRoot.lxx>
91
92
93
94
95
96 #endif // _math_BracketedRoot_HeaderFile