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 actual relative accuracy.
034     * @return the accuracy
035     */
036    double getRelativeAccuracy();
037
038    /**
039     * Get the actual absolute accuracy.
040     *
041     * @return the accuracy
042     */
043    double getAbsoluteAccuracy();
044
045    /**
046     * Get the min limit for the number of iterations.
047     *
048     * @return the actual min limit
049     */
050    int getMinimalIterationCount();
051
052    /**
053     * Get the upper limit for the number of iterations.
054     *
055     * @return the actual upper limit
056     */
057    int getMaximalIterationCount();
058
059    /**
060     * Integrate the function in the given interval.
061     *
062     * @param maxEval Maximum number of evaluations.
063     * @param f the integrand function
064     * @param min the min bound for the interval
065     * @param max the upper bound for the interval
066     * @return the value of integral
067     * @throws TooManyEvaluationsException if the maximum number of function
068     * evaluations is exceeded.
069     * @throws MaxCountExceededException if the maximum iteration count is exceeded
070     * or the integrator detects convergence problems otherwise
071     * @throws MathIllegalArgumentException if min > max or the endpoints do not
072     * satisfy the requirements specified by the integrator
073     * @throws NullArgumentException if {@code f} is {@code null}.
074     */
075    double integrate(int maxEval, UnivariateFunction f, double min,
076                     double max)
077        throws TooManyEvaluationsException, MaxCountExceededException,
078               MathIllegalArgumentException, NullArgumentException;
079
080    /**
081     * Get the number of function evaluations of the last run of the integrator.
082     * @return number of function evaluations
083     */
084    int getEvaluations();
085
086    /**
087     * Get the number of iterations of the last run of the integrator.
088     * @return number of iterations
089     */
090    int getIterations();
091
092}