View Javadoc
1   /*
2    * Licensed to the Hipparchus project 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 Hipparchus project 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    *      https://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.hipparchus.analysis.integration;
18  
19  import org.hipparchus.CalculusFieldElement;
20  import org.hipparchus.analysis.CalculusFieldUnivariateFunction;
21  import org.hipparchus.exception.MathIllegalArgumentException;
22  import org.hipparchus.exception.MathIllegalStateException;
23  import org.hipparchus.exception.NullArgumentException;
24  
25  /**
26   * Interface for univariate real integration algorithms.
27   * @param <T> Type of the field elements.
28   * @since 2.0
29   */
30  public interface FieldUnivariateIntegrator<T extends CalculusFieldElement<T>> {
31  
32      /**
33       * Get the relative accuracy.
34       *
35       * @return the accuracy
36       */
37      double getRelativeAccuracy();
38  
39      /**
40       * Get the absolute accuracy.
41       *
42       * @return the accuracy
43       */
44      double getAbsoluteAccuracy();
45  
46      /**
47       * Get the min limit for the number of iterations.
48       *
49       * @return the actual min limit
50       */
51      int getMinimalIterationCount();
52  
53      /**
54       * Get the upper limit for the number of iterations.
55       *
56       * @return the actual upper limit
57       */
58      int getMaximalIterationCount();
59  
60      /**
61       * Integrate the function in the given interval.
62       *
63       * @param maxEval Maximum number of evaluations.
64       * @param f the integrand function
65       * @param min the lower bound for the interval
66       * @param max the upper bound for the interval
67       * @return the value of integral
68       * @throws MathIllegalStateException if the maximum number of function
69       * evaluations is exceeded
70       * @throws MathIllegalStateException if the maximum iteration count is exceeded
71       * or the integrator detects convergence problems otherwise
72       * @throws MathIllegalArgumentException if {@code min > max} or the endpoints do not
73       * satisfy the requirements specified by the integrator
74       * @throws NullArgumentException if {@code f} is {@code null}.
75       */
76      T integrate(int maxEval, CalculusFieldUnivariateFunction<T> f, T min, T max)
77          throws MathIllegalArgumentException, MathIllegalStateException, NullArgumentException;
78  
79      /**
80       * Get the number of function evaluations of the last run of the integrator.
81       *
82       * @return number of function evaluations
83       */
84      int getEvaluations();
85  
86      /**
87       * Get the number of iterations of the last run of the integrator.
88       *
89       * @return number of iterations
90       */
91      int getIterations();
92  
93  }