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     */
017    package org.apache.commons.math3.analysis.integration;
018    
019    import org.apache.commons.math3.analysis.UnivariateFunction;
020    import org.apache.commons.math3.exception.MathIllegalArgumentException;
021    import org.apache.commons.math3.exception.MaxCountExceededException;
022    import org.apache.commons.math3.exception.NullArgumentException;
023    import org.apache.commons.math3.exception.TooManyEvaluationsException;
024    
025    /**
026     * Interface for univariate real integration algorithms.
027     *
028     * @version $Id: UnivariateIntegrator.java 1364387 2012-07-22 18:14:11Z tn $
029     * @since 1.2
030     */
031    public interface UnivariateIntegrator {
032    
033        /**
034         * Get the actual relative accuracy.
035         * @return the accuracy
036         */
037        double getRelativeAccuracy();
038    
039        /**
040         * Get the actual 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 min 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 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         * @return number of function evaluations
084         */
085        int getEvaluations();
086    
087        /**
088         * Get the number of iterations of the last run of the integrator.
089         * @return number of iterations
090         */
091        int getIterations();
092    
093    }