本文整理汇总了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;
}