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


Java BigInteger.random方法代码示例

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


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

示例1: testBaseQR

import edu.jas.arith.BigInteger; //导入方法依赖的package包/类
/**
 * Test base quotioent and remainder.
 * 
 */
public void testBaseQR() {
    di = new BigInteger(1);
    dfac = new GenPolynomialRing<BigInteger>(new BigInteger(1), 1, to);

    for (int i = 0; i < 5; i++) {
        a = dfac.random(kl * (i + 2), ll + 2 * i, el + 2 * i, q);
        c = dfac.random(kl * (i + 2), ll + 2 * i, el + 2 * i, q);
        //a = ufd.basePrimitivePart(a).abs();
        //c = ufd.basePrimitivePart(c);
        ci = di.random(kl * (i + 2));
        ci = ci.sum(di.getONE());

        //System.out.println("a  = " + a);
        //System.out.println("c  = " + c);
        //System.out.println("ci = " + ci);

        if (a.isZERO() || c.isZERO() || ci.isZERO()) {
            // skip for this turn
            continue;
        }
        assertTrue("length( c" + i + " ) <> 0", c.length() > 0);
        //assertTrue(" not isZERO( c"+i+" )", !c.isZERO() );
        //assertTrue(" not isONE( c"+i+" )", !c.isONE() );

        b = a.multiply(c);
        //System.out.println("b  = " + b);
        d = PolyUtil.<BigInteger> basePseudoRemainder(b, c);
        //System.out.println("d  = " + d);

        assertTrue("rem(ac,c) == 0", d.isZERO());

        b = a.multiply(ci);
        //System.out.println("b  = " + b);
        d = b.divide(ci);
        //System.out.println("d  = " + d);

        assertEquals("a == ac/c", a, d);

        b = a.multiply(c);
        //System.out.println("b  = " + b);
        d = PolyUtil.<BigInteger> basePseudoDivide(b, c);
        //System.out.println("d  = " + d);

        assertEquals("a == ac/c", a, d);
    }
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:51,代码来源:GCDPrimitiveTest.java

示例2: testEvalAll

import edu.jas.arith.BigInteger; //导入方法依赖的package包/类
/**
 * Test evaluate all.
 */
public void testEvalAll() {
    BigInteger cfac = new BigInteger();

    List<BigInteger> Ev = new ArrayList<BigInteger>();
    for (int i = 0; i < rl; i++) {
        ei = cfac.random(kl);
        Ev.add(ei);
    }
    //System.out.println("Ev  = " + Ev);

    BigInteger ae, be, ce, de;

    GenPolynomialRing<BigInteger> fac;
    fac = new GenPolynomialRing<BigInteger>(cfac, rl, to);
    //System.out.println("fac  = " + fac);

    a = fac.getZERO();
    //System.out.println("a  = " + a);

    ae = PolyUtil.<BigInteger> evaluateAll(cfac, a, Ev);
    //System.out.println("ae   = " + ae);

    assertTrue("isZERO( ae )", ae.isZERO());

    a = fac.getONE();
    //System.out.println("a  = " + a);

    ae = PolyUtil.<BigInteger> evaluateAll(cfac, a, Ev);
    //System.out.println("ae   = " + ae);

    assertTrue("isONE( ae )", ae.isONE());

    //a = fac.getONE();
    a = fac.random(kl, ll, el, q);
    //System.out.println("a  = " + a);
    //b = fac.getONE();
    b = fac.random(kl, ll, el, q);
    //System.out.println("b  = " + b);

    c = b.sum(a);
    //System.out.println("c  = " + c);

    ae = PolyUtil.<BigInteger> evaluateAll(cfac, a, Ev);
    be = PolyUtil.<BigInteger> evaluateAll(cfac, b, Ev);
    ce = PolyUtil.<BigInteger> evaluateAll(cfac, c, Ev);
    //System.out.println("ae   = " + ae);
    //System.out.println("be   = " + be);
    //System.out.println("ce   = " + ce);

    de = be.sum(ae);
    //System.out.println("de   = " + de);

    assertEquals("eval(a+b) == eval(a) + eval(b)", ce, de);

    c = b.multiply(a);
    //System.out.println("c  = " + c);

    ce = PolyUtil.<BigInteger> evaluateAll(cfac, c, Ev);
    //System.out.println("ae   = " + ae);
    //System.out.println("be   = " + be);
    //System.out.println("ce   = " + ce);

    de = be.multiply(ae);
    //System.out.println("de   = " + de);

    assertEquals("eval(a*b) == eval(a) * eval(b)", ce, de);
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:71,代码来源:PolyUtilTest.java

示例3: testAddition

import edu.jas.arith.BigInteger; //导入方法依赖的package包/类
/**
 * Test addition.
 */
public void testAddition() {
    // integers
    BigInteger rf = new BigInteger();
    // System.out.println("rf = " + rf);

    // non-commuting vars: abcdef
    WordFactory wf = new WordFactory("abcdef");
    //System.out.println("wf = " + wf);

    // polynomials over integers
    GenWordPolynomialRing<BigInteger> fac = new GenWordPolynomialRing<BigInteger>(rf, wf);
    //System.out.println("fac = " + fac);

    GenWordPolynomial<BigInteger> a = fac.random(kl, ll, el);
    GenWordPolynomial<BigInteger> b = fac.random(kl, ll, el);

    GenWordPolynomial<BigInteger> c = a.sum(b);
    GenWordPolynomial<BigInteger> d = c.subtract(b);
    GenWordPolynomial<BigInteger> e;
    assertEquals("a+b-b = a", a, d);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);

    c = fac.random(kl, ll, el);
    //System.out.println("\nc = " + c);
    d = a.sum(b.sum(c));
    e = (a.sum(b)).sum(c);

    //System.out.println("d = " + d);
    //System.out.println("e = " + e);
    //System.out.println("d-e = " + d.subtract(e) );
    assertEquals("a+(b+c) = (a+b)+c", d, e);

    Word u = wf.random(rl);
    BigInteger x = rf.random(kl);

    b = new GenWordPolynomial<BigInteger>(fac, x, u);
    c = a.sum(b);
    d = a.sum(x, u);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);
    //System.out.println("\nc = " + c);
    //System.out.println("d = " + d);

    c = a.subtract(b);
    d = a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);

    //a = new GenWordPolynomial<BigInteger>(fac);
    b = new GenWordPolynomial<BigInteger>(fac, x, u);
    c = b.sum(a);
    d = a.sum(x, u);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);

    c = a.subtract(b);
    d = a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:71,代码来源:GenWordPolynomialTest.java

示例4: testMultiplication

import edu.jas.arith.BigInteger; //导入方法依赖的package包/类
/**
 * Test multiplication.
 */
public void testMultiplication() {
    // integers
    BigInteger rf = new BigInteger();
    // System.out.println("rf = " + rf);

    // non-commuting vars: abcdef
    WordFactory wf = new WordFactory("abcdef");
    //System.out.println("wf = " + wf);

    // polynomials over integers
    GenWordPolynomialRing<BigInteger> fac = new GenWordPolynomialRing<BigInteger>(rf, wf);
    //System.out.println("fac = " + fac);

    GenWordPolynomial<BigInteger> a = fac.random(kl, ll, el);
    GenWordPolynomial<BigInteger> b = fac.random(kl, ll, el);

    GenWordPolynomial<BigInteger> c = a.multiply(b);
    GenWordPolynomial<BigInteger> d = b.multiply(a);
    GenWordPolynomial<BigInteger> e;
    assertFalse("a*b != b*a", c.equals(d));
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);

    c = fac.random(kl, ll, el);
    //System.out.println("c = " + c);
    d = a.multiply(b.multiply(c));
    e = (a.multiply(b)).multiply(c);

    //System.out.println("d = " + d);
    //System.out.println("e = " + e);
    //System.out.println("d-e = " + d.subtract(c) );
    assertEquals("a*(b*c) = (a*b)*c", d, e);

    Word u = wf.random(rl);
    BigInteger x = rf.random(kl);

    b = new GenWordPolynomial<BigInteger>(fac, x, u);
    c = a.multiply(b);
    d = a.multiply(x, u);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);

    //a = new GenWordPolynomial<BigInteger>(fac);
    b = new GenWordPolynomial<BigInteger>(fac, x, u);
    c = a.multiply(b);
    d = a.multiply(x, u);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:59,代码来源:GenWordPolynomialTest.java


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