本文整理汇总了Java中org.apache.commons.math3.util.CombinatoricsUtils.factorialDouble方法的典型用法代码示例。如果您正苦于以下问题:Java CombinatoricsUtils.factorialDouble方法的具体用法?Java CombinatoricsUtils.factorialDouble怎么用?Java CombinatoricsUtils.factorialDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.util.CombinatoricsUtils
的用法示例。
在下文中一共展示了CombinatoricsUtils.factorialDouble方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public GaussianQuadratureData generate(int n) {
ArgChecker.isTrue(n > 0, "n > 0");
Pair<DoubleFunction1D, DoubleFunction1D>[] polynomials = JACOBI.getPolynomialsAndFirstDerivative(n, _alpha, _beta);
Pair<DoubleFunction1D, DoubleFunction1D> pair = polynomials[n];
DoubleFunction1D previous = polynomials[n - 1].getFirst();
DoubleFunction1D function = pair.getFirst();
DoubleFunction1D derivative = pair.getSecond();
double[] x = new double[n];
double[] w = new double[n];
double root = 0;
for (int i = 0; i < n; i++) {
double d = 2 * n + _c;
root = getInitialRootGuess(root, i, n, x);
root = ROOT_FINDER.getRoot(function, derivative, root);
x[i] = root;
w[i] =
GAMMA_FUNCTION.applyAsDouble(_alpha + n) * GAMMA_FUNCTION.applyAsDouble(_beta + n) /
CombinatoricsUtils.factorialDouble(n) / GAMMA_FUNCTION.applyAsDouble(n + _c + 1) * d *
Math.pow(2, _c)
/ (derivative.applyAsDouble(root) * previous.applyAsDouble(root));
}
return new GaussianQuadratureData(x, w);
}
示例2: generate
import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public GaussianQuadratureData generate(int n) {
ArgChecker.isTrue(n > 0);
Pair<DoubleFunction1D, DoubleFunction1D>[] polynomials = LAGUERRE.getPolynomialsAndFirstDerivative(n, _alpha);
Pair<DoubleFunction1D, DoubleFunction1D> pair = polynomials[n];
DoubleFunction1D p1 = polynomials[n - 1].getFirst();
DoubleFunction1D function = pair.getFirst();
DoubleFunction1D derivative = pair.getSecond();
double[] x = new double[n];
double[] w = new double[n];
double root = 0;
for (int i = 0; i < n; i++) {
root = ROOT_FINDER.getRoot(function, derivative, getInitialRootGuess(root, i, n, x));
x[i] = root;
w[i] =
-GAMMA_FUNCTION.applyAsDouble(_alpha + n) / CombinatoricsUtils.factorialDouble(n) /
(derivative.applyAsDouble(root) * p1.applyAsDouble(root));
}
return new GaussianQuadratureData(x, w);
}
示例3: factorial
import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Override
public ASTNodeValue factorial(ASTNode value) throws SBMLException {
double v = toDouble(value);
double roundedV = FastMath.round(v);
if (v != roundedV) {
throw new IllegalArgumentException("factorial cannot be computed from floating point number: " + v);
}
return new ASTNodeValue(CombinatoricsUtils.factorialDouble((int) roundedV), this);
}