本文整理汇总了Java中org.apache.commons.math3.util.FastMath.cbrt方法的典型用法代码示例。如果您正苦于以下问题:Java FastMath.cbrt方法的具体用法?Java FastMath.cbrt怎么用?Java FastMath.cbrt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.util.FastMath
的用法示例。
在下文中一共展示了FastMath.cbrt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rootN
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** Compute n<sup>th</sup> root of a derivative structure.
* @param operand array holding the operand
* @param operandOffset offset of the operand in its array
* @param n order of the root
* @param result array where result must be stored (for
* n<sup>th</sup> root the result array <em>cannot</em> be the input
* array)
* @param resultOffset offset of the result in its array
*/
public void rootN(final double[] operand, final int operandOffset, final int n,
final double[] result, final int resultOffset) {
// create the function value and derivatives
// [x^(1/n), (1/n)x^((1/n)-1), (1-n)/n^2x^((1/n)-2), ... ]
double[] function = new double[1 + order];
double xk;
if (n == 2) {
function[0] = FastMath.sqrt(operand[operandOffset]);
xk = 0.5 / function[0];
} else if (n == 3) {
function[0] = FastMath.cbrt(operand[operandOffset]);
xk = 1.0 / (3.0 * function[0] * function[0]);
} else {
function[0] = FastMath.pow(operand[operandOffset], 1.0 / n);
xk = 1.0 / (n * FastMath.pow(function[0], n - 1));
}
final double nReciprocal = 1.0 / n;
final double xReciprocal = 1.0 / operand[operandOffset];
for (int i = 1; i <= order; ++i) {
function[i] = xk;
xk *= xReciprocal * (nReciprocal - i);
}
// apply function composition
compose(operand, operandOffset, function, result, resultOffset);
}
示例2: derivative
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public UnivariateFunction derivative() {
return new UnivariateFunction() {
/** {@inheritDoc} */
public double value(double x) {
return 1 / (3 * FastMath.cbrt(x * x));
}
};
}
示例3: value
import org.apache.commons.math3.util.FastMath; //导入方法依赖的package包/类
/** {@inheritDoc} */
public double value(double x) {
return FastMath.cbrt(x);
}