1 /*
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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 */
17 package org.apache.commons.math4.legacy.analysis.integration;
18
19 import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
20
21 /**
22 * Interface for univariate real integration algorithms.
23 *
24 * @since 1.2
25 */
26 public interface UnivariateIntegrator {
27
28 /**
29 * Get the relative accuracy.
30 *
31 * @return the accuracy
32 */
33 double getRelativeAccuracy();
34
35 /**
36 * Get the absolute accuracy.
37 *
38 * @return the accuracy
39 */
40 double getAbsoluteAccuracy();
41
42 /**
43 * Get the min limit for the number of iterations.
44 *
45 * @return the actual min limit
46 */
47 int getMinimalIterationCount();
48
49 /**
50 * Get the upper limit for the number of iterations.
51 *
52 * @return the actual upper limit
53 */
54 int getMaximalIterationCount();
55
56 /**
57 * Integrate the function in the given interval.
58 *
59 * @param maxEval Maximum number of evaluations.
60 * @param f the integrand function
61 * @param min the lower bound for the interval
62 * @param max the upper bound for the interval
63 * @return the value of integral
64 * @throws org.apache.commons.math4.legacy.exception.TooManyEvaluationsException if the maximum number of function
65 * evaluations is exceeded
66 * @throws org.apache.commons.math4.legacy.exception.MaxCountExceededException if the maximum iteration count is exceeded
67 * or the integrator detects convergence problems otherwise
68 * @throws org.apache.commons.math4.legacy.exception.MathIllegalArgumentException if {@code min > max} or the endpoints do not
69 * satisfy the requirements specified by the integrator
70 * @throws org.apache.commons.math4.legacy.exception.NullArgumentException if {@code f} is {@code null}.
71 */
72 double integrate(int maxEval, UnivariateFunction f, double min, double max);
73
74 /**
75 * Get the number of function evaluations of the last run of the integrator.
76 *
77 * @return number of function evaluations
78 */
79 int getEvaluations();
80
81 /**
82 * Get the number of iterations of the last run of the integrator.
83 *
84 * @return number of iterations
85 */
86 int getIterations();
87 }