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


Java BigInteger.getVal方法代码示例

本文整理汇总了Java中edu.jas.arith.BigInteger.getVal方法的典型用法代码示例。如果您正苦于以下问题:Java BigInteger.getVal方法的具体用法?Java BigInteger.getVal怎么用?Java BigInteger.getVal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.jas.arith.BigInteger的用法示例。


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

示例1: baseEqualDegreeFactors

import edu.jas.arith.BigInteger; //导入方法依赖的package包/类
/**
 * GenPolynomial base equal degree factorization.
 * @param P squarefree and monic GenPolynomial.
 * @param deg such that P has only irreducible factors of degree deg.
 * @return [p_1,...,p_k] with P = prod_{i=1,...,r} p_i.
 */
public List<GenPolynomial<MOD>> baseEqualDegreeFactors(GenPolynomial<MOD> P, long deg) {
    if (P == null) {
        throw new IllegalArgumentException(this.getClass().getName() + " P != null");
    }
    List<GenPolynomial<MOD>> facs = new ArrayList<GenPolynomial<MOD>>();
    if (P.isZERO()) {
        return facs;
    }
    GenPolynomialRing<MOD> pfac = P.ring;
    if (pfac.nvar > 1) {
        throw new IllegalArgumentException(
                        this.getClass().getName() + " only for univariate polynomials");
    }
    if (P.degree(0) == deg) {
        facs.add(P);
        return facs;
    }
    ModularRingFactory<MOD> mr = (ModularRingFactory<MOD>) pfac.coFac;
    java.math.BigInteger m = mr.getIntegerModul().getVal();
    //System.out.println("m = " + m);
    boolean p2 = false;
    if (m.equals(java.math.BigInteger.valueOf(2L))) {
        p2 = true;
        //throw new RuntimeException(this.getClass().getName() + " case p = 2 not implemented");
    }
    GenPolynomial<MOD> one = pfac.getONE();
    GenPolynomial<MOD> t = pfac.univariate(0, 1L);
    GenPolynomial<MOD> r;
    GenPolynomial<MOD> h;
    GenPolynomial<MOD> f = P;
    //GreatestCommonDivisor<MOD> engine = GCDFactory.<MOD> getImplementation(pfac.coFac);
    Power<GenPolynomial<MOD>> pow = new Power<GenPolynomial<MOD>>(pfac);
    GenPolynomial<MOD> g = null;
    int degi = (int) deg; //f.degree(0);
    //System.out.println("deg = " + deg);
    BigInteger di = (new BigInteger(m)).power(deg);
    //System.out.println("di = " + di);
    java.math.BigInteger d = di.getVal(); //.longValue()-1;
    //System.out.println("d = " + d);
    d = d.shiftRight(1); // divide by 2
    do {
        if (p2) {
            h = t;
            for (int i = 1; i < degi; i++) {
                h = t.sum(h.multiply(h));
                h = h.remainder(f);
            }
            t = t.multiply(pfac.univariate(0, 2L));
            //System.out.println("h = " + h);
        } else {
            r = pfac.random(17, degi, 2 * degi, 1.0f);
            if (r.degree(0) >= f.degree(0)) {
                r = r.remainder(f);
            }
            r = r.monic();
            //System.out.println("r = " + r);
            h = pow.modPower(r, d, f).subtract(one);
            degi++;
        }
        g = engine.gcd(h, f);
        //System.out.println("g = " + g);
    } while (g.degree(0) == 0 || g.degree(0) == f.degree(0));
    f = f.divide(g);
    facs.addAll(baseEqualDegreeFactors(f, deg));
    facs.addAll(baseEqualDegreeFactors(g, deg));
    return facs;
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:74,代码来源:FactorModular.java


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