b311480e |
1 | -- Created on: 1991-07-17 |
2 | -- Created by: Isabelle GRIGNON |
3 | -- Copyright (c) 1991-1999 Matra Datavision |
4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | -- |
6 | -- The content of this file is subject to the Open CASCADE Technology Public |
7 | -- License Version 6.5 (the "License"). You may not use the content of this file |
8 | -- except in compliance with the License. Please obtain a copy of the License |
9 | -- at http://www.opencascade.org and read it completely before using this file. |
10 | -- |
11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | -- |
14 | -- The Original Code and all software distributed under the License is |
15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | -- Initial Developer hereby disclaims all such warranties, including without |
17 | -- limitation, any warranties of merchantability, fitness for a particular |
18 | -- purpose or non-infringement. Please see the License for the specific terms |
19 | -- and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | class FunctionAllRoots from math |
24 | |
25 | ---Purpose: This algorithm uses a sample of the function to find |
26 | -- all intervals on which the function is null, and afterwards |
27 | -- uses the FunctionRoots algorithm to find the points |
28 | -- where the function is null outside the "null intervals". |
29 | -- Knowledge of the derivative is required. |
30 | |
31 | |
32 | uses FunctionSample from math, |
33 | FunctionRoots from math, |
34 | FunctionWithDerivative from math, |
35 | SequenceOfReal from TColStd, |
36 | SequenceOfInteger from TColStd, |
37 | OStream from Standard |
38 | |
39 | raises OutOfRange from Standard, |
40 | NotDone from StdFail, |
41 | NumericError from Standard |
42 | |
43 | is |
44 | |
45 | Create(F: in out FunctionWithDerivative from math; |
46 | S: FunctionSample from math; |
47 | EpsX, EpsF, EpsNul: Real) |
48 | |
49 | ---Purpose: The algorithm uses the sample to find intervals on which |
50 | -- the function is null. An interval is found if, for at least |
51 | -- two consecutive points of the sample, Ui and Ui+1, we get |
52 | -- |F(Ui)|<=EpsNul and |F(Ui+1)|<=EpsNul. The real bounds of |
53 | -- an interval are computed with the FunctionRoots. |
54 | -- algorithm. |
55 | -- Between two intervals, the roots of the function F are |
56 | -- calculated using the FunctionRoots algorithm. |
57 | |
58 | returns FunctionAllRoots |
59 | |
60 | raises NumericError from Standard; |
61 | |
62 | |
63 | IsDone(me) |
64 | |
65 | ---Purpose: Returns True if the computation has been done successfully. |
66 | ---C++: inline |
67 | |
68 | returns Boolean |
69 | is static; |
70 | |
71 | |
72 | NbIntervals(me) |
73 | ---Purpose: Returns the number of intervals on which the function |
74 | -- is Null. |
75 | -- An exception is raised if IsDone returns False. |
76 | ---C++: inline |
77 | |
78 | returns Integer |
79 | raises NotDone from StdFail |
80 | is static; |
81 | |
82 | |
83 | GetInterval(me; Index: Integer; A,B: out Real) |
84 | ---Purpose: Returns the interval of parameter of range Index. |
85 | -- An exception is raised if IsDone returns False; |
86 | -- An exception is raised if Index<=0 or Index >Nbintervals. |
87 | ---C++: inline |
88 | |
89 | raises NotDone from StdFail, OutOfRange from Standard |
90 | is static; |
91 | |
92 | |
93 | GetIntervalState(me; Index: Integer; IFirst, ILast: out Integer) |
94 | ---Purpose: returns the State Number associated to the interval Index. |
95 | -- An exception is raised if IsDone returns False; |
96 | -- An exception is raised if Index<=0 or Index >Nbintervals. |
97 | ---C++: inline |
98 | |
99 | raises NotDone from StdFail, OutOfRange from Standard |
100 | is static; |
101 | |
102 | |
103 | NbPoints(me) |
104 | ---Purpose: returns the number of points where the function is Null. |
105 | -- An exception is raised if IsDone returns False. |
106 | ---C++: inline |
107 | |
108 | returns Integer |
109 | raises NotDone from StdFail |
110 | is static; |
111 | |
112 | |
113 | GetPoint(me; Index: Integer) |
114 | ---Purpose: Returns the parameter of the point of range Index. |
115 | -- An exception is raised if IsDone returns False; |
116 | -- An exception is raised if Index<=0 or Index >NbPoints. |
117 | ---C++: inline |
118 | |
119 | returns Real |
120 | raises NotDone from StdFail, OutOfRange from Standard |
121 | is static; |
122 | |
123 | |
124 | GetPointState(me; Index: Integer) |
125 | ---Purpose: returns the State Number associated to the point Index. |
126 | -- An exception is raised if IsDone returns False; |
127 | -- An exception is raised if Index<=0 or Index >Nbintervals. |
128 | ---C++: inline |
129 | |
130 | returns Integer |
131 | raises NotDone from StdFail, OutOfRange from Standard |
132 | is static; |
133 | |
134 | |
135 | Dump(me; o: in out OStream) |
136 | ---Purpose: Prints on the stream o information on the current state |
137 | -- of the object. |
138 | |
139 | is static; |
140 | |
141 | fields |
142 | |
143 | done: Boolean; |
144 | pdeb: SequenceOfReal from TColStd; |
145 | pfin: SequenceOfReal from TColStd; |
146 | piso: SequenceOfReal from TColStd; |
147 | ideb: SequenceOfInteger from TColStd; |
148 | ifin: SequenceOfInteger from TColStd; |
149 | iiso: SequenceOfInteger from TColStd; |
150 | |
151 | end FunctionAllRoots; |