001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.math3.analysis.integration; 018 019import org.apache.commons.math3.analysis.UnivariateFunction; 020import org.apache.commons.math3.exception.MathIllegalArgumentException; 021import org.apache.commons.math3.exception.MaxCountExceededException; 022import org.apache.commons.math3.exception.NullArgumentException; 023import org.apache.commons.math3.exception.TooManyEvaluationsException; 024 025/** 026 * Interface for univariate real integration algorithms. 027 * 028 * @since 1.2 029 */ 030public interface UnivariateIntegrator { 031 032 /** 033 * Get the relative accuracy. 034 * 035 * @return the accuracy 036 */ 037 double getRelativeAccuracy(); 038 039 /** 040 * Get the absolute accuracy. 041 * 042 * @return the accuracy 043 */ 044 double getAbsoluteAccuracy(); 045 046 /** 047 * Get the min limit for the number of iterations. 048 * 049 * @return the actual min limit 050 */ 051 int getMinimalIterationCount(); 052 053 /** 054 * Get the upper limit for the number of iterations. 055 * 056 * @return the actual upper limit 057 */ 058 int getMaximalIterationCount(); 059 060 /** 061 * Integrate the function in the given interval. 062 * 063 * @param maxEval Maximum number of evaluations. 064 * @param f the integrand function 065 * @param min the lower bound for the interval 066 * @param max the upper bound for the interval 067 * @return the value of integral 068 * @throws TooManyEvaluationsException if the maximum number of function 069 * evaluations is exceeded 070 * @throws MaxCountExceededException if the maximum iteration count is exceeded 071 * or the integrator detects convergence problems otherwise 072 * @throws MathIllegalArgumentException if {@code min > max} or the endpoints do not 073 * satisfy the requirements specified by the integrator 074 * @throws NullArgumentException if {@code f} is {@code null}. 075 */ 076 double integrate(int maxEval, UnivariateFunction f, double min, 077 double max) 078 throws TooManyEvaluationsException, MaxCountExceededException, 079 MathIllegalArgumentException, NullArgumentException; 080 081 /** 082 * Get the number of function evaluations of the last run of the integrator. 083 * 084 * @return number of function evaluations 085 */ 086 int getEvaluations(); 087 088 /** 089 * Get the number of iterations of the last run of the integrator. 090 * 091 * @return number of iterations 092 */ 093 int getIterations(); 094 095}