本文整理匯總了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);
}