本文整理汇总了Java中org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator.integrate方法的典型用法代码示例。如果您正苦于以下问题:Java GaussIntegrator.integrate方法的具体用法?Java GaussIntegrator.integrate怎么用?Java GaussIntegrator.integrate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator
的用法示例。
在下文中一共展示了GaussIntegrator.integrate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stage
import org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator; //导入方法依赖的package包/类
/**
* 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() {
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;
}
示例2: stage
import org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator; //导入方法依赖的package包/类
/**
* 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() {
public double value(double x) {
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;
}
示例3: stage
import org.apache.commons.math3.analysis.integration.gauss.GaussIntegrator; //导入方法依赖的package包/类
/**
* 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;
}