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.math4.legacy.analysis.integration; 018 019import org.apache.commons.math4.legacy.analysis.UnivariateFunction; 020 021/** 022 * Interface for univariate real integration algorithms. 023 * 024 * @since 1.2 025 */ 026public interface UnivariateIntegrator { 027 028 /** 029 * Get the relative accuracy. 030 * 031 * @return the accuracy 032 */ 033 double getRelativeAccuracy(); 034 035 /** 036 * Get the absolute accuracy. 037 * 038 * @return the accuracy 039 */ 040 double getAbsoluteAccuracy(); 041 042 /** 043 * Get the min limit for the number of iterations. 044 * 045 * @return the actual min limit 046 */ 047 int getMinimalIterationCount(); 048 049 /** 050 * Get the upper limit for the number of iterations. 051 * 052 * @return the actual upper limit 053 */ 054 int getMaximalIterationCount(); 055 056 /** 057 * Integrate the function in the given interval. 058 * 059 * @param maxEval Maximum number of evaluations. 060 * @param f the integrand function 061 * @param min the lower bound for the interval 062 * @param max the upper bound for the interval 063 * @return the value of integral 064 * @throws org.apache.commons.math4.legacy.exception.TooManyEvaluationsException if the maximum number of function 065 * evaluations is exceeded 066 * @throws org.apache.commons.math4.legacy.exception.MaxCountExceededException if the maximum iteration count is exceeded 067 * or the integrator detects convergence problems otherwise 068 * @throws org.apache.commons.math4.legacy.exception.MathIllegalArgumentException if {@code min > max} or the endpoints do not 069 * satisfy the requirements specified by the integrator 070 * @throws org.apache.commons.math4.legacy.exception.NullArgumentException if {@code f} is {@code null}. 071 */ 072 double integrate(int maxEval, UnivariateFunction f, double min, double max); 073 074 /** 075 * Get the number of function evaluations of the last run of the integrator. 076 * 077 * @return number of function evaluations 078 */ 079 int getEvaluations(); 080 081 /** 082 * Get the number of iterations of the last run of the integrator. 083 * 084 * @return number of iterations 085 */ 086 int getIterations(); 087}