commons-math3-3.6.1-org.apache.commons.math3.analysis.integration-包下的类-中英对照文档及源码赏析

摘要:中英对照文档、源码赏析、org.apache.commons.math3.analysis.integration、UnivariateIntegrator、BaseAbstractUnivariateIntegrator、IterativeLegendreGaussIntegrator、LegendreGaussIntegrator、MidPointIntegrator、RombergIntegrator、SimpsonIntegrator、TrapezoidIntegrator

完整中文文档、中英对照文档下载请移步:commons-math3-中文文档、中英对照文档-CSDN下载

1. 开源组件说明

jar包名称:commons-math3-3.6.1.jar

Maven 依赖:

<dependency><groupId>org.apache.commons</groupId><artifactId>commons-math3</artifactId><version>3.6.1</version>
</dependency>

完整中文文档、中英对照文档下载请移步:commons-math3-中文文档、中英对照文档-CSDN下载

程序包 org.apache.commons.math3.analysis.integration

Numerical integration (quadrature) algorithms for univariate real functions.

单变量真正函数的数值积分(正交)算法。

See: 说明

  • 接口概要  
    接口 说明
    UnivariateIntegrator
    Interface for univariate real integration algorithms.

    单变量真实集成算法的界面。

  • 类 Summary  
    说明
    BaseAbstractUnivariateIntegrator
    Provide a default implementation for several generic functions.

    提供多个通用功能的默认实现。

    IterativeLegendreGaussIntegrator
    This algorithm divides the integration interval into equally-sized sub-interval and on each of them performs a Legendre-Gauss quadrature.

    该算法将集成间隔划分为同等大小的子间隔,并且在它们中的每一个上执行Legendre-Gause正交。

    LegendreGaussIntegrator Deprecated

    As of 3.1 (to be removed in 4.0).

    截至3.1(4.0中删除)。

    MidPointIntegrator
    Implements the Midpoint Rule for integration of real univariate functions.

    实现中点规则,以实现实际单变量函数的集成。

    RombergIntegrator
    Implements the Romberg Algorithm for integration of real univariate functions.

    实现romberg算法,以集成真正的单变量函数。

    SimpsonIntegrator
    Implements Simpson's Rule for integration of real univariate functions.

    实现辛普森的规则,以集成真正单变量功能。

    TrapezoidIntegrator
    Implements the Trapezoid Rule for integration of real univariate functions.

    实现梯形规则,以便集成真正的单变量函数。

程序包 org.apache.commons.math3.analysis.integration 的说明

Numerical integration (quadrature) algorithms for univariate real functions.

单变量真正函数的数值积分(正交)算法。

2. 类 org.apache.commons.math3.analysis.integration.UnivariateIntegrator

2.1. UnivariateIntegrator 中英对照文档

org.apache.commons.math3.analysis.integration

接口 UnivariateIntegrator

  • All Known Implementing Classes:
    BaseAbstractUnivariateIntegrator, IterativeLegendreGaussIntegrator, LegendreGaussIntegrator, MidPointIntegrator, RombergIntegrator, SimpsonIntegrator, TrapezoidIntegrator

    BaseAbstractunigariate integrator,IterativeLegendregaussIntegrator,LegendregaussIntegrator,中点煤矿,rombergintegrator,夏普锰矿,梯形融化器



    public interface UnivariateIntegrator
    Interface for univariate real integration algorithms.

    单变量真实集成算法的界面。

    从以下版本开始:
    1.2

    1.2

  • 方法概要

    Methods  
    限定符和类型 方法和说明
    double getAbsoluteAccuracy()

    Get the absolute accuracy.

    获得绝对的准确性。

    int getEvaluations()

    Get the number of function evaluations of the last run of the integrator.

    获取积分器最后一次运行的函数评估数。

    int getIterations()

    Get the number of iterations of the last run of the integrator.

    获取积分器最后一次运行的迭代次数。

    int getMaximalIterationCount()

    Get the upper limit for the number of iterations.

    获取迭代次数的上限。

    int getMinimalIterationCount()

    Get the min limit for the number of iterations.

    获取迭代次数的最小限制。

    double getRelativeAccuracy()

    Get the relative accuracy.

    获得相对准确性。

    double integrate(int maxEval, UnivariateFunction f, double min, double max)

    Integrate the function in the given interval.

    在给定间隔中集成函数。

  • 方法详细说明

    • getRelativeAccuracy

      double getRelativeAccuracy()
      Get the relative accuracy.

      获得相对准确性。

      返回:
      the accuracy

      准确性

    • getAbsoluteAccuracy

      double getAbsoluteAccuracy()
      Get the absolute accuracy.

      获得绝对的准确性。

      返回:
      the accuracy

      准确性

    • getMinimalIterationCount

      int getMinimalIterationCount()
      Get the min limit for the number of iterations.

      获取迭代次数的最小限制。

      返回:
      the actual min limit

      实际最小限制

    • getMaximalIterationCount

      int getMaximalIterationCount()
      Get the upper limit for the number of iterations.

      获取迭代次数的上限。

      返回:
      the actual upper limit

      实际上限

    • integrate

      double integrate(int maxEval,UnivariateFunction f,double min,double max)throws TooManyEvaluationsException,MaxCountExceededException,MathIllegalArgumentException,NullArgumentException
      Integrate the function in the given interval.

      在给定间隔中集成函数。

      参数:
      maxEval - Maximum number of evaluations.

      maxeval - 最大评估数。

      f - the integrand function

      f - Integrand功能

      min - the lower bound for the interval

      最小 - 间隔的下限

      max - the upper bound for the interval

      max - 间隔的上限

      返回:
      the value of integral

      积分的价值

      抛出:
      TooManyEvaluationsException - if the maximum number of function evaluations is exceeded

      toomanyevaliveSexception - 如果超过了最大函数评估数

      MaxCountExceededException - if the maximum iteration count is exceeded or the integrator detects convergence problems otherwise

      MaxCountExceedEdException - 如果超出了最大迭代计数,或者积分器否则会检测到融合问题

      MathIllegalArgumentException - if min > max or the endpoints do not satisfy the requirements specified by the integrator

      MathilleGalargumentException - 如果min> max或端点不满足积分器指定的要求

      NullArgumentException - if f is null.

      nullargumentException - 如果f为null。

    • getEvaluations

      int getEvaluations()
      Get the number of function evaluations of the last run of the integrator.

      获取积分器最后一次运行的函数评估数。

      返回:
      number of function evaluations

      功能评估数量

    • getIterations

      int getIterations()
      Get the number of iterations of the last run of the integrator.

      获取积分器最后一次运行的迭代次数。

      返回:
      number of iterations

      迭代次数

2.2. UnivariateIntegrator 源码赏析

/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.* The ASF licenses this file to You under the Apache License, Version 2.0* (the "License"); you may not use this file except in compliance with* the License.  You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/
package org.apache.commons.math3.analysis.integration;import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.exception.NullArgumentException;
import org.apache.commons.math3.exception.TooManyEvaluationsException;/*** Interface for univariate real integration algorithms.** @since 1.2*/
public interface UnivariateIntegrator {/*** Get the relative accuracy.** @return the accuracy*/double getRelativeAccuracy();/*** Get the absolute accuracy.** @return the accuracy*/double getAbsoluteAccuracy();/*** Get the min limit for the number of iterations.** @return the actual min limit*/int getMinimalIterationCount();/*** Get the upper limit for the number of iterations.** @return the actual upper limit*/int getMaximalIterationCount();/*** Integrate the function in the given interval.** @param maxEval Maximum number of evaluations.* @param f the integrand function* @param min the lower bound for the interval* @param max the upper bound for the interval* @return the value of integral* @throws TooManyEvaluationsException if the maximum number of function* evaluations is exceeded* @throws MaxCountExceededException if the maximum iteration count is exceeded* or the integrator detects convergence problems otherwise* @throws MathIllegalArgumentException if {@code min > max} or the endpoints do not* satisfy the requirements specified by the integrator* @throws NullArgumentException if {@code f} is {@code null}.*/double integrate(int maxEval, UnivariateFunction f, double min,double max)throws TooManyEvaluationsException, MaxCountExceededException,MathIllegalArgumentException, NullArgumentException;/*** Get the number of function evaluations of the last run of the integrator.** @return number of function evaluations*/int getEvaluations();/*** Get the number of iterations of the last run of the integrator.** @return number of iterations*/int getIterations();}

3. 类 org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

3.1. BaseAbstractUnivariateIntegrator 中英对照文档

org.apache.commons.math3.analysis.integration

类 BaseAbstractUnivariateIntegrator

  • java.lang.Object
    • org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator
  • All Implemented Interfaces:
    UnivariateIntegrator

    单抗体钢结构

    Direct Known Subclasses:
    IterativeLegendreGaussIntegrator, LegendreGaussIntegrator, MidPointIntegrator, RombergIntegrator, SimpsonIntegrator, TrapezoidIntegrator

    IterativeLegendregaussIntegrator,LegendregaussIntegrator,中点煤矿,rombergintegrator,夏天素融化器,梯形钢组


    public abstract class BaseAbstractUnivariateIntegrator
    extends Object
    implements UnivariateIntegrator
    Provide a default implementation for several generic functions.

    提供多个通用功能的默认实现。

    从以下版本开始:
    1.2

    1.2

    • 字段概要

      字段  
      限定符和类型 Field and 的说明
      static double DEFAULT_ABSOLUTE_ACCURACY

      Default absolute accuracy.

      默认绝对准确性。

      static int DEFAULT_MAX_ITERATIONS_COUNT

      Default maximal iteration count.

      默认最大迭代计数。

      static int DEFAULT_MIN_ITERATIONS_COUNT

      Default minimal iteration count.

      默认最小迭代计数。

      static double DEFAULT_RELATIVE_ACCURACY

      Default relative accuracy.

      默认的相对准确性。

      protected Incrementor iterations

      Deprecated.

      as of 3.6, this field has been replaced with incrementCount()

      截至3.6,此字段已被替换为incrementCount()

      弃用。截至3.6,此字段已被替换为incrementCount()

    • 构造器概要

      构造器  
      Modifier 构造器和说明
      protected BaseAbstractUnivariateIntegrator(double relativeAccuracy, double absoluteAccuracy)

      Construct an integrator with given accuracies.

      构建具有给定精度的积分器。

      protected BaseAbstractUnivariateIntegrator(double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount)

      Construct an integrator with given accuracies and iteration counts.

      构建具有给定精度和迭代计数的集成器。

      protected BaseAbstractUnivariateIntegrator(int minimalIterationCount, int maximalIterationCount)

      Construct an integrator with given iteration counts.

      构建具有给定迭代计数的集成器。

    • 方法概要

      Methods  
      限定符和类型 方法和说明
      protected double computeObjectiveValue(double point)

      Compute the objective function value.

      计算目标函数值。

      protected abstract double doIntegrate()

      Method for implementing actual integration algorithms in derived classes.

      在派生类中实现实际集成算法的方法。

      double getAbsoluteAccuracy()

      Get the absolute accuracy.

      获得绝对的准确性。

      int getEvaluations()

      Get the number of function evaluations of the last run of the integrator.

      获取积分器最后一次运行的函数评估数。

      int getIterations()

      Get the number of iterations of the last run of the integrator.

      获取积分器最后一次运行的迭代次数。

      protected double getMax() 
      int getMaximalIterationCount()

      Get the upper limit for the number of iterations.

      获取迭代次数的上限。

      protected double getMin() 
      int getMinimalIterationCount()

      Get the min limit for the number of iterations.

      获取迭代次数的最小限制。

      double getRelativeAccuracy()

      Get the relative accuracy.

      获得相对准确性。

      protected void incrementCount()

      Increment the number of iterations.

      递增迭代次数。

      double integrate(int maxEval, UnivariateFunction f, double lower, double upper)

      Integrate the function in the given interval.

      在给定间隔中集成函数。

      protected void setup(int maxEval, UnivariateFunction f, double lower, double upper)

      Prepare for computation.

      准备计算。

      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    • 字段详情:

      • DEFAULT_ABSOLUTE_ACCURACY

        public static final double DEFAULT_ABSOLUTE_ACCURACY
        Default absolute accuracy.

        默认绝对准确性。

        另请参阅:
        Constant Field Values

        恒定字段值

      • DEFAULT_RELATIVE_ACCURACY

        public static final double DEFAULT_RELATIVE_ACCURACY
        Default relative accuracy.

        默认的相对准确性。

        另请参阅:
        Constant Field Values

        恒定字段值

      • DEFAULT_MIN_ITERATIONS_COUNT

        public static final int DEFAULT_MIN_ITERATIONS_COUNT
        Default minimal iteration count.

        默认最小迭代计数。

        另请参阅:
        Constant Field Values

        恒定字段值

      • DEFAULT_MAX_ITERATIONS_COUNT

        public static final int DEFAULT_MAX_ITERATIONS_COUNT
        Default maximal iteration count.

        默认最大迭代计数。

        另请参阅:
        Constant Field Values

        恒定字段值

      • iterations

        @Deprecated
        protected Incrementor iterations
        Deprecated.  as of 3.6, this field has been replaced with incrementCount()

        弃用。截至3.6,此字段已被替换为incrementCount()

        The iteration count.

        迭代计数。

    • 构造器详细说明

      • BaseAbstractUnivariateIntegrator

        protected BaseAbstractUnivariateIntegrator(double relativeAccuracy,double absoluteAccuracy,int minimalIterationCount,int maximalIterationCount)throws NotStrictlyPositiveException,NumberIsTooSmallException
        Construct an integrator with given accuracies and iteration counts.

        The meanings of the various parameters are:

        • relative accuracy: this is used to stop iterations if the absolute accuracy can't be achieved due to large values or short mantissa length. If this should be the primary criterion for convergence rather then a safety measure, set the absolute accuracy to a ridiculously small value, like Precision.SAFE_MIN.
        • absolute accuracy: The default is usually chosen so that results in the interval -10..-0.1 and +0.1..+10 can be found with a reasonable accuracy. If the expected absolute value of your results is of much smaller magnitude, set this to a smaller value.
        • minimum number of iterations: minimal iteration is needed to avoid false early convergence, e.g. the sample points happen to be zeroes of the function. Users can use the default value or choose one that they see as appropriate.
        • maximum number of iterations: usually a high iteration count indicates convergence problems. However, the "reasonable value" varies widely for different algorithms. Users are advised to use the default value supplied by the algorithm.

        构建具有给定精度和迭代计数的集成器。各种参数的含义是:相对精度:如果由于大值或短的尾数长度无法实现绝对精度,则使用该方法来停止迭代。如果这应该是收敛的主要标准,而是安全措施,则将绝对精度设置为易易上小的值,如precision.safe_min。绝对精度:通常选择默认值,以便在间隔-10 ..- 0.1和+0.1。+ 10可以以合理的准确度找到。如果结果的预期绝对值具有更小的幅度,请将其设置为较小的值。最小迭代次数:需要最小的迭代以避免假早期收敛,例如,采样点恰好是该功能的零。用户可以使用默认值或选择它们适当地看到的值。最大迭代次数:通常高迭代计数表示收敛问题。然而,“合理的值”因不同的算法而异。建议用户使用算法提供的默认值。

        参数:
        relativeAccuracy - relative accuracy of the result

        相对准确性 - 结果的相对准确性

        absoluteAccuracy - absolute accuracy of the result

        绝对精度 - 结果绝对准确性

        minimalIterationCount - minimum number of iterations

        minimalitorioncount - 最小迭代次数

        maximalIterationCount - maximum number of iterations

        maximalimerationcount - 最大迭代次数

        抛出:
        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive

        NOTSTRICLYPOSIVEIVEEXception - 如果最小的迭代数量并不严格积极

        NumberIsTooSmallException - if maximal number of iterations is lesser than or equal to the minimal number of iterations

        numberistoosmallexception - 如果最大迭代次数小于或等于最小数量的迭代次数

      • BaseAbstractUnivariateIntegrator

        protected BaseAbstractUnivariateIntegrator(double relativeAccuracy,double absoluteAccuracy)
        Construct an integrator with given accuracies.

        构建具有给定精度的积分器。

        参数:
        relativeAccuracy - relative accuracy of the result

        相对准确性 - 结果的相对准确性

        absoluteAccuracy - absolute accuracy of the result

        绝对精度 - 结果绝对准确性

      • BaseAbstractUnivariateIntegrator

        protected BaseAbstractUnivariateIntegrator(int minimalIterationCount,int maximalIterationCount)throws NotStrictlyPositiveException,NumberIsTooSmallException
        Construct an integrator with given iteration counts.

        构建具有给定迭代计数的集成器。

        参数:
        minimalIterationCount - minimum number of iterations

        minimalitorioncount - 最小迭代次数

        maximalIterationCount - maximum number of iterations

        maximalimerationcount - 最大迭代次数

        抛出:
        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive

        NOTSTRICLYPOSIVEIVEEXception - 如果最小的迭代数量并不严格积极

        NumberIsTooSmallException - if maximal number of iterations is lesser than or equal to the minimal number of iterations

        numberistoosmallexception - 如果最大迭代次数小于或等于最小数量的迭代次数

    • 方法详细说明

      • getRelativeAccuracy

        public double getRelativeAccuracy()
        Get the relative accuracy.

        获得相对准确性。

        指定者:
        getRelativeAccuracy in interface  UnivariateIntegrator

        界面非变量钢结构中的GetrelativeAccuracy

        返回:
        the accuracy

        准确性

      • getAbsoluteAccuracy

        public double getAbsoluteAccuracy()
        Get the absolute accuracy.

        获得绝对的准确性。

        指定者:
        getAbsoluteAccuracy in interface  UnivariateIntegrator

        在界面单变量钢结构中的GetAbsoluteAccuracy

        返回:
        the accuracy

        准确性

      • getMinimalIterationCount

        public int getMinimalIterationCount()
        Get the min limit for the number of iterations.

        获取迭代次数的最小限制。

        指定者:
        getMinimalIterationCount in interface  UnivariateIntegrator

        interfaceunimalierationcount在一个单变量钢结构中

        返回:
        the actual min limit

        实际最小限制

      • getMaximalIterationCount

        public int getMaximalIterationCount()
        Get the upper limit for the number of iterations.

        获取迭代次数的上限。

        指定者:
        getMaximalIterationCount in interface  UnivariateIntegrator

        interfaceunigatiate inegrator中的getMaximalItrationCount

        返回:
        the actual upper limit

        实际上限

      • getEvaluations

        public int getEvaluations()
        Get the number of function evaluations of the last run of the integrator.

        获取积分器最后一次运行的函数评估数。

        指定者:
        getEvaluations in interface  UnivariateIntegrator

        界面非变量钢结构中的GeteValuation

        返回:
        number of function evaluations

        功能评估数量

      • getIterations

        public int getIterations()
        Get the number of iterations of the last run of the integrator.

        获取积分器最后一次运行的迭代次数。

        指定者:
        getIterations in interface  UnivariateIntegrator

        界面单因素钢结构中的getTeration

        返回:
        number of iterations

        迭代次数

      • incrementCount

        protected void incrementCount()throws MaxCountExceededException
        Increment the number of iterations.

        递增迭代次数。

        抛出:
        MaxCountExceededException - if the number of iterations exceeds the allowed maximum number

        MaxCountExceedEdException - 如果迭代次数超过允许的最大数量

      • getMin

        protected double getMin()
        返回:
        the lower bound.

        下限。

      • getMax

        protected double getMax()
        返回:
        the upper bound.

        上限。

      • computeObjectiveValue

        protected double computeObjectiveValue(double point)throws TooManyEvaluationsException
        Compute the objective function value.

        计算目标函数值。

        参数:
        point - Point at which the objective function must be evaluated.

        要评估目标函数的点点。

        返回:
        the objective function value at specified point.

        指定点的目标函数值。

        抛出:
        TooManyEvaluationsException - if the maximal number of function evaluations is exceeded.

        toomanyevalionsexception - 如果超出了函数评估的最大数量。

      • setup

        protected void setup(int maxEval,UnivariateFunction f,double lower,double upper)throws NullArgumentException,MathIllegalArgumentException
        Prepare for computation. Subclasses must call this method if they override any of the solve methods.

        准备计算。如果覆盖任何求解方法,则子类必须调用此方法。

        参数:
        maxEval - Maximum number of evaluations.

        maxeval - 最大评估数。

        f - the integrand function

        f - Integrand功能

        lower - the min bound for the interval

        降低 - 间隔的最小限制

        upper - the upper bound for the interval

        上限 - 间隔的上限

        抛出:
        NullArgumentException - if f is null.

        nullargumentException - 如果f为null。

        MathIllegalArgumentException - if min >= max.

        MathilleGalargumentException - 如果min> = max。

      • integrate

        public double integrate(int maxEval,UnivariateFunction f,double lower,double upper)throws TooManyEvaluationsException,MaxCountExceededException,MathIllegalArgumentException,NullArgumentException
        Integrate the function in the given interval.

        在给定间隔中集成函数。

        指定者:
        integrate in interface  UnivariateIntegrator

        集成在UnivariateIngator的界面中

        参数:
        maxEval - Maximum number of evaluations.

        maxeval - 最大评估数。

        f - the integrand function

        f - Integrand功能

        lower - the lower bound for the interval

        较低 - 间隔的下限

        upper - the upper bound for the interval

        上限 - 间隔的上限

        返回:
        the value of integral

        积分的价值

        抛出:
        TooManyEvaluationsException - if the maximum number of function evaluations is exceeded

        toomanyevaliveSexception - 如果超过了最大函数评估数

        MaxCountExceededException - if the maximum iteration count is exceeded or the integrator detects convergence problems otherwise

        MaxCountExceedEdException - 如果超出了最大迭代计数,或者积分器否则会检测到融合问题

        MathIllegalArgumentException - if min > max or the endpoints do not satisfy the requirements specified by the integrator

        MathilleGalargumentException - 如果min> max或端点不满足积分器指定的要求

        NullArgumentException - if f is null.

        nullargumentException - 如果f为null。

      • doIntegrate

        protected abstract double doIntegrate()throws TooManyEvaluationsException,MaxCountExceededException
        Method for implementing actual integration algorithms in derived classes.

        在派生类中实现实际集成算法的方法。

        返回:
        the root.

        根。

        抛出:
        TooManyEvaluationsException - if the maximal number of evaluations is exceeded.

        toomanyevalionsexception - 如果超出了最大数量的评估。

        MaxCountExceededException - if the maximum iteration count is exceeded or the integrator detects convergence problems otherwise

        MaxCountExceedEdException - 如果超出了最大迭代计数,或者积分器否则会检测到融合问题

3.2. BaseAbstractUnivariateIntegrator 源码赏析

/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.* The ASF licenses this file to You under the Apache License, Version 2.0* (the "License"); you may not use this file except in compliance with* the License.  You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/
package org.apache.commons.math3.analysis.integration;import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.analysis.solvers.UnivariateSolverUtils;
import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NullArgumentException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
import org.apache.commons.math3.util.IntegerSequence;
import org.apache.commons.math3.util.MathUtils;/*** Provide a default implementation for several generic functions.** @since 1.2*/
public abstract class BaseAbstractUnivariateIntegrator implements UnivariateIntegrator {/** Default absolute accuracy. */public static final double DEFAULT_ABSOLUTE_ACCURACY = 1.0e-15;/** Default relative accuracy. */public static final double DEFAULT_RELATIVE_ACCURACY = 1.0e-6;/** Default minimal iteration count. */public static final int DEFAULT_MIN_ITERATIONS_COUNT = 3;/** Default maximal iteration count. */public static final int DEFAULT_MAX_ITERATIONS_COUNT = Integer.MAX_VALUE;/** The iteration count.* @deprecated as of 3.6, this field has been replaced with {@link #incrementCount()}*/@Deprecatedprotected org.apache.commons.math3.util.Incrementor iterations;/** The iteration count. */private IntegerSequence.Incrementor count;/** Maximum absolute error. */private final double absoluteAccuracy;/** Maximum relative error. */private final double relativeAccuracy;/** minimum number of iterations */private final int minimalIterationCount;/** The functions evaluation count. */private IntegerSequence.Incrementor evaluations;/** Function to integrate. */private UnivariateFunction function;/** Lower bound for the interval. */private double min;/** Upper bound for the interval. */private double max;/*** Construct an integrator with given accuracies and iteration counts.* <p>* The meanings of the various parameters are:* <ul>*   <li>relative accuracy:*       this is used to stop iterations if the absolute accuracy can't be*       achieved due to large values or short mantissa length. If this*       should be the primary criterion for convergence rather then a*       safety measure, set the absolute accuracy to a ridiculously small value,*       like {@link org.apache.commons.math3.util.Precision#SAFE_MIN Precision.SAFE_MIN}.</li>*   <li>absolute accuracy:*       The default is usually chosen so that results in the interval*       -10..-0.1 and +0.1..+10 can be found with a reasonable accuracy. If the*       expected absolute value of your results is of much smaller magnitude, set*       this to a smaller value.</li>*   <li>minimum number of iterations:*       minimal iteration is needed to avoid false early convergence, e.g.*       the sample points happen to be zeroes of the function. Users can*       use the default value or choose one that they see as appropriate.</li>*   <li>maximum number of iterations:*       usually a high iteration count indicates convergence problems. However,*       the "reasonable value" varies widely for different algorithms. Users are*       advised to use the default value supplied by the algorithm.</li>* </ul>** @param relativeAccuracy relative accuracy of the result* @param absoluteAccuracy absolute accuracy of the result* @param minimalIterationCount minimum number of iterations* @param maximalIterationCount maximum number of iterations* @exception NotStrictlyPositiveException if minimal number of iterations* is not strictly positive* @exception NumberIsTooSmallException if maximal number of iterations* is lesser than or equal to the minimal number of iterations*/protected BaseAbstractUnivariateIntegrator(final double relativeAccuracy,final double absoluteAccuracy,final int minimalIterationCount,final int maximalIterationCount)throws NotStrictlyPositiveException, NumberIsTooSmallException {// accuracy settingsthis.relativeAccuracy      = relativeAccuracy;this.absoluteAccuracy      = absoluteAccuracy;// iterations count settingsif (minimalIterationCount <= 0) {throw new NotStrictlyPositiveException(minimalIterationCount);}if (maximalIterationCount <= minimalIterationCount) {throw new NumberIsTooSmallException(maximalIterationCount, minimalIterationCount, false);}this.minimalIterationCount = minimalIterationCount;this.count                 = IntegerSequence.Incrementor.create().withMaximalCount(maximalIterationCount);@SuppressWarnings("deprecation")org.apache.commons.math3.util.Incrementor wrapped =org.apache.commons.math3.util.Incrementor.wrap(count);this.iterations = wrapped;// prepare evaluations counter, but do not set it yetevaluations = IntegerSequence.Incrementor.create();}/*** Construct an integrator with given accuracies.* @param relativeAccuracy relative accuracy of the result* @param absoluteAccuracy absolute accuracy of the result*/protected BaseAbstractUnivariateIntegrator(final double relativeAccuracy,final double absoluteAccuracy) {this(relativeAccuracy, absoluteAccuracy,DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_MAX_ITERATIONS_COUNT);}/*** Construct an integrator with given iteration counts.* @param minimalIterationCount minimum number of iterations* @param maximalIterationCount maximum number of iterations* @exception NotStrictlyPositiveException if minimal number of iterations* is not strictly positive* @exception NumberIsTooSmallException if maximal number of iterations* is lesser than or equal to the minimal number of iterations*/protected BaseAbstractUnivariateIntegrator(final int minimalIterationCount,final int maximalIterationCount)throws NotStrictlyPositiveException, NumberIsTooSmallException {this(DEFAULT_RELATIVE_ACCURACY, DEFAULT_ABSOLUTE_ACCURACY,minimalIterationCount, maximalIterationCount);}/** {@inheritDoc} */public double getRelativeAccuracy() {return relativeAccuracy;}/** {@inheritDoc} */public double getAbsoluteAccuracy() {return absoluteAccuracy;}/** {@inheritDoc} */public int getMinimalIterationCount() {return minimalIterationCount;}/** {@inheritDoc} */public int getMaximalIterationCount() {return count.getMaximalCount();}/** {@inheritDoc} */public int getEvaluations() {return evaluations.getCount();}/** {@inheritDoc} */public int getIterations() {return count.getCount();}/** Increment the number of iterations.* @exception MaxCountExceededException if the number of iterations* exceeds the allowed maximum number*/protected void incrementCount() throws MaxCountExceededException {count.increment();}/*** @return the lower bound.*/protected double getMin() {return min;}/*** @return the upper bound.*/protected double getMax() {return max;}/*** Compute the objective function value.** @param point Point at which the objective function must be evaluated.* @return the objective function value at specified point.* @throws TooManyEvaluationsException if the maximal number of function* evaluations is exceeded.*/protected double computeObjectiveValue(final double point)throws TooManyEvaluationsException {try {evaluations.increment();} catch (MaxCountExceededException e) {throw new TooManyEvaluationsException(e.getMax());}return function.value(point);}/*** Prepare for computation.* Subclasses must call this method if they override any of the* {@code solve} methods.** @param maxEval Maximum number of evaluations.* @param f the integrand function* @param lower the min bound for the interval* @param upper the upper bound for the interval* @throws NullArgumentException if {@code f} is {@code null}.* @throws MathIllegalArgumentException if {@code min >= max}.*/protected void setup(final int maxEval,final UnivariateFunction f,final double lower, final double upper)throws NullArgumentException, MathIllegalArgumentException {// Checks.MathUtils.checkNotNull(f);UnivariateSolverUtils.verifyInterval(lower, upper);// Reset.min = lower;max = upper;function = f;evaluations = evaluations.withMaximalCount(maxEval).withStart(0);count       = count.withStart(0);}/** {@inheritDoc} */public double integrate(final int maxEval, final UnivariateFunction f,final double lower, final double upper)throws TooManyEvaluationsException, MaxCountExceededException,MathIllegalArgumentException, NullArgumentException {// Initialization.setup(maxEval, f, lower, upper);// Perform computation.return doIntegrate();}/*** Method for implementing actual integration algorithms in derived* classes.** @return the root.* @throws TooManyEvaluationsException if the maximal number of evaluations* is exceeded.* @throws MaxCountExceededException if the maximum iteration count is exceeded* or the integrator detects convergence problems otherwise*/protected abstract double doIntegrate()throws TooManyEvaluationsException, MaxCountExceededException;}

4. 类 org.apache.commons.math3.analysis.integration.IterativeLegendreGaussIntegrator

4.1. IterativeLegendreGaussIntegrator 中英对照文档

org.apache.commons.math3.analysis.integration

类 IterativeLegendreGaussIntegrator

  • java.lang.Object
    • org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator
      • org.apache.commons.math3.analysis.integration.IterativeLegendreGaussIntegrator
  • All Implemented Interfaces:
    UnivariateIntegrator

    单抗体钢结构


    public class IterativeLegendreGaussIntegrator
    extends BaseAbstractUnivariateIntegrator
    This algorithm divides the integration interval into equally-sized sub-interval and on each of them performs a Legendre-Gauss quadrature. Because of its non-adaptive nature, this algorithm can converge to a wrong value for the integral (for example, if the function is significantly different from zero toward the ends of the integration interval). In particular, a change of variables aimed at estimating integrals over infinite intervals as proposed here should be avoided when using this class.

    该算法将集成间隔划分为同等大小的子间隔,并且在它们中的每一个上执行Legendre-Gause正交。由于其非自适应性,该算法可以收敛到积分的错误值(例如,如果该功能与集成间隔的结束有显着不同)。特别地,在使用此类时,应避免旨在估计估计无限间隔积分的变量。

    从以下版本开始:
    3.1

    3.1

    • 字段概要

      • Fields inherited from class org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

        DEFAULT_ABSOLUTE_ACCURACY, DEFAULT_MAX_ITERATIONS_COUNT, DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_RELATIVE_ACCURACY, iterations

    • 构造器概要

      构造器  
      构造器和说明
      IterativeLegendreGaussIntegrator(int n, double relativeAccuracy, double absoluteAccuracy)

      Builds an integrator with given accuracies.

      构建具有给定精度的集成商。

      IterativeLegendreGaussIntegrator(int n, double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount)

      Builds an integrator with given accuracies and iterations counts.

      构建具有给定精度和迭代计数的集成商。

      IterativeLegendreGaussIntegrator(int n, int minimalIterationCount, int maximalIterationCount)

      Builds an integrator with given iteration counts.

      构建具有给定迭代计数的集成商。

    • 方法概要

      Methods  
      限定符和类型 方法和说明
      protected double doIntegrate()

      Method for implementing actual integration algorithms in derived classes.

      在派生类中实现实际集成算法的方法。

      • 从类继承的方法 org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

        computeObjectiveValue, getAbsoluteAccuracy, getEvaluations, getIterations, getMax, getMaximalIterationCount, getMin, getMinimalIterationCount, getRelativeAccuracy, incrementCount, integrate, setup

      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    • 构造器详细说明

      • IterativeLegendreGaussIntegrator

        public IterativeLegendreGaussIntegrator(int n,double relativeAccuracy,double absoluteAccuracy,int minimalIterationCount,int maximalIterationCount)throws NotStrictlyPositiveException,NumberIsTooSmallException
        Builds an integrator with given accuracies and iterations counts.

        构建具有给定精度和迭代计数的集成商。

        参数:
        n - Number of integration points.

        n - 集成点数。

        relativeAccuracy - Relative accuracy of the result.

        相对准确性 - 结果的相对准确性。

        absoluteAccuracy - Absolute accuracy of the result.

        绝对准确性 - 结果绝对精度。

        minimalIterationCount - Minimum number of iterations.

        minimaliantationcount - 最小迭代次数。

        maximalIterationCount - Maximum number of iterations.

        maximalimerationcount - 最大迭代次数。

        抛出:
        NotStrictlyPositiveException - if minimal number of iterations or number of points are not strictly positive.

        NOTSTRICLYPositiveException - 如果最小的迭代数或点数并不严格为正。

        NumberIsTooSmallException - if maximal number of iterations is smaller than or equal to the minimal number of iterations.

        numberistoosmallexception - 如果最大次数的迭代次数小于或等于最小的迭代次数。

      • IterativeLegendreGaussIntegrator

        public IterativeLegendreGaussIntegrator(int n,double relativeAccuracy,double absoluteAccuracy)throws NotStrictlyPositiveException
        Builds an integrator with given accuracies.

        构建具有给定精度的集成商。

        参数:
        n - Number of integration points.

        n - 集成点数。

        relativeAccuracy - Relative accuracy of the result.

        相对准确性 - 结果的相对准确性。

        absoluteAccuracy - Absolute accuracy of the result.

        绝对准确性 - 结果绝对精度。

        抛出:
        NotStrictlyPositiveException - if n < 1.

        notstrictypositiveexception - 如果n <1。

      • IterativeLegendreGaussIntegrator

        public IterativeLegendreGaussIntegrator(int n,int minimalIterationCount,int maximalIterationCount)throws NotStrictlyPositiveException,NumberIsTooSmallException
        Builds an integrator with given iteration counts.

        构建具有给定迭代计数的集成商。

        参数:
        n - Number of integration points.

        n - 集成点数。

        minimalIterationCount - Minimum number of iterations.

        minimaliantationcount - 最小迭代次数。

        maximalIterationCount - Maximum number of iterations.

        maximalimerationcount - 最大迭代次数。

        抛出:
        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive.

        NOTSTRICLYPositiveException - 如果最小的迭代次数并不严格积极。

        NumberIsTooSmallException - if maximal number of iterations is smaller than or equal to the minimal number of iterations.

        numberistoosmallexception - 如果最大次数的迭代次数小于或等于最小的迭代次数。

        NotStrictlyPositiveException - if n < 1.

        notstrictypositiveexception - 如果n <1。

    • 方法详细说明

      • doIntegrate

        protected double doIntegrate()throws MathIllegalArgumentException,TooManyEvaluationsException,MaxCountExceededException
        Method for implementing actual integration algorithms in derived classes.

        在派生类中实现实际集成算法的方法。

        指定者:
        doIntegrate in class  BaseAbstractUnivariateIntegrator

        在课堂Baseabstractunigariation integrator中进行了致力于

        返回:
        the root.

        根。

        抛出:
        TooManyEvaluationsException - if the maximal number of evaluations is exceeded.

        toomanyevalionsexception - 如果超出了最大数量的评估。

        MaxCountExceededException - if the maximum iteration count is exceeded or the integrator detects convergence problems otherwise

        MaxCountExceedEdException - 如果超出了最大迭代计数,或者积分器否则会检测到融合问题

        MathIllegalArgumentException

        MathilleGalargumentException.

4.2. IterativeLegendreGaussIntegrator 源码赏析

/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.* The ASF licenses this file to You under the Apache License, Version 2.0* (the "License"); you may not use this file except in compliance with* the License.  You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/
package org.apache.commons.math3.analysis.integration;import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.analysis.integration.gauss.GaussIntegratorFactory;
import org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator;
import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.util.FastMath;/*** This algorithm divides the integration interval into equally-sized* sub-interval and on each of them performs a* <a href="http://mathworld.wolfram.com/Legendre-GaussQuadrature.html">* Legendre-Gauss</a> quadrature.* Because of its <em>non-adaptive</em> nature, this algorithm can* converge to a wrong value for the integral (for example, if the* function is significantly different from zero toward the ends of the* integration interval).* In particular, a change of variables aimed at estimating integrals* over infinite intervals as proposed* <a href="http://en.wikipedia.org/w/index.php?title=Numerical_integration#Integrals_over_infinite_intervals">*  here</a> should be avoided when using this class.** @since 3.1*/public class IterativeLegendreGaussIntegratorextends BaseAbstractUnivariateIntegrator {/** Factory that computes the points and weights. */private static final GaussIntegratorFactory FACTORY= new GaussIntegratorFactory();/** Number of integration points (per interval). */private final int numberOfPoints;/*** Builds an integrator with given accuracies and iterations counts.** @param n Number of integration points.* @param relativeAccuracy Relative accuracy of the result.* @param absoluteAccuracy Absolute accuracy of the result.* @param minimalIterationCount Minimum number of iterations.* @param maximalIterationCount Maximum number of iterations.* @throws NotStrictlyPositiveException if minimal number of iterations* or number of points are not strictly positive.* @throws NumberIsTooSmallException if maximal number of iterations* is smaller than or equal to the minimal number of iterations.*/public IterativeLegendreGaussIntegrator(final int n,final double relativeAccuracy,final double absoluteAccuracy,final int minimalIterationCount,final int maximalIterationCount)throws NotStrictlyPositiveException, NumberIsTooSmallException {super(relativeAccuracy, absoluteAccuracy, minimalIterationCount, maximalIterationCount);if (n <= 0) {throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_POINTS, n);}numberOfPoints = n;}/*** Builds an integrator with given accuracies.** @param n Number of integration points.* @param relativeAccuracy Relative accuracy of the result.* @param absoluteAccuracy Absolute accuracy of the result.* @throws NotStrictlyPositiveException if {@code n < 1}.*/public IterativeLegendreGaussIntegrator(final int n,final double relativeAccuracy,final double absoluteAccuracy)throws NotStrictlyPositiveException {this(n, relativeAccuracy, absoluteAccuracy,DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_MAX_ITERATIONS_COUNT);}/*** Builds an integrator with given iteration counts.** @param n Number of integration points.* @param minimalIterationCount Minimum number of iterations.* @param maximalIterationCount Maximum number of iterations.* @throws NotStrictlyPositiveException if minimal number of iterations* is not strictly positive.* @throws NumberIsTooSmallException if maximal number of iterations* is smaller than or equal to the minimal number of iterations.* @throws NotStrictlyPositiveException if {@code n < 1}.*/public IterativeLegendreGaussIntegrator(final int n,final int minimalIterationCount,final int maximalIterationCount)throws NotStrictlyPositiveException, NumberIsTooSmallException {this(n, DEFAULT_RELATIVE_ACCURACY, DEFAULT_ABSOLUTE_ACCURACY,minimalIterationCount, maximalIterationCount);}/** {@inheritDoc} */@Overrideprotected double doIntegrate()throws MathIllegalArgumentException, TooManyEvaluationsException, MaxCountExceededException {// Compute first estimate with a single step.double oldt = stage(1);int n = 2;while (true) {// Improve integral with a larger number of steps.final double t = stage(n);// Estimate the error.final double delta = FastMath.abs(t - oldt);final double limit =FastMath.max(getAbsoluteAccuracy(),getRelativeAccuracy() * (FastMath.abs(oldt) + FastMath.abs(t)) * 0.5);// check convergenceif (getIterations() + 1 >= getMinimalIterationCount() &&delta <= limit) {return t;}// Prepare next iteration.final double ratio = FastMath.min(4, FastMath.pow(delta / limit, 0.5 / numberOfPoints));n = FastMath.max((int) (ratio * n), n + 1);oldt = t;incrementCount();}}/*** Compute the n-th stage integral.** @param n Number of steps.* @return the value of n-th stage integral.* @throws TooManyEvaluationsException if the maximum number of evaluations* is exceeded.*/private double stage(final int n)throws TooManyEvaluationsException {// Function to be integrated is stored in the base class.final UnivariateFunction f = new UnivariateFunction() {/** {@inheritDoc} */public double value(double x)throws MathIllegalArgumentException, TooManyEvaluationsException {return computeObjectiveValue(x);}};final double min = getMin();final double max = getMax();final double step = (max - min) / n;double sum = 0;for (int i = 0; i < n; i++) {// Integrate over each sub-interval [a, b].final double a = min + i * step;final double b = a + step;final GaussIntegrator g = FACTORY.legendreHighPrecision(numberOfPoints, a, b);sum += g.integrate(f);}return sum;}
}

5. 类 org.apache.commons.math3.analysis.integration.LegendreGaussIntegrator

5.1. LegendreGaussIntegrator 中英对照文档

org.apache.commons.math3.analysis.integration

类 LegendreGaussIntegrator

  • java.lang.Object
    • org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator
      • org.apache.commons.math3.analysis.integration.LegendreGaussIntegrator
  • All Implemented Interfaces:
    UnivariateIntegrator

    单抗体钢结构


    Deprecated.

    As of 3.1 (to be removed in 4.0). Please use IterativeLegendreGaussIntegrator instead.

    截至3.1(4.0中删除)。请使用iterativelegendregaussIntegrator。

    弃用。截至3.1(4.0中删除)。请使用iterativelegendregaussIntegrator。

    @Deprecated
    public class LegendreGaussIntegrator
    extends BaseAbstractUnivariateIntegrator
    Implements the Legendre-Gauss quadrature formula.

    Legendre-Gauss integrators are efficient integrators that can accurately integrate functions with few function evaluations. A Legendre-Gauss integrator using an n-points quadrature formula can integrate 2n-1 degree polynomials exactly.

    These integrators evaluate the function on n carefully chosen abscissas in each step interval (mapped to the canonical [-1,1] interval). The evaluation abscissas are not evenly spaced and none of them are at the interval endpoints. This implies the function integrated can be undefined at integration interval endpoints.

    The evaluation abscissas xi are the roots of the degree n Legendre polynomial. The weights ai of the quadrature formula integrals from -1 to +1 ∫ Li2 where Li (x) = ∏ (x-xk)/(xi-xk) for k != i.

    实现Legendre-Gauss正交公式。Legendre-Gauss Integators是有效的集成商,可以准确地集成功能评估。使用N点正交配方的Legendre-Gauss积分器可以完全集成2N-1度多项式。这些集成商在每个步骤间隔中评估N仔细选择的横坐标的功能(映射到规范[-1,1]间隔)。评估横坐标均匀间隔,并且它们都不是在间隔端点。这意味着集成的功能可以在集成间隔端点处未定义。评估横坐标xi是N型Legendre多项式的根源。从-1到+1≠li2的正交公式的重量ai为k!= i的li(x)=π(x-xk)/(xi-xk)。

    从以下版本开始:
    1.2

    1.2

    • 字段概要

      • Fields inherited from class org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

        DEFAULT_ABSOLUTE_ACCURACY, DEFAULT_MAX_ITERATIONS_COUNT, DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_RELATIVE_ACCURACY, iterations

    • 构造器概要

      构造器  
      构造器和说明
      LegendreGaussIntegrator(int n, double relativeAccuracy, double absoluteAccuracy)

      Deprecated.

      弃用。

      Build a Legendre-Gauss integrator with given accuracies.

      构建具有给定精度的Legendre-Gauss Integrator。

      LegendreGaussIntegrator(int n, double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount)

      Deprecated.

      弃用。

      Build a Legendre-Gauss integrator with given accuracies and iterations counts.

      构建具有给定精度和迭代计数的Legendre-Gauss Integrator。

      LegendreGaussIntegrator(int n, int minimalIterationCount, int maximalIterationCount)

      Deprecated.

      弃用。

      Build a Legendre-Gauss integrator with given iteration counts.

      构建具有给定迭代计数的Legendre-Gauss Integrator。

    • 方法概要

      Methods  
      限定符和类型 方法和说明
      protected double doIntegrate()

      Deprecated.

      弃用。

      Method for implementing actual integration algorithms in derived classes.

      在派生类中实现实际集成算法的方法。

      • 从类继承的方法 org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

        computeObjectiveValue, getAbsoluteAccuracy, getEvaluations, getIterations, getMax, getMaximalIterationCount, getMin, getMinimalIterationCount, getRelativeAccuracy, incrementCount, integrate, setup

      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    • 构造器详细说明

      • LegendreGaussIntegrator

        public LegendreGaussIntegrator(int n,double relativeAccuracy,double absoluteAccuracy,int minimalIterationCount,int maximalIterationCount)throws MathIllegalArgumentException,NotStrictlyPositiveException,NumberIsTooSmallException
        Deprecated.

        弃用。

        Build a Legendre-Gauss integrator with given accuracies and iterations counts.

        构建具有给定精度和迭代计数的Legendre-Gauss Integrator。

        参数:
        n - number of points desired (must be between 2 and 5 inclusive)

        n - 所需的点数(必须在2到5之间)

        relativeAccuracy - relative accuracy of the result

        相对准确性 - 结果的相对准确性

        absoluteAccuracy - absolute accuracy of the result

        绝对精度 - 结果绝对准确性

        minimalIterationCount - minimum number of iterations

        minimalitorioncount - 最小迭代次数

        maximalIterationCount - maximum number of iterations

        maximalimerationcount - 最大迭代次数

        抛出:
        MathIllegalArgumentException - if number of points is out of [2; 5]

        MathilleGalargumentException - 如果点数超出[2;5]

        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive

        NOTSTRICLYPOSIVEIVEEXception - 如果最小的迭代数量并不严格积极

        NumberIsTooSmallException - if maximal number of iterations is lesser than or equal to the minimal number of iterations

        numberistoosmallexception - 如果最大迭代次数小于或等于最小数量的迭代次数

      • LegendreGaussIntegrator

        public LegendreGaussIntegrator(int n,double relativeAccuracy,double absoluteAccuracy)throws MathIllegalArgumentException
        Deprecated.

        弃用。

        Build a Legendre-Gauss integrator with given accuracies.

        构建具有给定精度的Legendre-Gauss Integrator。

        参数:
        n - number of points desired (must be between 2 and 5 inclusive)

        n - 所需的点数(必须在2到5之间)

        relativeAccuracy - relative accuracy of the result

        相对准确性 - 结果的相对准确性

        absoluteAccuracy - absolute accuracy of the result

        绝对精度 - 结果绝对准确性

        抛出:
        MathIllegalArgumentException - if number of points is out of [2; 5]

        MathilleGalargumentException - 如果点数超出[2;5]

      • LegendreGaussIntegrator

        public LegendreGaussIntegrator(int n,int minimalIterationCount,int maximalIterationCount)throws MathIllegalArgumentException
        Deprecated.

        弃用。

        Build a Legendre-Gauss integrator with given iteration counts.

        构建具有给定迭代计数的Legendre-Gauss Integrator。

        参数:
        n - number of points desired (must be between 2 and 5 inclusive)

        n - 所需的点数(必须在2到5之间)

        minimalIterationCount - minimum number of iterations

        minimalitorioncount - 最小迭代次数

        maximalIterationCount - maximum number of iterations

        maximalimerationcount - 最大迭代次数

        抛出:
        MathIllegalArgumentException - if number of points is out of [2; 5]

        MathilleGalargumentException - 如果点数超出[2;5]

        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive

        NOTSTRICLYPOSIVEIVEEXception - 如果最小的迭代数量并不严格积极

        NumberIsTooSmallException - if maximal number of iterations is lesser than or equal to the minimal number of iterations

        numberistoosmallexception - 如果最大迭代次数小于或等于最小数量的迭代次数

    • 方法详细说明

      • doIntegrate

        protected double doIntegrate()throws MathIllegalArgumentException,TooManyEvaluationsException,MaxCountExceededException
        Deprecated.

        弃用。

        Method for implementing actual integration algorithms in derived classes.

        在派生类中实现实际集成算法的方法。

        指定者:
        doIntegrate in class  BaseAbstractUnivariateIntegrator

        在课堂Baseabstractunigariation integrator中进行了致力于

        返回:
        the root.

        根。

        抛出:
        TooManyEvaluationsException - if the maximal number of evaluations is exceeded.

        toomanyevalionsexception - 如果超出了最大数量的评估。

        MaxCountExceededException - if the maximum iteration count is exceeded or the integrator detects convergence problems otherwise

        MaxCountExceedEdException - 如果超出了最大迭代计数,或者积分器否则会检测到融合问题

        MathIllegalArgumentException

        MathilleGalargumentException.

5.2. LegendreGaussIntegrator 源码赏析

/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.* The ASF licenses this file to You under the Apache License, Version 2.0* (the "License"); you may not use this file except in compliance with* the License.  You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/
package org.apache.commons.math3.analysis.integration;import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
import org.apache.commons.math3.exception.util.LocalizedFormats;
import org.apache.commons.math3.util.FastMath;/*** Implements the <a href="http://mathworld.wolfram.com/Legendre-GaussQuadrature.html">* Legendre-Gauss</a> quadrature formula.* <p>* Legendre-Gauss integrators are efficient integrators that can* accurately integrate functions with few function evaluations. A* Legendre-Gauss integrator using an n-points quadrature formula can* integrate 2n-1 degree polynomials exactly.* </p>* <p>* These integrators evaluate the function on n carefully chosen* abscissas in each step interval (mapped to the canonical [-1,1] interval).* The evaluation abscissas are not evenly spaced and none of them are* at the interval endpoints. This implies the function integrated can be* undefined at integration interval endpoints.* </p>* <p>* The evaluation abscissas x<sub>i</sub> are the roots of the degree n* Legendre polynomial. The weights a<sub>i</sub> of the quadrature formula* integrals from -1 to +1 &int; Li<sup>2</sup> where Li (x) =* &prod; (x-x<sub>k</sub>)/(x<sub>i</sub>-x<sub>k</sub>) for k != i.* </p>* <p>* @since 1.2* @deprecated As of 3.1 (to be removed in 4.0). Please use* {@link IterativeLegendreGaussIntegrator} instead.*/
@Deprecated
public class LegendreGaussIntegrator extends BaseAbstractUnivariateIntegrator {/** Abscissas for the 2 points method. */private static final double[] ABSCISSAS_2 = {-1.0 / FastMath.sqrt(3.0),1.0 / FastMath.sqrt(3.0)};/** Weights for the 2 points method. */private static final double[] WEIGHTS_2 = {1.0,1.0};/** Abscissas for the 3 points method. */private static final double[] ABSCISSAS_3 = {-FastMath.sqrt(0.6),0.0,FastMath.sqrt(0.6)};/** Weights for the 3 points method. */private static final double[] WEIGHTS_3 = {5.0 / 9.0,8.0 / 9.0,5.0 / 9.0};/** Abscissas for the 4 points method. */private static final double[] ABSCISSAS_4 = {-FastMath.sqrt((15.0 + 2.0 * FastMath.sqrt(30.0)) / 35.0),-FastMath.sqrt((15.0 - 2.0 * FastMath.sqrt(30.0)) / 35.0),FastMath.sqrt((15.0 - 2.0 * FastMath.sqrt(30.0)) / 35.0),FastMath.sqrt((15.0 + 2.0 * FastMath.sqrt(30.0)) / 35.0)};/** Weights for the 4 points method. */private static final double[] WEIGHTS_4 = {(90.0 - 5.0 * FastMath.sqrt(30.0)) / 180.0,(90.0 + 5.0 * FastMath.sqrt(30.0)) / 180.0,(90.0 + 5.0 * FastMath.sqrt(30.0)) / 180.0,(90.0 - 5.0 * FastMath.sqrt(30.0)) / 180.0};/** Abscissas for the 5 points method. */private static final double[] ABSCISSAS_5 = {-FastMath.sqrt((35.0 + 2.0 * FastMath.sqrt(70.0)) / 63.0),-FastMath.sqrt((35.0 - 2.0 * FastMath.sqrt(70.0)) / 63.0),0.0,FastMath.sqrt((35.0 - 2.0 * FastMath.sqrt(70.0)) / 63.0),FastMath.sqrt((35.0 + 2.0 * FastMath.sqrt(70.0)) / 63.0)};/** Weights for the 5 points method. */private static final double[] WEIGHTS_5 = {(322.0 - 13.0 * FastMath.sqrt(70.0)) / 900.0,(322.0 + 13.0 * FastMath.sqrt(70.0)) / 900.0,128.0 / 225.0,(322.0 + 13.0 * FastMath.sqrt(70.0)) / 900.0,(322.0 - 13.0 * FastMath.sqrt(70.0)) / 900.0};/** Abscissas for the current method. */private final double[] abscissas;/** Weights for the current method. */private final double[] weights;/*** Build a Legendre-Gauss integrator with given accuracies and iterations counts.* @param n number of points desired (must be between 2 and 5 inclusive)* @param relativeAccuracy relative accuracy of the result* @param absoluteAccuracy absolute accuracy of the result* @param minimalIterationCount minimum number of iterations* @param maximalIterationCount maximum number of iterations* @exception MathIllegalArgumentException if number of points is out of [2; 5]* @exception NotStrictlyPositiveException if minimal number of iterations* is not strictly positive* @exception NumberIsTooSmallException if maximal number of iterations* is lesser than or equal to the minimal number of iterations*/public LegendreGaussIntegrator(final int n,final double relativeAccuracy,final double absoluteAccuracy,final int minimalIterationCount,final int maximalIterationCount)throws MathIllegalArgumentException, NotStrictlyPositiveException, NumberIsTooSmallException {super(relativeAccuracy, absoluteAccuracy, minimalIterationCount, maximalIterationCount);switch(n) {case 2 :abscissas = ABSCISSAS_2;weights   = WEIGHTS_2;break;case 3 :abscissas = ABSCISSAS_3;weights   = WEIGHTS_3;break;case 4 :abscissas = ABSCISSAS_4;weights   = WEIGHTS_4;break;case 5 :abscissas = ABSCISSAS_5;weights   = WEIGHTS_5;break;default :throw new MathIllegalArgumentException(LocalizedFormats.N_POINTS_GAUSS_LEGENDRE_INTEGRATOR_NOT_SUPPORTED,n, 2, 5);}}/*** Build a Legendre-Gauss integrator with given accuracies.* @param n number of points desired (must be between 2 and 5 inclusive)* @param relativeAccuracy relative accuracy of the result* @param absoluteAccuracy absolute accuracy of the result* @exception MathIllegalArgumentException if number of points is out of [2; 5]*/public LegendreGaussIntegrator(final int n,final double relativeAccuracy,final double absoluteAccuracy)throws MathIllegalArgumentException {this(n, relativeAccuracy, absoluteAccuracy,DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_MAX_ITERATIONS_COUNT);}/*** Build a Legendre-Gauss integrator with given iteration counts.* @param n number of points desired (must be between 2 and 5 inclusive)* @param minimalIterationCount minimum number of iterations* @param maximalIterationCount maximum number of iterations* @exception MathIllegalArgumentException if number of points is out of [2; 5]* @exception NotStrictlyPositiveException if minimal number of iterations* is not strictly positive* @exception NumberIsTooSmallException if maximal number of iterations* is lesser than or equal to the minimal number of iterations*/public LegendreGaussIntegrator(final int n,final int minimalIterationCount,final int maximalIterationCount)throws MathIllegalArgumentException {this(n, DEFAULT_RELATIVE_ACCURACY, DEFAULT_ABSOLUTE_ACCURACY,minimalIterationCount, maximalIterationCount);}/** {@inheritDoc} */@Overrideprotected double doIntegrate()throws MathIllegalArgumentException, TooManyEvaluationsException, MaxCountExceededException {// compute first estimate with a single stepdouble oldt = stage(1);int n = 2;while (true) {// improve integral with a larger number of stepsfinal double t = stage(n);// estimate errorfinal double delta = FastMath.abs(t - oldt);final double limit =FastMath.max(getAbsoluteAccuracy(),getRelativeAccuracy() * (FastMath.abs(oldt) + FastMath.abs(t)) * 0.5);// check convergenceif ((getIterations() + 1 >= getMinimalIterationCount()) && (delta <= limit)) {return t;}// prepare next iterationdouble ratio = FastMath.min(4, FastMath.pow(delta / limit, 0.5 / abscissas.length));n = FastMath.max((int) (ratio * n), n + 1);oldt = t;incrementCount();}}/*** Compute the n-th stage integral.* @param n number of steps* @return the value of n-th stage integral* @throws TooManyEvaluationsException if the maximum number of evaluations* is exceeded.*/private double stage(final int n)throws TooManyEvaluationsException {// set up the step for the current stagefinal double step     = (getMax() - getMin()) / n;final double halfStep = step / 2.0;// integrate over all elementary stepsdouble midPoint = getMin() + halfStep;double sum = 0.0;for (int i = 0; i < n; ++i) {for (int j = 0; j < abscissas.length; ++j) {sum += weights[j] * computeObjectiveValue(midPoint + halfStep * abscissas[j]);}midPoint += step;}return halfStep * sum;}}

6. 类 org.apache.commons.math3.analysis.integration.MidPointIntegrator

6.1. MidPointIntegrator 中英对照文档

org.apache.commons.math3.analysis.integration

类 MidPointIntegrator

  • java.lang.Object
    • org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator
      • org.apache.commons.math3.analysis.integration.MidPointIntegrator
  • All Implemented Interfaces:
    UnivariateIntegrator

    单抗体钢结构


    public class MidPointIntegrator
    extends BaseAbstractUnivariateIntegrator
    Implements the Midpoint Rule for integration of real univariate functions. For reference, see Numerical Mathematics, ISBN 0387989595, chapter 9.2.

    The function should be integrable.

    实现中点规则,以实现实际单变量函数的集成。参考,见数字数学,ISBN 0387989595,第9.2章。该功能应该是可集成的。

    从以下版本开始:
    3.3

    3.3

    • 字段概要

      字段  
      限定符和类型 Field and 的说明
      static int MIDPOINT_MAX_ITERATIONS_COUNT

      Maximum number of iterations for midpoint.

      中点的最大迭代次数。

      • Fields inherited from class org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

        DEFAULT_ABSOLUTE_ACCURACY, DEFAULT_MAX_ITERATIONS_COUNT, DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_RELATIVE_ACCURACY, iterations

    • 构造器概要

      构造器  
      构造器和说明
      MidPointIntegrator()

      Construct a midpoint integrator with default settings.

      使用默认设置构造中点积分器。

      MidPointIntegrator(double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount)

      Build a midpoint integrator with given accuracies and iterations counts.

      构建具有给定精度和迭代计数的中点积分器。

      MidPointIntegrator(int minimalIterationCount, int maximalIterationCount)

      Build a midpoint integrator with given iteration counts.

      构建具有给定迭代计数的中点积分器。

    • 方法概要

      Methods  
      限定符和类型 方法和说明
      protected double doIntegrate()

      Method for implementing actual integration algorithms in derived classes.

      在派生类中实现实际集成算法的方法。

      • 从类继承的方法 org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

        computeObjectiveValue, getAbsoluteAccuracy, getEvaluations, getIterations, getMax, getMaximalIterationCount, getMin, getMinimalIterationCount, getRelativeAccuracy, incrementCount, integrate, setup

      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    • 字段详情:

      • MIDPOINT_MAX_ITERATIONS_COUNT

        public static final int MIDPOINT_MAX_ITERATIONS_COUNT
        Maximum number of iterations for midpoint.

        中点的最大迭代次数。

        另请参阅:
        Constant Field Values

        恒定字段值

    • 构造器详细说明

      • MidPointIntegrator

        public MidPointIntegrator(double relativeAccuracy,double absoluteAccuracy,int minimalIterationCount,int maximalIterationCount)throws NotStrictlyPositiveException,NumberIsTooSmallException,NumberIsTooLargeException
        Build a midpoint integrator with given accuracies and iterations counts.

        构建具有给定精度和迭代计数的中点积分器。

        参数:
        relativeAccuracy - relative accuracy of the result

        相对准确性 - 结果的相对准确性

        absoluteAccuracy - absolute accuracy of the result

        绝对精度 - 结果绝对准确性

        minimalIterationCount - minimum number of iterations

        minimalitorioncount - 最小迭代次数

        maximalIterationCount - maximum number of iterations (must be less than or equal to MIDPOINT_MAX_ITERATIONS_COUNT

        maximalimerationcount - 最大迭代次数(必须小于或等于midpoint_max_iterations_count

        抛出:
        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive

        NOTSTRICLYPOSIVEIVEEXception - 如果最小的迭代数量并不严格积极

        NumberIsTooSmallException - if maximal number of iterations is lesser than or equal to the minimal number of iterations

        numberistoosmallexception - 如果最大迭代次数小于或等于最小数量的迭代次数

        NumberIsTooLargeException - if maximal number of iterations is greater than MIDPOINT_MAX_ITERATIONS_COUNT

        NumberStoolArgeException - 如果最大迭代次数大于MIDPOINT_MAX_ITERATIONS_COUNT

      • MidPointIntegrator

        public MidPointIntegrator(int minimalIterationCount,int maximalIterationCount)throws NotStrictlyPositiveException,NumberIsTooSmallException,NumberIsTooLargeException
        Build a midpoint integrator with given iteration counts.

        构建具有给定迭代计数的中点积分器。

        参数:
        minimalIterationCount - minimum number of iterations

        minimalitorioncount - 最小迭代次数

        maximalIterationCount - maximum number of iterations (must be less than or equal to MIDPOINT_MAX_ITERATIONS_COUNT

        maximalimerationcount - 最大迭代次数(必须小于或等于midpoint_max_iterations_count

        抛出:
        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive

        NOTSTRICLYPOSIVEIVEEXception - 如果最小的迭代数量并不严格积极

        NumberIsTooSmallException - if maximal number of iterations is lesser than or equal to the minimal number of iterations

        numberistoosmallexception - 如果最大迭代次数小于或等于最小数量的迭代次数

        NumberIsTooLargeException - if maximal number of iterations is greater than MIDPOINT_MAX_ITERATIONS_COUNT

        NumberStoolArgeException - 如果最大迭代次数大于MIDPOINT_MAX_ITERATIONS_COUNT

      • MidPointIntegrator

        public MidPointIntegrator()
        Construct a midpoint integrator with default settings. (max iteration count set to MIDPOINT_MAX_ITERATIONS_COUNT)

        使用默认设置构造中点积分器。(最多迭代计数设置为midpoint_max_Iterations_count)

    • 方法详细说明

      • doIntegrate

        protected double doIntegrate()throws MathIllegalArgumentException,TooManyEvaluationsException,MaxCountExceededException
        Method for implementing actual integration algorithms in derived classes.

        在派生类中实现实际集成算法的方法。

        指定者:
        doIntegrate in class  BaseAbstractUnivariateIntegrator

        在课堂Baseabstractunigariation integrator中进行了致力于

        返回:
        the root.

        根。

        抛出:
        TooManyEvaluationsException - if the maximal number of evaluations is exceeded.

        toomanyevalionsexception - 如果超出了最大数量的评估。

        MaxCountExceededException - if the maximum iteration count is exceeded or the integrator detects convergence problems otherwise

        MaxCountExceedEdException - 如果超出了最大迭代计数,或者积分器否则会检测到融合问题

        MathIllegalArgumentException

        MathilleGalargumentException.

6.2. MidPointIntegrator 源码赏析

/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.* The ASF licenses this file to You under the Apache License, Version 2.0* (the "License"); you may not use this file except in compliance with* the License.  You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/
package org.apache.commons.math3.analysis.integration;import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
import org.apache.commons.math3.util.FastMath;/*** Implements the <a href="http://en.wikipedia.org/wiki/Midpoint_method">* Midpoint Rule</a> for integration of real univariate functions. For* reference, see <b>Numerical Mathematics</b>, ISBN 0387989595,* chapter 9.2.* <p>* The function should be integrable.</p>** @since 3.3*/
public class MidPointIntegrator extends BaseAbstractUnivariateIntegrator {/** Maximum number of iterations for midpoint. */public static final int MIDPOINT_MAX_ITERATIONS_COUNT = 64;/*** Build a midpoint integrator with given accuracies and iterations counts.* @param relativeAccuracy relative accuracy of the result* @param absoluteAccuracy absolute accuracy of the result* @param minimalIterationCount minimum number of iterations* @param maximalIterationCount maximum number of iterations* (must be less than or equal to {@link #MIDPOINT_MAX_ITERATIONS_COUNT}* @exception NotStrictlyPositiveException if minimal number of iterations* is not strictly positive* @exception NumberIsTooSmallException if maximal number of iterations* is lesser than or equal to the minimal number of iterations* @exception NumberIsTooLargeException if maximal number of iterations* is greater than {@link #MIDPOINT_MAX_ITERATIONS_COUNT}*/public MidPointIntegrator(final double relativeAccuracy,final double absoluteAccuracy,final int minimalIterationCount,final int maximalIterationCount)throws NotStrictlyPositiveException, NumberIsTooSmallException, NumberIsTooLargeException {super(relativeAccuracy, absoluteAccuracy, minimalIterationCount, maximalIterationCount);if (maximalIterationCount > MIDPOINT_MAX_ITERATIONS_COUNT) {throw new NumberIsTooLargeException(maximalIterationCount,MIDPOINT_MAX_ITERATIONS_COUNT, false);}}/*** Build a midpoint integrator with given iteration counts.* @param minimalIterationCount minimum number of iterations* @param maximalIterationCount maximum number of iterations* (must be less than or equal to {@link #MIDPOINT_MAX_ITERATIONS_COUNT}* @exception NotStrictlyPositiveException if minimal number of iterations* is not strictly positive* @exception NumberIsTooSmallException if maximal number of iterations* is lesser than or equal to the minimal number of iterations* @exception NumberIsTooLargeException if maximal number of iterations* is greater than {@link #MIDPOINT_MAX_ITERATIONS_COUNT}*/public MidPointIntegrator(final int minimalIterationCount,final int maximalIterationCount)throws NotStrictlyPositiveException, NumberIsTooSmallException, NumberIsTooLargeException {super(minimalIterationCount, maximalIterationCount);if (maximalIterationCount > MIDPOINT_MAX_ITERATIONS_COUNT) {throw new NumberIsTooLargeException(maximalIterationCount,MIDPOINT_MAX_ITERATIONS_COUNT, false);}}/*** Construct a midpoint integrator with default settings.* (max iteration count set to {@link #MIDPOINT_MAX_ITERATIONS_COUNT})*/public MidPointIntegrator() {super(DEFAULT_MIN_ITERATIONS_COUNT, MIDPOINT_MAX_ITERATIONS_COUNT);}/*** Compute the n-th stage integral of midpoint rule.* This function should only be called by API <code>integrate()</code> in the package.* To save time it does not verify arguments - caller does.* <p>* The interval is divided equally into 2^n sections rather than an* arbitrary m sections because this configuration can best utilize the* already computed values.</p>** @param n the stage of 1/2 refinement. Must be larger than 0.* @param previousStageResult Result from the previous call to the* {@code stage} method.* @param min Lower bound of the integration interval.* @param diffMaxMin Difference between the lower bound and upper bound* of the integration interval.* @return the value of n-th stage integral* @throws TooManyEvaluationsException if the maximal number of evaluations* is exceeded.*/private double stage(final int n,double previousStageResult,double min,double diffMaxMin)throws TooManyEvaluationsException {// number of new points in this stagefinal long np = 1L << (n - 1);double sum = 0;// spacing between adjacent new pointsfinal double spacing = diffMaxMin / np;// the first new pointdouble x = min + 0.5 * spacing;for (long i = 0; i < np; i++) {sum += computeObjectiveValue(x);x += spacing;}// add the new sum to previously calculated resultreturn 0.5 * (previousStageResult + sum * spacing);}/** {@inheritDoc} */@Overrideprotected double doIntegrate()throws MathIllegalArgumentException, TooManyEvaluationsException, MaxCountExceededException {final double min = getMin();final double diff = getMax() - min;final double midPoint = min + 0.5 * diff;double oldt = diff * computeObjectiveValue(midPoint);while (true) {incrementCount();final int i = getIterations();final double t = stage(i, oldt, min, diff);if (i >= getMinimalIterationCount()) {final double delta = FastMath.abs(t - oldt);final double rLimit =getRelativeAccuracy() * (FastMath.abs(oldt) + FastMath.abs(t)) * 0.5;if ((delta <= rLimit) || (delta <= getAbsoluteAccuracy())) {return t;}}oldt = t;}}}

7. 类 org.apache.commons.math3.analysis.integration.RombergIntegrator

7.1. RombergIntegrator 中英对照文档

org.apache.commons.math3.analysis.integration

类 RombergIntegrator

  • java.lang.Object
    • org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator
      • org.apache.commons.math3.analysis.integration.RombergIntegrator
  • All Implemented Interfaces:
    UnivariateIntegrator

    单抗体钢结构


    public class RombergIntegrator
    extends BaseAbstractUnivariateIntegrator
    Implements the Romberg Algorithm for integration of real univariate functions. For reference, see Introduction to Numerical Analysis, ISBN 038795452X, chapter 3.

    Romberg integration employs k successive refinements of the trapezoid rule to remove error terms less than order O(N^(-2k)). Simpson's rule is a special case of k = 2.

    实现romberg算法,以集成真正的单变量函数。参见,参见数值分析简介,ISBN 038795452x,第3章romberg集成采用梯形规则的k连续改进,以删除比Order O的错误条款(n ^( - 2k))。辛普森的规则是k = 2的特殊情况。

    从以下版本开始:
    1.2

    1.2

    • 字段概要

      字段  
      限定符和类型 Field and 的说明
      static int ROMBERG_MAX_ITERATIONS_COUNT

      Maximal number of iterations for Romberg.

      Romberg的最大迭代次数。

      • Fields inherited from class org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

        DEFAULT_ABSOLUTE_ACCURACY, DEFAULT_MAX_ITERATIONS_COUNT, DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_RELATIVE_ACCURACY, iterations

    • 构造器概要

      构造器  
      构造器和说明
      RombergIntegrator()

      Construct a Romberg integrator with default settings (max iteration count set to ROMBERG_MAX_ITERATIONS_COUNT)

      构建具有默认设置的romberg集成商(Max Iteration Count设置为romberg_max_iterations_count)

      RombergIntegrator(double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount)

      Build a Romberg integrator with given accuracies and iterations counts.

      构建具有给定精度和迭代计数的romberg Integrator。

      RombergIntegrator(int minimalIterationCount, int maximalIterationCount)

      Build a Romberg integrator with given iteration counts.

      构建带有迭代计数的romberg集成商。

    • 方法概要

      Methods  
      限定符和类型 方法和说明
      protected double doIntegrate()

      Method for implementing actual integration algorithms in derived classes.

      在派生类中实现实际集成算法的方法。

      • 从类继承的方法 org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

        computeObjectiveValue, getAbsoluteAccuracy, getEvaluations, getIterations, getMax, getMaximalIterationCount, getMin, getMinimalIterationCount, getRelativeAccuracy, incrementCount, integrate, setup

      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    • 字段详情:

      • ROMBERG_MAX_ITERATIONS_COUNT

        public static final int ROMBERG_MAX_ITERATIONS_COUNT
        Maximal number of iterations for Romberg.

        Romberg的最大迭代次数。

        另请参阅:
        Constant Field Values

        恒定字段值

    • 构造器详细说明

      • RombergIntegrator

        public RombergIntegrator(double relativeAccuracy,double absoluteAccuracy,int minimalIterationCount,int maximalIterationCount)throws NotStrictlyPositiveException,NumberIsTooSmallException,NumberIsTooLargeException
        Build a Romberg integrator with given accuracies and iterations counts.

        构建具有给定精度和迭代计数的romberg Integrator。

        参数:
        relativeAccuracy - relative accuracy of the result

        相对准确性 - 结果的相对准确性

        absoluteAccuracy - absolute accuracy of the result

        绝对精度 - 结果绝对准确性

        minimalIterationCount - minimum number of iterations

        minimalitorioncount - 最小迭代次数

        maximalIterationCount - maximum number of iterations (must be less than or equal to ROMBERG_MAX_ITERATIONS_COUNT)

        maximalimerationcount - 最大迭代次数(必须小于或等于romberg_max_iterations_count)

        抛出:
        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive

        NOTSTRICLYPOSIVEIVEEXception - 如果最小的迭代数量并不严格积极

        NumberIsTooSmallException - if maximal number of iterations is lesser than or equal to the minimal number of iterations

        numberistoosmallexception - 如果最大迭代次数小于或等于最小数量的迭代次数

        NumberIsTooLargeException - if maximal number of iterations is greater than ROMBERG_MAX_ITERATIONS_COUNT

        NumberStoolarGeexception - 如果最大迭代次数大于romberg_max_iterations_count

      • RombergIntegrator

        public RombergIntegrator(int minimalIterationCount,int maximalIterationCount)throws NotStrictlyPositiveException,NumberIsTooSmallException,NumberIsTooLargeException
        Build a Romberg integrator with given iteration counts.

        构建带有迭代计数的romberg集成商。

        参数:
        minimalIterationCount - minimum number of iterations

        minimalitorioncount - 最小迭代次数

        maximalIterationCount - maximum number of iterations (must be less than or equal to ROMBERG_MAX_ITERATIONS_COUNT)

        maximalimerationcount - 最大迭代次数(必须小于或等于romberg_max_iterations_count)

        抛出:
        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive

        NOTSTRICLYPOSIVEIVEEXception - 如果最小的迭代数量并不严格积极

        NumberIsTooSmallException - if maximal number of iterations is lesser than or equal to the minimal number of iterations

        numberistoosmallexception - 如果最大迭代次数小于或等于最小数量的迭代次数

        NumberIsTooLargeException - if maximal number of iterations is greater than ROMBERG_MAX_ITERATIONS_COUNT

        NumberStoolarGeexception - 如果最大迭代次数大于romberg_max_iterations_count

      • RombergIntegrator

        public RombergIntegrator()
        Construct a Romberg integrator with default settings (max iteration count set to ROMBERG_MAX_ITERATIONS_COUNT)

        构建具有默认设置的romberg集成商(Max Iteration Count设置为romberg_max_iterations_count)

    • 方法详细说明

      • doIntegrate

        protected double doIntegrate()throws TooManyEvaluationsException,MaxCountExceededException
        Method for implementing actual integration algorithms in derived classes.

        在派生类中实现实际集成算法的方法。

        指定者:
        doIntegrate in class  BaseAbstractUnivariateIntegrator

        在课堂Baseabstractunigariation integrator中进行了致力于

        返回:
        the root.

        根。

        抛出:
        TooManyEvaluationsException - if the maximal number of evaluations is exceeded.

        toomanyevalionsexception - 如果超出了最大数量的评估。

        MaxCountExceededException - if the maximum iteration count is exceeded or the integrator detects convergence problems otherwise

        MaxCountExceedEdException - 如果超出了最大迭代计数,或者积分器否则会检测到融合问题

7.2. RombergIntegrator 源码赏析

/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.* The ASF licenses this file to You under the Apache License, Version 2.0* (the "License"); you may not use this file except in compliance with* the License.  You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/
package org.apache.commons.math3.analysis.integration;import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
import org.apache.commons.math3.util.FastMath;/*** Implements the <a href="http://mathworld.wolfram.com/RombergIntegration.html">* Romberg Algorithm</a> for integration of real univariate functions. For* reference, see <b>Introduction to Numerical Analysis</b>, ISBN 038795452X,* chapter 3.* <p>* Romberg integration employs k successive refinements of the trapezoid* rule to remove error terms less than order O(N^(-2k)). Simpson's rule* is a special case of k = 2.</p>** @since 1.2*/
public class RombergIntegrator extends BaseAbstractUnivariateIntegrator {/** Maximal number of iterations for Romberg. */public static final int ROMBERG_MAX_ITERATIONS_COUNT = 32;/*** Build a Romberg integrator with given accuracies and iterations counts.* @param relativeAccuracy relative accuracy of the result* @param absoluteAccuracy absolute accuracy of the result* @param minimalIterationCount minimum number of iterations* @param maximalIterationCount maximum number of iterations* (must be less than or equal to {@link #ROMBERG_MAX_ITERATIONS_COUNT})* @exception NotStrictlyPositiveException if minimal number of iterations* is not strictly positive* @exception NumberIsTooSmallException if maximal number of iterations* is lesser than or equal to the minimal number of iterations* @exception NumberIsTooLargeException if maximal number of iterations* is greater than {@link #ROMBERG_MAX_ITERATIONS_COUNT}*/public RombergIntegrator(final double relativeAccuracy,final double absoluteAccuracy,final int minimalIterationCount,final int maximalIterationCount)throws NotStrictlyPositiveException, NumberIsTooSmallException, NumberIsTooLargeException {super(relativeAccuracy, absoluteAccuracy, minimalIterationCount, maximalIterationCount);if (maximalIterationCount > ROMBERG_MAX_ITERATIONS_COUNT) {throw new NumberIsTooLargeException(maximalIterationCount,ROMBERG_MAX_ITERATIONS_COUNT, false);}}/*** Build a Romberg integrator with given iteration counts.* @param minimalIterationCount minimum number of iterations* @param maximalIterationCount maximum number of iterations* (must be less than or equal to {@link #ROMBERG_MAX_ITERATIONS_COUNT})* @exception NotStrictlyPositiveException if minimal number of iterations* is not strictly positive* @exception NumberIsTooSmallException if maximal number of iterations* is lesser than or equal to the minimal number of iterations* @exception NumberIsTooLargeException if maximal number of iterations* is greater than {@link #ROMBERG_MAX_ITERATIONS_COUNT}*/public RombergIntegrator(final int minimalIterationCount,final int maximalIterationCount)throws NotStrictlyPositiveException, NumberIsTooSmallException, NumberIsTooLargeException {super(minimalIterationCount, maximalIterationCount);if (maximalIterationCount > ROMBERG_MAX_ITERATIONS_COUNT) {throw new NumberIsTooLargeException(maximalIterationCount,ROMBERG_MAX_ITERATIONS_COUNT, false);}}/*** Construct a Romberg integrator with default settings* (max iteration count set to {@link #ROMBERG_MAX_ITERATIONS_COUNT})*/public RombergIntegrator() {super(DEFAULT_MIN_ITERATIONS_COUNT, ROMBERG_MAX_ITERATIONS_COUNT);}/** {@inheritDoc} */@Overrideprotected double doIntegrate()throws TooManyEvaluationsException, MaxCountExceededException {final int m = getMaximalIterationCount() + 1;double previousRow[] = new double[m];double currentRow[]  = new double[m];TrapezoidIntegrator qtrap = new TrapezoidIntegrator();currentRow[0] = qtrap.stage(this, 0);incrementCount();double olds = currentRow[0];while (true) {final int i = getIterations();// switch rowsfinal double[] tmpRow = previousRow;previousRow = currentRow;currentRow = tmpRow;currentRow[0] = qtrap.stage(this, i);incrementCount();for (int j = 1; j <= i; j++) {// Richardson extrapolation coefficientfinal double r = (1L << (2 * j)) - 1;final double tIJm1 = currentRow[j - 1];currentRow[j] = tIJm1 + (tIJm1 - previousRow[j - 1]) / r;}final double s = currentRow[i];if (i >= getMinimalIterationCount()) {final double delta  = FastMath.abs(s - olds);final double rLimit = getRelativeAccuracy() * (FastMath.abs(olds) + FastMath.abs(s)) * 0.5;if ((delta <= rLimit) || (delta <= getAbsoluteAccuracy())) {return s;}}olds = s;}}}

8. 类 org.apache.commons.math3.analysis.integration.SimpsonIntegrator

8.1. SimpsonIntegrator 中英对照文档

org.apache.commons.math3.analysis.integration

类 SimpsonIntegrator

  • java.lang.Object
    • org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator
      • org.apache.commons.math3.analysis.integration.SimpsonIntegrator
  • All Implemented Interfaces:
    UnivariateIntegrator

    单抗体钢结构


    public class SimpsonIntegrator
    extends BaseAbstractUnivariateIntegrator
    Implements Simpson's Rule for integration of real univariate functions. For reference, see Introduction to Numerical Analysis, ISBN 038795452X, chapter 3.

    This implementation employs the basic trapezoid rule to calculate Simpson's rule.

    实现辛普森的规则,以集成真正单变量功能。有关参考,请参阅介绍数值分析,ISBN 038795452x,第3章。此实现采用基本梯形规则来计算SIMPSON的规则。

    从以下版本开始:
    1.2

    1.2

    • 字段概要

      字段  
      限定符和类型 Field and 的说明
      static int SIMPSON_MAX_ITERATIONS_COUNT

      Maximal number of iterations for Simpson.

      辛普森的最大迭代次数。

      • Fields inherited from class org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

        DEFAULT_ABSOLUTE_ACCURACY, DEFAULT_MAX_ITERATIONS_COUNT, DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_RELATIVE_ACCURACY, iterations

    • 构造器概要

      构造器  
      构造器和说明
      SimpsonIntegrator()

      Construct an integrator with default settings.

      构建具有默认设置的集成器。

      SimpsonIntegrator(double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount)

      Build a Simpson integrator with given accuracies and iterations counts.

      构建具有给定精度和迭代计数的辛普森集成商。

      SimpsonIntegrator(int minimalIterationCount, int maximalIterationCount)

      Build a Simpson integrator with given iteration counts.

      构建具有给定迭代计数的SIMPSON Integrator。

    • 方法概要

      Methods  
      限定符和类型 方法和说明
      protected double doIntegrate()

      Method for implementing actual integration algorithms in derived classes.

      在派生类中实现实际集成算法的方法。

      • 从类继承的方法 org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

        computeObjectiveValue, getAbsoluteAccuracy, getEvaluations, getIterations, getMax, getMaximalIterationCount, getMin, getMinimalIterationCount, getRelativeAccuracy, incrementCount, integrate, setup

      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    • 字段详情:

      • SIMPSON_MAX_ITERATIONS_COUNT

        public static final int SIMPSON_MAX_ITERATIONS_COUNT
        Maximal number of iterations for Simpson.

        辛普森的最大迭代次数。

        另请参阅:
        Constant Field Values

        恒定字段值

    • 构造器详细说明

      • SimpsonIntegrator

        public SimpsonIntegrator(double relativeAccuracy,double absoluteAccuracy,int minimalIterationCount,int maximalIterationCount)throws NotStrictlyPositiveException,NumberIsTooSmallException,NumberIsTooLargeException
        Build a Simpson integrator with given accuracies and iterations counts.

        构建具有给定精度和迭代计数的辛普森集成商。

        参数:
        relativeAccuracy - relative accuracy of the result

        相对准确性 - 结果的相对准确性

        absoluteAccuracy - absolute accuracy of the result

        绝对精度 - 结果绝对准确性

        minimalIterationCount - minimum number of iterations

        minimalitorioncount - 最小迭代次数

        maximalIterationCount - maximum number of iterations (must be less than or equal to SIMPSON_MAX_ITERATIONS_COUNT)

        maximalimerationcount - 最大迭代次数(必须小于或等于SIMPSON_MAX_INTATIONS_COUNT)

        抛出:
        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive

        NOTSTRICLYPOSIVEIVEEXception - 如果最小的迭代数量并不严格积极

        NumberIsTooSmallException - if maximal number of iterations is lesser than or equal to the minimal number of iterations

        numberistoosmallexception - 如果最大迭代次数小于或等于最小数量的迭代次数

        NumberIsTooLargeException - if maximal number of iterations is greater than SIMPSON_MAX_ITERATIONS_COUNT

        NumberStoolarGeexception - 如果最大迭代次数大于SIMPSON_MAX_ITERATIONS_COUNT

      • SimpsonIntegrator

        public SimpsonIntegrator(int minimalIterationCount,int maximalIterationCount)throws NotStrictlyPositiveException,NumberIsTooSmallException,NumberIsTooLargeException
        Build a Simpson integrator with given iteration counts.

        构建具有给定迭代计数的SIMPSON Integrator。

        参数:
        minimalIterationCount - minimum number of iterations

        minimalitorioncount - 最小迭代次数

        maximalIterationCount - maximum number of iterations (must be less than or equal to SIMPSON_MAX_ITERATIONS_COUNT)

        maximalimerationcount - 最大迭代次数(必须小于或等于SIMPSON_MAX_INTATIONS_COUNT)

        抛出:
        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive

        NOTSTRICLYPOSIVEIVEEXception - 如果最小的迭代数量并不严格积极

        NumberIsTooSmallException - if maximal number of iterations is lesser than or equal to the minimal number of iterations

        numberistoosmallexception - 如果最大迭代次数小于或等于最小数量的迭代次数

        NumberIsTooLargeException - if maximal number of iterations is greater than SIMPSON_MAX_ITERATIONS_COUNT

        NumberStoolarGeexception - 如果最大迭代次数大于SIMPSON_MAX_ITERATIONS_COUNT

      • SimpsonIntegrator

        public SimpsonIntegrator()
        Construct an integrator with default settings. (max iteration count set to SIMPSON_MAX_ITERATIONS_COUNT)

        构建具有默认设置的集成器。(MAX迭代计数设置为SIMPSON_MAX_ITIRATIONS_COUNT)

    • 方法详细说明

      • doIntegrate

        protected double doIntegrate()throws TooManyEvaluationsException,MaxCountExceededException
        Method for implementing actual integration algorithms in derived classes.

        在派生类中实现实际集成算法的方法。

        指定者:
        doIntegrate in class  BaseAbstractUnivariateIntegrator

        在课堂Baseabstractunigariation integrator中进行了致力于

        返回:
        the root.

        根。

        抛出:
        TooManyEvaluationsException - if the maximal number of evaluations is exceeded.

        toomanyevalionsexception - 如果超出了最大数量的评估。

        MaxCountExceededException - if the maximum iteration count is exceeded or the integrator detects convergence problems otherwise

        MaxCountExceedEdException - 如果超出了最大迭代计数,或者积分器否则会检测到融合问题

8.2. SimpsonIntegrator 源码赏析

/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.* The ASF licenses this file to You under the Apache License, Version 2.0* (the "License"); you may not use this file except in compliance with* the License.  You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/
package org.apache.commons.math3.analysis.integration;import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
import org.apache.commons.math3.util.FastMath;/*** Implements <a href="http://mathworld.wolfram.com/SimpsonsRule.html">* Simpson's Rule</a> for integration of real univariate functions. For* reference, see <b>Introduction to Numerical Analysis</b>, ISBN 038795452X,* chapter 3.* <p>* This implementation employs the basic trapezoid rule to calculate Simpson's* rule.</p>** @since 1.2*/
public class SimpsonIntegrator extends BaseAbstractUnivariateIntegrator {/** Maximal number of iterations for Simpson. */public static final int SIMPSON_MAX_ITERATIONS_COUNT = 64;/*** Build a Simpson integrator with given accuracies and iterations counts.* @param relativeAccuracy relative accuracy of the result* @param absoluteAccuracy absolute accuracy of the result* @param minimalIterationCount minimum number of iterations* @param maximalIterationCount maximum number of iterations* (must be less than or equal to {@link #SIMPSON_MAX_ITERATIONS_COUNT})* @exception NotStrictlyPositiveException if minimal number of iterations* is not strictly positive* @exception NumberIsTooSmallException if maximal number of iterations* is lesser than or equal to the minimal number of iterations* @exception NumberIsTooLargeException if maximal number of iterations* is greater than {@link #SIMPSON_MAX_ITERATIONS_COUNT}*/public SimpsonIntegrator(final double relativeAccuracy,final double absoluteAccuracy,final int minimalIterationCount,final int maximalIterationCount)throws NotStrictlyPositiveException, NumberIsTooSmallException, NumberIsTooLargeException {super(relativeAccuracy, absoluteAccuracy, minimalIterationCount, maximalIterationCount);if (maximalIterationCount > SIMPSON_MAX_ITERATIONS_COUNT) {throw new NumberIsTooLargeException(maximalIterationCount,SIMPSON_MAX_ITERATIONS_COUNT, false);}}/*** Build a Simpson integrator with given iteration counts.* @param minimalIterationCount minimum number of iterations* @param maximalIterationCount maximum number of iterations* (must be less than or equal to {@link #SIMPSON_MAX_ITERATIONS_COUNT})* @exception NotStrictlyPositiveException if minimal number of iterations* is not strictly positive* @exception NumberIsTooSmallException if maximal number of iterations* is lesser than or equal to the minimal number of iterations* @exception NumberIsTooLargeException if maximal number of iterations* is greater than {@link #SIMPSON_MAX_ITERATIONS_COUNT}*/public SimpsonIntegrator(final int minimalIterationCount,final int maximalIterationCount)throws NotStrictlyPositiveException, NumberIsTooSmallException, NumberIsTooLargeException {super(minimalIterationCount, maximalIterationCount);if (maximalIterationCount > SIMPSON_MAX_ITERATIONS_COUNT) {throw new NumberIsTooLargeException(maximalIterationCount,SIMPSON_MAX_ITERATIONS_COUNT, false);}}/*** Construct an integrator with default settings.* (max iteration count set to {@link #SIMPSON_MAX_ITERATIONS_COUNT})*/public SimpsonIntegrator() {super(DEFAULT_MIN_ITERATIONS_COUNT, SIMPSON_MAX_ITERATIONS_COUNT);}/** {@inheritDoc} */@Overrideprotected double doIntegrate()throws TooManyEvaluationsException, MaxCountExceededException {TrapezoidIntegrator qtrap = new TrapezoidIntegrator();if (getMinimalIterationCount() == 1) {return (4 * qtrap.stage(this, 1) - qtrap.stage(this, 0)) / 3.0;}// Simpson's rule requires at least two trapezoid stages.double olds = 0;double oldt = qtrap.stage(this, 0);while (true) {final double t = qtrap.stage(this, getIterations());incrementCount();final double s = (4 * t - oldt) / 3.0;if (getIterations() >= getMinimalIterationCount()) {final double delta = FastMath.abs(s - olds);final double rLimit =getRelativeAccuracy() * (FastMath.abs(olds) + FastMath.abs(s)) * 0.5;if ((delta <= rLimit) || (delta <= getAbsoluteAccuracy())) {return s;}}olds = s;oldt = t;}}}

9. 类 org.apache.commons.math3.analysis.integration.TrapezoidIntegrator

9.1. TrapezoidIntegrator 中英对照文档

org.apache.commons.math3.analysis.integration

类 TrapezoidIntegrator

  • java.lang.Object
    • org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator
      • org.apache.commons.math3.analysis.integration.TrapezoidIntegrator
  • All Implemented Interfaces:
    UnivariateIntegrator

    单抗体钢结构


    public class TrapezoidIntegrator
    extends BaseAbstractUnivariateIntegrator
    Implements the Trapezoid Rule for integration of real univariate functions. For reference, see Introduction to Numerical Analysis, ISBN 038795452X, chapter 3.

    The function should be integrable.

    实现梯形规则,以便集成真正的单变量函数。供参考,请参阅介绍数值分析,ISBN 038795452x,第3章。功能应该是可集成的。

    从以下版本开始:
    1.2

    1.2

    • 字段概要

      字段  
      限定符和类型 Field and 的说明
      static int TRAPEZOID_MAX_ITERATIONS_COUNT

      Maximum number of iterations for trapezoid.

      梯形的最大迭代次数。

      • Fields inherited from class org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

        DEFAULT_ABSOLUTE_ACCURACY, DEFAULT_MAX_ITERATIONS_COUNT, DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_RELATIVE_ACCURACY, iterations

    • 构造器概要

      构造器  
      构造器和说明
      TrapezoidIntegrator()

      Construct a trapezoid integrator with default settings.

      用默认设置构造梯形集成器。

      TrapezoidIntegrator(double relativeAccuracy, double absoluteAccuracy, int minimalIterationCount, int maximalIterationCount)

      Build a trapezoid integrator with given accuracies and iterations counts.

      构建具有给定精度和迭代计数的梯形集成器。

      TrapezoidIntegrator(int minimalIterationCount, int maximalIterationCount)

      Build a trapezoid integrator with given iteration counts.

      构建具有给定迭代计数的梯形集成器。

    • 方法概要

      Methods  
      限定符和类型 方法和说明
      protected double doIntegrate()

      Method for implementing actual integration algorithms in derived classes.

      在派生类中实现实际集成算法的方法。

      • 从类继承的方法 org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator

        computeObjectiveValue, getAbsoluteAccuracy, getEvaluations, getIterations, getMax, getMaximalIterationCount, getMin, getMinimalIterationCount, getRelativeAccuracy, incrementCount, integrate, setup

      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    • 字段详情:

      • TRAPEZOID_MAX_ITERATIONS_COUNT

        public static final int TRAPEZOID_MAX_ITERATIONS_COUNT
        Maximum number of iterations for trapezoid.

        梯形的最大迭代次数。

        另请参阅:
        Constant Field Values

        恒定字段值

    • 构造器详细说明

      • TrapezoidIntegrator

        public TrapezoidIntegrator(double relativeAccuracy,double absoluteAccuracy,int minimalIterationCount,int maximalIterationCount)throws NotStrictlyPositiveException,NumberIsTooSmallException,NumberIsTooLargeException
        Build a trapezoid integrator with given accuracies and iterations counts.

        构建具有给定精度和迭代计数的梯形集成器。

        参数:
        relativeAccuracy - relative accuracy of the result

        相对准确性 - 结果的相对准确性

        absoluteAccuracy - absolute accuracy of the result

        绝对精度 - 结果绝对准确性

        minimalIterationCount - minimum number of iterations

        minimalitorioncount - 最小迭代次数

        maximalIterationCount - maximum number of iterations (must be less than or equal to TRAPEZOID_MAX_ITERATIONS_COUNT

        maximalimerationcount - 最大迭代次数(必须小于或等于trapezoid_max_iterations_count

        抛出:
        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive

        NOTSTRICLYPOSIVEIVEEXception - 如果最小的迭代数量并不严格积极

        NumberIsTooSmallException - if maximal number of iterations is lesser than or equal to the minimal number of iterations

        numberistoosmallexception - 如果最大迭代次数小于或等于最小数量的迭代次数

        NumberIsTooLargeException - if maximal number of iterations is greater than TRAPEZOID_MAX_ITERATIONS_COUNT

        NumberStoolarGeexception - 如果最大迭代次数大于Trapezoid_max_Iterations_count

      • TrapezoidIntegrator

        public TrapezoidIntegrator(int minimalIterationCount,int maximalIterationCount)throws NotStrictlyPositiveException,NumberIsTooSmallException,NumberIsTooLargeException
        Build a trapezoid integrator with given iteration counts.

        构建具有给定迭代计数的梯形集成器。

        参数:
        minimalIterationCount - minimum number of iterations

        minimalitorioncount - 最小迭代次数

        maximalIterationCount - maximum number of iterations (must be less than or equal to TRAPEZOID_MAX_ITERATIONS_COUNT

        maximalimerationcount - 最大迭代次数(必须小于或等于trapezoid_max_iterations_count

        抛出:
        NotStrictlyPositiveException - if minimal number of iterations is not strictly positive

        NOTSTRICLYPOSIVEIVEEXception - 如果最小的迭代数量并不严格积极

        NumberIsTooSmallException - if maximal number of iterations is lesser than or equal to the minimal number of iterations

        numberistoosmallexception - 如果最大迭代次数小于或等于最小数量的迭代次数

        NumberIsTooLargeException - if maximal number of iterations is greater than TRAPEZOID_MAX_ITERATIONS_COUNT

        NumberStoolarGeexception - 如果最大迭代次数大于Trapezoid_max_Iterations_count

      • TrapezoidIntegrator

        public TrapezoidIntegrator()
        Construct a trapezoid integrator with default settings. (max iteration count set to TRAPEZOID_MAX_ITERATIONS_COUNT)

        用默认设置构造梯形集成器。(最多迭代计数设置为trapezoid_max_iterations_count)

    • 方法详细说明

      • doIntegrate

        protected double doIntegrate()throws MathIllegalArgumentException,TooManyEvaluationsException,MaxCountExceededException
        Method for implementing actual integration algorithms in derived classes.

        在派生类中实现实际集成算法的方法。

        指定者:
        doIntegrate in class  BaseAbstractUnivariateIntegrator

        在课堂Baseabstractunigariation integrator中进行了致力于

        返回:
        the root.

        根。

        抛出:
        TooManyEvaluationsException - if the maximal number of evaluations is exceeded.

        toomanyevalionsexception - 如果超出了最大数量的评估。

        MaxCountExceededException - if the maximum iteration count is exceeded or the integrator detects convergence problems otherwise

        MaxCountExceedEdException - 如果超出了最大迭代计数,或者积分器否则会检测到融合问题

        MathIllegalArgumentException

        MathilleGalargumentException.

9.2. TrapezoidIntegrator 源码赏析

/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.* The ASF licenses this file to You under the Apache License, Version 2.0* (the "License"); you may not use this file except in compliance with* the License.  You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/
package org.apache.commons.math3.analysis.integration;import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
import org.apache.commons.math3.util.FastMath;/*** Implements the <a href="http://mathworld.wolfram.com/TrapezoidalRule.html">* Trapezoid Rule</a> for integration of real univariate functions. For* reference, see <b>Introduction to Numerical Analysis</b>, ISBN 038795452X,* chapter 3.* <p>* The function should be integrable.</p>** @since 1.2*/
public class TrapezoidIntegrator extends BaseAbstractUnivariateIntegrator {/** Maximum number of iterations for trapezoid. */public static final int TRAPEZOID_MAX_ITERATIONS_COUNT = 64;/** Intermediate result. */private double s;/*** Build a trapezoid integrator with given accuracies and iterations counts.* @param relativeAccuracy relative accuracy of the result* @param absoluteAccuracy absolute accuracy of the result* @param minimalIterationCount minimum number of iterations* @param maximalIterationCount maximum number of iterations* (must be less than or equal to {@link #TRAPEZOID_MAX_ITERATIONS_COUNT}* @exception NotStrictlyPositiveException if minimal number of iterations* is not strictly positive* @exception NumberIsTooSmallException if maximal number of iterations* is lesser than or equal to the minimal number of iterations* @exception NumberIsTooLargeException if maximal number of iterations* is greater than {@link #TRAPEZOID_MAX_ITERATIONS_COUNT}*/public TrapezoidIntegrator(final double relativeAccuracy,final double absoluteAccuracy,final int minimalIterationCount,final int maximalIterationCount)throws NotStrictlyPositiveException, NumberIsTooSmallException, NumberIsTooLargeException {super(relativeAccuracy, absoluteAccuracy, minimalIterationCount, maximalIterationCount);if (maximalIterationCount > TRAPEZOID_MAX_ITERATIONS_COUNT) {throw new NumberIsTooLargeException(maximalIterationCount,TRAPEZOID_MAX_ITERATIONS_COUNT, false);}}/*** Build a trapezoid integrator with given iteration counts.* @param minimalIterationCount minimum number of iterations* @param maximalIterationCount maximum number of iterations* (must be less than or equal to {@link #TRAPEZOID_MAX_ITERATIONS_COUNT}* @exception NotStrictlyPositiveException if minimal number of iterations* is not strictly positive* @exception NumberIsTooSmallException if maximal number of iterations* is lesser than or equal to the minimal number of iterations* @exception NumberIsTooLargeException if maximal number of iterations* is greater than {@link #TRAPEZOID_MAX_ITERATIONS_COUNT}*/public TrapezoidIntegrator(final int minimalIterationCount,final int maximalIterationCount)throws NotStrictlyPositiveException, NumberIsTooSmallException, NumberIsTooLargeException {super(minimalIterationCount, maximalIterationCount);if (maximalIterationCount > TRAPEZOID_MAX_ITERATIONS_COUNT) {throw new NumberIsTooLargeException(maximalIterationCount,TRAPEZOID_MAX_ITERATIONS_COUNT, false);}}/*** Construct a trapezoid integrator with default settings.* (max iteration count set to {@link #TRAPEZOID_MAX_ITERATIONS_COUNT})*/public TrapezoidIntegrator() {super(DEFAULT_MIN_ITERATIONS_COUNT, TRAPEZOID_MAX_ITERATIONS_COUNT);}/*** Compute the n-th stage integral of trapezoid rule. This function* should only be called by API <code>integrate()</code> in the package.* To save time it does not verify arguments - caller does.* <p>* The interval is divided equally into 2^n sections rather than an* arbitrary m sections because this configuration can best utilize the* already computed values.</p>** @param baseIntegrator integrator holding integration parameters* @param n the stage of 1/2 refinement, n = 0 is no refinement* @return the value of n-th stage integral* @throws TooManyEvaluationsException if the maximal number of evaluations* is exceeded.*/double stage(final BaseAbstractUnivariateIntegrator baseIntegrator, final int n)throws TooManyEvaluationsException {if (n == 0) {final double max = baseIntegrator.getMax();final double min = baseIntegrator.getMin();s = 0.5 * (max - min) *(baseIntegrator.computeObjectiveValue(min) +baseIntegrator.computeObjectiveValue(max));return s;} else {final long np = 1L << (n-1);           // number of new points in this stagedouble sum = 0;final double max = baseIntegrator.getMax();final double min = baseIntegrator.getMin();// spacing between adjacent new pointsfinal double spacing = (max - min) / np;double x = min + 0.5 * spacing;    // the first new pointfor (long i = 0; i < np; i++) {sum += baseIntegrator.computeObjectiveValue(x);x += spacing;}// add the new sum to previously calculated results = 0.5 * (s + sum * spacing);return s;}}/** {@inheritDoc} */@Overrideprotected double doIntegrate()throws MathIllegalArgumentException, TooManyEvaluationsException, MaxCountExceededException {double oldt = stage(this, 0);incrementCount();while (true) {final int i = getIterations();final double t = stage(this, i);if (i >= getMinimalIterationCount()) {final double delta = FastMath.abs(t - oldt);final double rLimit =getRelativeAccuracy() * (FastMath.abs(oldt) + FastMath.abs(t)) * 0.5;if ((delta <= rLimit) || (delta <= getAbsoluteAccuracy())) {return t;}}oldt = t;incrementCount();}}}

commons-math3-3.6.1-org.apache.commons.math3.analysis.integration-包下的类-中英对照文档及源码赏析相关推荐

  1. commons-math3-3.6.1-org.apache.commons.math3.analysis.integration.gauss-包下的类-中英对照文档及源码赏析

    commons-math3-3.6.1-org.apache.commons.math3.analysis.integration.gauss-包下的类-中英对照文档及源码赏析 摘要:中英对照文档.源 ...

  2. commons-math3-3.6.1-org.apache.commons.math3.analysis.differentiation-包下的接口-中英对照文档及源码赏析

    commons-math3-3.6.1-org.apache.commons.math3.analysis.differentiation-包下的接口-中英对照文档及源码赏析 摘要:中英对照文档.源码 ...

  3. commons-math3-3.6.1-org.apache.commons.math3.analysis.function-包下的类(三)-中英对照文档及源码赏析

    commons-math3-3.6.1-org.apache.commons.math3.analysis.function-包下的类(三)-中英对照文档及源码赏析 摘要:中英对照文档.源码赏析.or ...

  4. commons-math3-3.6.1-org.apache.commons.math3.analysis.function-包下的类(二)-中英对照文档及源码赏析

    commons-math3-3.6.1-org.apache.commons.math3.analysis.function-包下的类(二)-中英对照文档及源码赏析 摘要:中英对照文档.源码赏析.or ...

  5. Apache Commons Math3学习笔记(2) - 多项式曲线拟合(转)

    多项式曲线拟合:org.apache.commons.math3.fitting.PolynomialCurveFitter类. 用法示例代码: [java] view plain copy   // ...

  6. 如何在Java中正确使用Apache Commons数学库中的ZipfDistribution?

    java   apache-commons-math   zipf 温馨提示:将鼠标放在语句上可以显示对应的英文.   或者   切换至中英文显示 我想基于遵循Zipf分布的单词(来自字典)创建数据源 ...

  7. Apache Commons Pool 故事一则 专题

    Apache Commons Pool 故事一则 最近工作中遇到一个由于对commons-pool的使用不当而引发的问题,习得正确的使用姿势后,写下这个简单的故事,帮助理解Apache Commons ...

  8. [转]Apache Commons IO入门教程

    Apache Commons IO是Apache基金会创建并维护的Java函数库.它提供了许多类使得开发者的常见任务变得简单,同时减少重复(boiler-plate)代码,这些代码可能遍布于每个独立的 ...

  9. Apache Commons fileUpload实现文件上传

    Apache的commons-fileupload.jar可方便的实现文件的上传功能,本文通过实例来介绍如何使用commons-fileupload.jar. @author:ZJ 07-2-22 B ...

最新文章

  1. 使用 ale.js 制作一个小而美的表格编辑器(2)
  2. mysql数据库引擎博客_2、MySQL常见数据库引擎及比较?
  3. 企业网站如何具备亲和力?
  4. JavaScript 复习之 Array 对象
  5. Codeforces 500
  6. php curl和file get,PHP cURL与file_get_contents
  7. leetcode991. 坏了的计算器(贪心)
  8. 分割法和填补法_“聚合”法与“分割”法
  9. 【51Nod - 1103】N的倍数 (思维,鸽巢原理也叫抽屉定理,求倍数问题取模)
  10. opencv6-调整图像亮度和对比度
  11. [TaskList] 省选前板子补完计划
  12. Bind Service 不会在后台无限期的一直运行
  13. 首届全国信创大赛圆满收官,信创新势力载誉而归!
  14. mt6735通用recovery_MTK65XX通用线刷刷机工具驱动-MTK65xx刷机工具驱动及教程下载最新免费版-西西软件下载...
  15. java 二进制转十进制的算法_java中位运算与整数的十进制转二进制
  16. matlab中modred,计算机仿真技术(中南大学)3系统模型及转换.ppt
  17. Excel_一维二维表转换(行列转换)的几种方法
  18. Java入门学习笔记
  19. 导数求函数的单调性与极值习题
  20. 【二维前缀和】小白月赛-秘法地震

热门文章

  1. 环境温湿度在线监测如何实现?有何应用场景?
  2. Office2019安装视频教程
  3. python type()
  4. [WPF自定义控件库]以Button为例谈谈如何模仿Aero2主题
  5. 围观|解读新一代企业数字化架构的“三驾马车”
  6. W5500常见问题集锦
  7. 什么是鱼骨图分析法,详细解析
  8. JAVA简单的键盘输入
  9. flash cs3快捷键大全
  10. 股票量化交易接口策略与资金管理才是实现投资理念的最佳方式