Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||
UnivariateRealIntegrator |
|
| 1.0;1 |
1 | /* |
|
2 | * Copyright 2005 The Apache Software Foundation. |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
15 | */ |
|
16 | package org.apache.commons.math.analysis; |
|
17 | ||
18 | import org.apache.commons.math.ConvergenceException; |
|
19 | import org.apache.commons.math.FunctionEvaluationException; |
|
20 | ||
21 | /** |
|
22 | * Interface for univariate real integration algorithms. |
|
23 | * |
|
24 | * @version $Revision$ $Date: 2005-08-22 12:58:57 -0700 (Mon, 22 Aug 2005) $ |
|
25 | */ |
|
26 | public interface UnivariateRealIntegrator { |
|
27 | ||
28 | /** |
|
29 | * Set the upper limit for the number of iterations. |
|
30 | * <p> |
|
31 | * Usually a high iteration count indicates convergence problem. However, |
|
32 | * the "reasonable value" varies widely for different cases. Users are |
|
33 | * advised to use the default value. |
|
34 | * <p> |
|
35 | * A <code>ConvergenceException</code> will be thrown if this number |
|
36 | * is exceeded. |
|
37 | * |
|
38 | * @param count maximum number of iterations |
|
39 | */ |
|
40 | void setMaximalIterationCount(int count); |
|
41 | ||
42 | /** |
|
43 | * Get the upper limit for the number of iterations. |
|
44 | * |
|
45 | * @return the actual upper limit |
|
46 | */ |
|
47 | int getMaximalIterationCount(); |
|
48 | ||
49 | /** |
|
50 | * Reset the upper limit for the number of iterations to the default. |
|
51 | * <p> |
|
52 | * The default value is supplied by the implementation. |
|
53 | * |
|
54 | * @see #setMaximalIterationCount(int) |
|
55 | */ |
|
56 | void resetMaximalIterationCount(); |
|
57 | ||
58 | /** |
|
59 | * Set the lower limit for the number of iterations. |
|
60 | * <p> |
|
61 | * Minimal iteration is needed to avoid false early convergence, e.g. |
|
62 | * the sample points happen to be zeroes of the function. Users can |
|
63 | * use the default value or choose one that they see as appropriate. |
|
64 | * <p> |
|
65 | * A <code>ConvergenceException</code> will be thrown if this number |
|
66 | * is not met. |
|
67 | * |
|
68 | * @param count minimum number of iterations |
|
69 | */ |
|
70 | void setMinimalIterationCount(int count); |
|
71 | ||
72 | /** |
|
73 | * Get the lower limit for the number of iterations. |
|
74 | * |
|
75 | * @return the actual lower limit |
|
76 | */ |
|
77 | int getMinimalIterationCount(); |
|
78 | ||
79 | /** |
|
80 | * Reset the lower limit for the number of iterations to the default. |
|
81 | * <p> |
|
82 | * The default value is supplied by the implementation. |
|
83 | * |
|
84 | * @see #setMinimalIterationCount(int) |
|
85 | */ |
|
86 | void resetMinimalIterationCount(); |
|
87 | ||
88 | /** |
|
89 | * Set the relative accuracy. |
|
90 | * <p> |
|
91 | * This is used to stop iterations. |
|
92 | * |
|
93 | * @param accuracy the relative accuracy |
|
94 | * @throws IllegalArgumentException if the accuracy can't be achieved |
|
95 | * or is otherwise deemed unreasonable |
|
96 | */ |
|
97 | void setRelativeAccuracy(double accuracy); |
|
98 | ||
99 | /** |
|
100 | * Get the actual relative accuracy. |
|
101 | * |
|
102 | * @return the accuracy |
|
103 | */ |
|
104 | double getRelativeAccuracy(); |
|
105 | ||
106 | /** |
|
107 | * Reset the relative accuracy to the default. |
|
108 | * <p> |
|
109 | * The default value is provided by the implementation. |
|
110 | * |
|
111 | * @see #setRelativeAccuracy(double) |
|
112 | */ |
|
113 | void resetRelativeAccuracy(); |
|
114 | ||
115 | /** |
|
116 | * Integrate the function in the given interval. |
|
117 | * |
|
118 | * @param min the lower bound for the interval |
|
119 | * @param max the upper bound for the interval |
|
120 | * @return the value of integral |
|
121 | * @throws ConvergenceException if the maximum iteration count is exceeded |
|
122 | * or the integrator detects convergence problems otherwise |
|
123 | * @throws FunctionEvaluationException if an error occurs evaluating the |
|
124 | * function |
|
125 | * @throws IllegalArgumentException if min > max or the endpoints do not |
|
126 | * satisfy the requirements specified by the integrator |
|
127 | */ |
|
128 | double integrate(double min, double max) throws ConvergenceException, |
|
129 | FunctionEvaluationException, IllegalArgumentException; |
|
130 | ||
131 | /** |
|
132 | * Get the result of the last run of the integrator. |
|
133 | * |
|
134 | * @return the last result |
|
135 | * @throws IllegalStateException if there is no result available, either |
|
136 | * because no result was yet computed or the last attempt failed |
|
137 | */ |
|
138 | double getResult() throws IllegalStateException; |
|
139 | ||
140 | /** |
|
141 | * Get the number of iterations in the last run of the integrator. |
|
142 | * <p> |
|
143 | * This is mainly meant for testing purposes. It may occasionally |
|
144 | * help track down performance problems: if the iteration count |
|
145 | * is notoriously high, check whether the function is evaluated |
|
146 | * properly, and whether another integrator is more amenable to the |
|
147 | * problem. |
|
148 | * |
|
149 | * @return the last iteration count |
|
150 | * @throws IllegalStateException if there is no result available, either |
|
151 | * because no result was yet computed or the last attempt failed |
|
152 | */ |
|
153 | int getIterationCount() throws IllegalStateException; |
|
154 | } |