0032402: Coding Rules - eliminate msvc warning C4668 (symbol is not defined as a...
[occt.git] / src / math / math_FunctionRoots.hxx
1 // Created on: 1991-05-13
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_FunctionRoots_HeaderFile
18 #define _math_FunctionRoots_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Boolean.hxx>
25 #include <TColStd_SequenceOfReal.hxx>
26 #include <TColStd_SequenceOfInteger.hxx>
27 #include <Standard_Real.hxx>
28 #include <Standard_Integer.hxx>
29 #include <Standard_OStream.hxx>
30 class Standard_RangeError;
31 class StdFail_NotDone;
32 class math_FunctionWithDerivative;
33
34
35
36 //! This class implements an algorithm which finds all the real roots of
37 //! a function with derivative within a given range.
38 //! Knowledge of the derivative is required.
39 class math_FunctionRoots 
40 {
41 public:
42
43   DEFINE_STANDARD_ALLOC
44
45   
46   //! Calculates all the real roots of a function F-K within the range
47   //! A..B. without conditions on A and B
48   //! A solution X is found when
49   //! abs(Xi - Xi-1) <= Epsx and abs(F(Xi)-K) <= EpsF.
50   //! The function is considered as null between A and B if
51   //! abs(F-K) <= EpsNull within this range.
52   Standard_EXPORT math_FunctionRoots(math_FunctionWithDerivative& F, const Standard_Real A, const Standard_Real B, const Standard_Integer NbSample, const Standard_Real EpsX = 0.0, const Standard_Real EpsF = 0.0, const Standard_Real EpsNull = 0.0, const Standard_Real K = 0.0);
53   
54   //! Returns true if the computations are successful, otherwise returns false.
55     Standard_Boolean IsDone() const;
56   
57
58   //! returns true if the function is considered as null between A and B.
59   //! Exceptions
60   //! StdFail_NotDone if the algorithm fails (and IsDone returns false).
61     Standard_Boolean IsAllNull() const;
62   
63   //! Returns the number of solutions found.
64   //! Exceptions
65   //! StdFail_NotDone if the algorithm fails (and IsDone returns false).
66     Standard_Integer NbSolutions() const;
67   
68   //! Returns the Nth value of the root of function F.
69   //! Exceptions
70   //! StdFail_NotDone if the algorithm fails (and IsDone returns false).
71     Standard_Real Value (const Standard_Integer Nieme) const;
72   
73
74   //! returns the StateNumber  of the Nieme root.
75   //! Exception RangeError is raised if Nieme is < 1
76   //! or Nieme > NbSolutions.
77     Standard_Integer StateNumber (const Standard_Integer Nieme) const;
78   
79   //! Prints on the stream o information on the current state
80   //! of the object.
81   Standard_EXPORT void Dump (Standard_OStream& o) const;
82
83
84
85
86 protected:
87
88
89
90
91
92 private:
93
94
95
96   Standard_Boolean Done;
97   Standard_Boolean AllNull;
98   TColStd_SequenceOfReal Sol;
99   TColStd_SequenceOfInteger NbStateSol;
100
101
102 };
103
104
105 #include <math_FunctionRoots.lxx>
106
107
108
109
110
111 #endif // _math_FunctionRoots_HeaderFile