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
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 #ifndef _math_FunctionRoots_HeaderFile
18 #define _math_FunctionRoots_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
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;
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
46 //! Calculates all the real roots of a function F-K within the range
47 //! A..B. whithout 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);
54 //! Returns true if the computations are successful, otherwise returns false.
55 Standard_Boolean IsDone() const;
58 //! returns true if the function is considered as null between A and B.
60 //! StdFail_NotDone if the algorithm fails (and IsDone returns false).
61 Standard_Boolean IsAllNull() const;
63 //! Returns the number of solutions found.
65 //! StdFail_NotDone if the algorithm fails (and IsDone returns false).
66 Standard_Integer NbSolutions() const;
68 //! Returns the Nth value of the root of function F.
70 //! StdFail_NotDone if the algorithm fails (and IsDone returns false).
71 Standard_Real Value (const Standard_Integer Nieme) const;
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;
79 //! Prints on the stream o information on the current state
81 Standard_EXPORT void Dump (Standard_OStream& o) const;
96 Standard_Boolean Done;
97 Standard_Boolean AllNull;
98 TColStd_SequenceOfReal Sol;
99 TColStd_SequenceOfInteger NbStateSol;
105 #include <math_FunctionRoots.lxx>
111 #endif // _math_FunctionRoots_HeaderFile