1 // Created on: 1991-07-17
2 // Created by: Isabelle GRIGNON
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_FunctionAllRoots_HeaderFile
18 #define _math_FunctionAllRoots_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 math_FunctionWithDerivative;
31 class math_FunctionSample;
34 //! This algorithm uses a sample of the function to find
35 //! all intervals on which the function is null, and afterwards
36 //! uses the FunctionRoots algorithm to find the points
37 //! where the function is null outside the "null intervals".
38 //! Knowledge of the derivative is required.
39 class math_FunctionAllRoots
46 //! The algorithm uses the sample to find intervals on which
47 //! the function is null. An interval is found if, for at least
48 //! two consecutive points of the sample, Ui and Ui+1, we get
49 //! |F(Ui)|<=EpsNul and |F(Ui+1)|<=EpsNul. The real bounds of
50 //! an interval are computed with the FunctionRoots.
52 //! Between two intervals, the roots of the function F are
53 //! calculated using the FunctionRoots algorithm.
54 Standard_EXPORT math_FunctionAllRoots(math_FunctionWithDerivative& F, const math_FunctionSample& S, const Standard_Real EpsX, const Standard_Real EpsF, const Standard_Real EpsNul);
56 //! Returns True if the computation has been done successfully.
57 Standard_Boolean IsDone() const;
59 //! Returns the number of intervals on which the function
61 //! An exception is raised if IsDone returns False.
62 Standard_Integer NbIntervals() const;
64 //! Returns the interval of parameter of range Index.
65 //! An exception is raised if IsDone returns False;
66 //! An exception is raised if Index<=0 or Index >Nbintervals.
67 void GetInterval (const Standard_Integer Index, Standard_Real& A, Standard_Real& B) const;
69 //! returns the State Number associated to the interval Index.
70 //! An exception is raised if IsDone returns False;
71 //! An exception is raised if Index<=0 or Index >Nbintervals.
72 void GetIntervalState (const Standard_Integer Index, Standard_Integer& IFirst, Standard_Integer& ILast) const;
74 //! returns the number of points where the function is Null.
75 //! An exception is raised if IsDone returns False.
76 Standard_Integer NbPoints() const;
78 //! Returns the parameter of the point of range Index.
79 //! An exception is raised if IsDone returns False;
80 //! An exception is raised if Index<=0 or Index >NbPoints.
81 Standard_Real GetPoint (const Standard_Integer Index) const;
83 //! returns the State Number associated to the point Index.
84 //! An exception is raised if IsDone returns False;
85 //! An exception is raised if Index<=0 or Index >Nbintervals.
86 Standard_Integer GetPointState (const Standard_Integer Index) const;
88 //! Prints on the stream o information on the current state
90 Standard_EXPORT void Dump (Standard_OStream& o) const;
105 Standard_Boolean done;
106 TColStd_SequenceOfReal pdeb;
107 TColStd_SequenceOfReal pfin;
108 TColStd_SequenceOfReal piso;
109 TColStd_SequenceOfInteger ideb;
110 TColStd_SequenceOfInteger ifin;
111 TColStd_SequenceOfInteger iiso;
117 #include <math_FunctionAllRoots.lxx>
123 #endif // _math_FunctionAllRoots_HeaderFile