当前位置: 首页>>代码示例>>Java>>正文


Java LocalizedFormats.POLYNOMIAL属性代码示例

本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.POLYNOMIAL属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.POLYNOMIAL属性的具体用法?Java LocalizedFormats.POLYNOMIAL怎么用?Java LocalizedFormats.POLYNOMIAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.math3.exception.util.LocalizedFormats的用法示例。


在下文中一共展示了LocalizedFormats.POLYNOMIAL属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: solveAll

/**
 * Find all complex roots for the polynomial with the given
 * coefficients, starting from the given initial value.
 *
 * @param coefficients Polynomial coefficients.
 * @param initial Start value.
 * @return the point at which the function value is zero.
 * @throws org.apache.commons.math3.exception.TooManyEvaluationsException
 * if the maximum number of evaluations is exceeded.
 * @throws NullArgumentException if the {@code coefficients} is
 * {@code null}.
 * @throws NoDataException if the {@code coefficients} array is empty.
 */
public Complex[] solveAll(Complex coefficients[], Complex initial)
    throws NullArgumentException,
           NoDataException,
           TooManyEvaluationsException {
    if (coefficients == null) {
        throw new NullArgumentException();
    }
    final int n = coefficients.length - 1;
    if (n == 0) {
        throw new NoDataException(LocalizedFormats.POLYNOMIAL);
    }
    // Coefficients for deflated polynomial.
    final Complex c[] = new Complex[n + 1];
    for (int i = 0; i <= n; i++) {
        c[i] = coefficients[i];
    }

    // Solve individual roots successively.
    final Complex root[] = new Complex[n];
    for (int i = 0; i < n; i++) {
        final Complex subarray[] = new Complex[n - i + 1];
        System.arraycopy(c, 0, subarray, 0, subarray.length);
        root[i] = solve(subarray, initial);
        // Polynomial deflation using synthetic division.
        Complex newc = c[n - i];
        Complex oldc = null;
        for (int j = n - i - 1; j >= 0; j--) {
            oldc = c[j];
            c[j] = newc;
            newc = oldc.add(newc.multiply(root[i]));
        }
    }

    return root;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:48,代码来源:LaguerreSolver.java


注:本文中的org.apache.commons.math3.exception.util.LocalizedFormats.POLYNOMIAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。