2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
17
package org.apache.commons.math.analysis;
19
import org.apache.commons.math.ConvergenceException;
20
import org.apache.commons.math.FunctionEvaluationException;
23
* Interface for univariate real integration algorithms.
25
* @version $Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 2008) $
28
public interface UnivariateRealIntegrator {
31
* Set the upper limit for the number of iterations.
33
* Usually a high iteration count indicates convergence problem. However,
34
* the "reasonable value" varies widely for different cases. Users are
35
* advised to use the default value.</p>
37
* A <code>ConvergenceException</code> will be thrown if this number
40
* @param count maximum number of iterations
42
void setMaximalIterationCount(int count);
45
* Get the upper limit for the number of iterations.
47
* @return the actual upper limit
49
int getMaximalIterationCount();
52
* Reset the upper limit for the number of iterations to the default.
54
* The default value is supplied by the implementation.</p>
56
* @see #setMaximalIterationCount(int)
58
void resetMaximalIterationCount();
61
* Set the lower limit for the number of iterations.
63
* Minimal iteration is needed to avoid false early convergence, e.g.
64
* the sample points happen to be zeroes of the function. Users can
65
* use the default value or choose one that they see as appropriate.</p>
67
* A <code>ConvergenceException</code> will be thrown if this number
70
* @param count minimum number of iterations
72
void setMinimalIterationCount(int count);
75
* Get the lower limit for the number of iterations.
77
* @return the actual lower limit
79
int getMinimalIterationCount();
82
* Reset the lower limit for the number of iterations to the default.
84
* The default value is supplied by the implementation.</p>
86
* @see #setMinimalIterationCount(int)
88
void resetMinimalIterationCount();
91
* Set the relative accuracy.
93
* This is used to stop iterations.</p>
95
* @param accuracy the relative accuracy
96
* @throws IllegalArgumentException if the accuracy can't be achieved
97
* or is otherwise deemed unreasonable
99
void setRelativeAccuracy(double accuracy);
102
* Get the actual relative accuracy.
104
* @return the accuracy
106
double getRelativeAccuracy();
109
* Reset the relative accuracy to the default.
111
* The default value is provided by the implementation.</p>
113
* @see #setRelativeAccuracy(double)
115
void resetRelativeAccuracy();
118
* Integrate the function in the given interval.
120
* @param min the lower bound for the interval
121
* @param max the upper bound for the interval
122
* @return the value of integral
123
* @throws ConvergenceException if the maximum iteration count is exceeded
124
* or the integrator detects convergence problems otherwise
125
* @throws FunctionEvaluationException if an error occurs evaluating the
127
* @throws IllegalArgumentException if min > max or the endpoints do not
128
* satisfy the requirements specified by the integrator
130
double integrate(double min, double max) throws ConvergenceException,
131
FunctionEvaluationException, IllegalArgumentException;
134
* Get the result of the last run of the integrator.
136
* @return the last result
137
* @throws IllegalStateException if there is no result available, either
138
* because no result was yet computed or the last attempt failed
140
double getResult() throws IllegalStateException;
143
* Get the number of iterations in the last run of the integrator.
145
* This is mainly meant for testing purposes. It may occasionally
146
* help track down performance problems: if the iteration count
147
* is notoriously high, check whether the function is evaluated
148
* properly, and whether another integrator is more amenable to the
151
* @return the last iteration count
152
* @throws IllegalStateException if there is no result available, either
153
* because no result was yet computed or the last attempt failed
155
int getIterationCount() throws IllegalStateException;