當前位置: 首頁>>代碼示例>>Java>>正文


Java ExpVector.EVRAND屬性代碼示例

本文整理匯總了Java中edu.jas.poly.ExpVector.EVRAND屬性的典型用法代碼示例。如果您正苦於以下問題:Java ExpVector.EVRAND屬性的具體用法?Java ExpVector.EVRAND怎麽用?Java ExpVector.EVRAND使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在edu.jas.poly.ExpVector的用法示例。


在下文中一共展示了ExpVector.EVRAND屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: random

/**
 * Random solvable polynomial.
 * @param k size of random coefficients.
 * @param l number of terms.
 * @param d maximal degree in each variable.
 * @param q density of nozero exponents.
 * @param rnd is a source for random bits.
 * @return a random solvable polynomial.
 */
@Override
public LocalSolvablePolynomial<C> random(int k, int l, int d, float q, Random rnd) {
    LocalSolvablePolynomial<C> r = getZERO(); // copy( ZERO ); 
    ExpVector e;
    SolvableLocal<C> a;
    // add random coeffs and exponents
    for (int i = 0; i < l; i++) {
        e = ExpVector.EVRAND(nvar, d, q, rnd);
        a = coFac.random(k, rnd);
        r = (LocalSolvablePolynomial<C>) r.sum(a, e);
        // somewhat inefficient but clean
    }
    return r;
}
 
開發者ID:kredel,項目名稱:java-algebra-system,代碼行數:23,代碼來源:LocalSolvablePolynomialRing.java

示例2: random

/**
 * Random solvable polynomial.
 * @param k size of random coefficients.
 * @param l number of terms.
 * @param d maximal degree in each variable.
 * @param q density of nozero exponents.
 * @param rnd is a source for random bits.
 * @return a random solvable polynomial.
 */
@Override
public ResidueSolvableWordPolynomial<C> random(int k, int l, int d, float q, Random rnd) {
    ResidueSolvableWordPolynomial<C> r = getZERO(); // copy( ZERO ); 
    ExpVector e;
    WordResidue<C> a;
    // add random coeffs and exponents
    for (int i = 0; i < l; i++) {
        e = ExpVector.EVRAND(nvar, d, q, rnd);
        a = coFac.random(k, rnd);
        r = (ResidueSolvableWordPolynomial<C>) r.sum(a, e);
        // somewhat inefficient but clean
    }
    return r;
}
 
開發者ID:kredel,項目名稱:java-algebra-system,代碼行數:23,代碼來源:ResidueSolvableWordPolynomialRing.java

示例3: random

/**
 * Random solvable polynomial.
 * @param k size of random coefficients.
 * @param l number of terms.
 * @param d maximal degree in each variable.
 * @param q density of nozero exponents.
 * @param rnd is a source for random bits.
 * @return a random solvable polynomial.
 */
@Override
public ResidueSolvablePolynomial<C> random(int k, int l, int d, float q, Random rnd) {
    ResidueSolvablePolynomial<C> r = getZERO(); // copy( ZERO ); 
    ExpVector e;
    SolvableResidue<C> a;
    // add random coeffs and exponents
    for (int i = 0; i < l; i++) {
        e = ExpVector.EVRAND(nvar, d, q, rnd);
        a = coFac.random(k, rnd);
        r = (ResidueSolvablePolynomial<C>) r.sum(a, e);
        // somewhat inefficient but clean
    }
    return r;
}
 
開發者ID:kredel,項目名稱:java-algebra-system,代碼行數:23,代碼來源:ResidueSolvablePolynomialRing.java

示例4: random

/**
 * Random solvable polynomial.
 * @param k size of random coefficients.
 * @param l number of terms.
 * @param d maximal degree in each variable.
 * @param q density of nozero exponents.
 * @param rnd is a source for random bits.
 * @return a random solvable polynomial.
 */
@Override
public QuotSolvablePolynomial<C> random(int k, int l, int d, float q, Random rnd) {
    QuotSolvablePolynomial<C> r = getZERO(); // copy( ZERO ); 
    ExpVector e;
    SolvableQuotient<C> a;
    // add random coeffs and exponents
    for (int i = 0; i < l; i++) {
        e = ExpVector.EVRAND(nvar, d, q, rnd);
        a = coFac.random(k, rnd);
        r = (QuotSolvablePolynomial<C>) r.sum(a, e);
        // somewhat inefficient but clean
    }
    return r;
}
 
開發者ID:kredel,項目名稱:java-algebra-system,代碼行數:23,代碼來源:QuotSolvablePolynomialRing.java

示例5: testAddition

/**
 * Test addition.
 */
@SuppressWarnings("unchecked")
public void testAddition() {
    a = ring.random(kl + 1, ll, el, q);
    c = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.subtract(a);
    assertTrue("a-a = 0", c.isZERO());

    b = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.sum(a);
    c = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) b.subtract(a);
    assertEquals("a+a-a = a", c, a);

    b = ring.random(kl, ll, el, q);
    c = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) b.sum(a);
    d = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.sum(b);
    assertEquals("a+b = b+a", c, d);

    c = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.sum(b);
    d = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) c.subtract(b);
    //System.out.println("a = " + a);
    //System.out.println("d = " + d);
    assertEquals("a+b-b = a", a, d);

    c = ring.random(kl, ll, el, q);
    d = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.sum(b.sum(c));
    e = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.sum(b).sum(c);
    assertEquals("a+(b+c) = (a+b)+c", d, e);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    //System.out.println("e = " + e);

    ExpVector u = ExpVector.EVRAND(rl, el, q);
    SolvableQuotient<BigRational> x = qcring.random(kl);
    //System.out.println("x = " + x);
    //System.out.println("u = " + u);

    b = ring.getONE().multiply(x, u);
    c = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.sum(b);
    d = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.sum(x, u);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.subtract(b);
    d = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);

    a = ring.getZERO();
    b = ring.getONE().multiply(x, u);
    c = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) b.sum(a);
    d = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.sum(x, u);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.subtract(b);
    d = (QLRSolvablePolynomial<SolvableQuotient<BigRational>, BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);
}
 
開發者ID:kredel,項目名稱:java-algebra-system,代碼行數:62,代碼來源:QuotientSolvablePolynomialQLRTest.java

示例6: testAddition

/**
 * Test addition.
 */
public void testAddition() {
    a = ring.random(kl, ll, el, q);
    c = (ResidueSolvablePolynomial<BigRational>) a.subtract(a);
    assertTrue("a-a = 0", c.isZERO());

    b = (ResidueSolvablePolynomial<BigRational>) a.sum(a);
    c = (ResidueSolvablePolynomial<BigRational>) b.subtract(a);
    assertEquals("a+a-a = a", c, a);

    b = ring.random(kl, ll, el, q);
    c = (ResidueSolvablePolynomial<BigRational>) b.sum(a);
    d = (ResidueSolvablePolynomial<BigRational>) a.sum(b);
    assertEquals("a+b = b+a", c, d);

    c = ring.random(kl, ll, el, q);
    d = (ResidueSolvablePolynomial<BigRational>) a.sum(b.sum(c));
    e = (ResidueSolvablePolynomial<BigRational>) a.sum(b).sum(c);
    assertEquals("a+(b+c) = (a+b)+c", d, e);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    //System.out.println("e = " + e);

    ExpVector u = ExpVector.EVRAND(rl, el, q);
    SolvableResidue<BigRational> x = rring.random(kl);
    //System.out.println("x = " + x);
    //System.out.println("u = " + u);

    b = ring.getONE().multiply(x, u);
    c = (ResidueSolvablePolynomial<BigRational>) a.sum(b);
    d = (ResidueSolvablePolynomial<BigRational>) a.sum(x, u);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (ResidueSolvablePolynomial<BigRational>) a.subtract(b);
    d = (ResidueSolvablePolynomial<BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);

    a = ring.getZERO();
    b = ring.getONE().multiply(x, u);
    c = (ResidueSolvablePolynomial<BigRational>) b.sum(a);
    d = (ResidueSolvablePolynomial<BigRational>) a.sum(x, u);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (ResidueSolvablePolynomial<BigRational>) a.subtract(b);
    d = (ResidueSolvablePolynomial<BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);
}
 
開發者ID:kredel,項目名稱:java-algebra-system,代碼行數:55,代碼來源:ResidueSolvablePolynomialTest.java

示例7: testAddition

/**
 * Test addition.
 */
@SuppressWarnings("unchecked")
public void testAddition() {
    a = ring.random(kl + 1, ll, el, q);
    c = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.subtract(a);
    assertTrue("a-a = 0", c.isZERO());

    b = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.sum(a);
    c = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) b.subtract(a);
    assertEquals("a+a-a = a", c, a);

    b = ring.random(kl, ll, el, q);
    c = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) b.sum(a);
    d = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.sum(b);
    assertEquals("a+b = b+a", c, d);

    c = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.sum(b);
    d = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) c.subtract(b);
    //System.out.println("a = " + a);
    //System.out.println("d = " + d);
    assertEquals("a+b-b = a", a, d);

    c = ring.random(kl, ll, el, q);
    d = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.sum(b.sum(c));
    e = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.sum(b).sum(c);
    assertEquals("a+(b+c) = (a+b)+c", d, e);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    //System.out.println("e = " + e);

    ExpVector u = ExpVector.EVRAND(rl, el, q);
    SolvableLocalResidue<BigRational> x = qcring.random(kl);
    //System.out.println("x = " + x);
    //System.out.println("u = " + u);

    b = ring.getONE().multiply(x, u);
    c = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.sum(b);
    d = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.sum(x, u);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.subtract(b);
    d = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);

    a = ring.getZERO();
    b = ring.getONE().multiply(x, u);
    c = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) b.sum(a);
    d = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.sum(x, u);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.subtract(b);
    d = (QLRSolvablePolynomial<SolvableLocalResidue<BigRational>, BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);
}
 
開發者ID:kredel,項目名稱:java-algebra-system,代碼行數:62,代碼來源:LocalResidueSolvablePolynomialQLRTest.java

示例8: testAddition

/**
 * Test addition.
 */
public void testAddition() {
    a = ring.random(kl, ll, el, q);
    c = (ResidueSolvableWordPolynomial<BigRational>) a.subtract(a);
    assertTrue("a-a = 0", c.isZERO());

    b = (ResidueSolvableWordPolynomial<BigRational>) a.sum(a);
    c = (ResidueSolvableWordPolynomial<BigRational>) b.subtract(a);
    assertEquals("a+a-a = a", c, a);

    b = ring.random(kl, ll, el, q);
    c = (ResidueSolvableWordPolynomial<BigRational>) b.sum(a);
    d = (ResidueSolvableWordPolynomial<BigRational>) a.sum(b);
    assertEquals("a+b = b+a", c, d);

    c = ring.random(kl, ll, el, q);
    d = (ResidueSolvableWordPolynomial<BigRational>) a.sum(b.sum(c));
    e = (ResidueSolvableWordPolynomial<BigRational>) a.sum(b).sum(c);
    assertEquals("a+(b+c) = (a+b)+c", d, e);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    //System.out.println("e = " + e);

    ExpVector u = ExpVector.EVRAND(rl, el, q);
    WordResidue<BigRational> x = rring.random(kl);
    //System.out.println("x = " + x);
    //System.out.println("u = " + u);

    b = ring.getONE().multiply(x, u);
    c = (ResidueSolvableWordPolynomial<BigRational>) a.sum(b);
    d = (ResidueSolvableWordPolynomial<BigRational>) a.sum(x, u);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (ResidueSolvableWordPolynomial<BigRational>) a.subtract(b);
    d = (ResidueSolvableWordPolynomial<BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);

    a = ring.getZERO();
    b = ring.getONE().multiply(x, u);
    c = (ResidueSolvableWordPolynomial<BigRational>) b.sum(a);
    d = (ResidueSolvableWordPolynomial<BigRational>) a.sum(x, u);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (ResidueSolvableWordPolynomial<BigRational>) a.subtract(b);
    d = (ResidueSolvableWordPolynomial<BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);
}
 
開發者ID:kredel,項目名稱:java-algebra-system,代碼行數:55,代碼來源:ResidueSolvableWordPolynomialTest.java

示例9: testAddition

/**
 * Test addition.
 */
public void testAddition() {
    a = ring.random(kl, ll, el, q);
    c = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) a.subtract(a);
    assertTrue("a-a = 0", c.isZERO());

    b = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) a.sum(a);
    c = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) b.subtract(a);
    assertEquals("a+a-a = a", c, a);

    b = ring.random(kl, ll, el, q);
    c = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) b.sum(a);
    d = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) a.sum(b);
    assertEquals("a+b = b+a", c, d);

    c = ring.random(kl, ll, el, q);
    d = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) a.sum(b.sum(c));
    e = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) a.sum(b).sum(c);
    assertEquals("a+(b+c) = (a+b)+c", d, e);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    //System.out.println("e = " + e);

    ExpVector u = ExpVector.EVRAND(rl, el, q);
    SolvableResidue<BigRational> x = rring.random(kl);
    //System.out.println("x = " + x);
    //System.out.println("u = " + u);

    b = ring.getONE().multiply(x, u);
    c = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) a.sum(b);
    d = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) a.sum(x, u);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) a.subtract(b);
    d = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);

    a = ring.getZERO();
    b = ring.getONE().multiply(x, u);
    c = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) b.sum(a);
    d = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) a.sum(x, u);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) a.subtract(b);
    d = (QLRSolvablePolynomial<SolvableResidue<BigRational>, BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);
}
 
開發者ID:kredel,項目名稱:java-algebra-system,代碼行數:55,代碼來源:ResidueSolvablePolynomialQLRTest.java

示例10: testAddition

/**
 * Test addition.
 */
@SuppressWarnings("unchecked")
public void testAddition() {
    a = ring.random(kl + 1, ll, el, q);
    c = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.subtract(a);
    assertTrue("a-a = 0", c.isZERO());

    b = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.sum(a);
    c = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) b.subtract(a);
    assertEquals("a+a-a = a", c, a);

    b = ring.random(kl, ll, el, q);
    c = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) b.sum(a);
    d = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.sum(b);
    assertEquals("a+b = b+a", c, d);

    c = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.sum(b);
    d = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) c.subtract(b);
    //System.out.println("a = " + a);
    //System.out.println("d = " + d);
    assertEquals("a+b-b = a", a, d);

    c = ring.random(kl, ll, el, q);
    d = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.sum(b.sum(c));
    e = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.sum(b).sum(c);
    assertEquals("a+(b+c) = (a+b)+c", d, e);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    //System.out.println("e = " + e);

    ExpVector u = ExpVector.EVRAND(rl, el, q);
    SolvableLocal<BigRational> x = qcring.random(kl);
    //System.out.println("x = " + x);
    //System.out.println("u = " + u);

    b = ring.getONE().multiply(x, u);
    c = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.sum(b);
    d = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.sum(x, u);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.subtract(b);
    d = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);

    a = ring.getZERO();
    b = ring.getONE().multiply(x, u);
    c = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) b.sum(a);
    d = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.sum(x, u);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.subtract(b);
    d = (QLRSolvablePolynomial<SolvableLocal<BigRational>, BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);
}
 
開發者ID:kredel,項目名稱:java-algebra-system,代碼行數:62,代碼來源:LocalSolvablePolynomialQLRTest.java

示例11: testAddition

/**
 * Test addition.
 */
public void testAddition() {
    a = ring.random(kl+1, ll, el, q);
    c = (LocalSolvablePolynomial<BigRational>) a.subtract(a);
    assertTrue("a-a = 0", c.isZERO());

    b = (LocalSolvablePolynomial<BigRational>) a.sum(a);
    c = (LocalSolvablePolynomial<BigRational>) b.subtract(a);
    assertEquals("a+a-a = a", c, a);

    b = ring.random(kl, ll, el, q);
    c = (LocalSolvablePolynomial<BigRational>) b.sum(a);
    d = (LocalSolvablePolynomial<BigRational>) a.sum(b);
    assertEquals("a+b = b+a", c, d);

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

    c = ring.random(kl, ll, el, q);
    d = (LocalSolvablePolynomial<BigRational>) a.sum(b.sum(c));
    e = (LocalSolvablePolynomial<BigRational>) a.sum(b).sum(c);
    assertEquals("a+(b+c) = (a+b)+c", d, e);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    //System.out.println("e = " + e);

    ExpVector u = ExpVector.EVRAND(rl, el, q);
    SolvableLocal<BigRational> x = qcring.random(kl);
    //System.out.println("x = " + x);
    //System.out.println("u = " + u);

    b = ring.getONE().multiply(x, u);
    c = (LocalSolvablePolynomial<BigRational>) a.sum(b);
    d = (LocalSolvablePolynomial<BigRational>) a.sum(x, u);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (LocalSolvablePolynomial<BigRational>) a.subtract(b);
    d = (LocalSolvablePolynomial<BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);

    a = ring.getZERO();
    b = ring.getONE().multiply(x, u);
    c = (LocalSolvablePolynomial<BigRational>) b.sum(a);
    d = (LocalSolvablePolynomial<BigRational>) a.sum(x, u);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (LocalSolvablePolynomial<BigRational>) a.subtract(b);
    d = (LocalSolvablePolynomial<BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);
}
 
開發者ID:kredel,項目名稱:java-algebra-system,代碼行數:61,代碼來源:LocalSolvablePolynomialTest.java

示例12: testAddition

/**
 * Test addition.
 */
public void testAddition() {
    a = ring.random(kl, ll, el, q);
    c = (QuotSolvablePolynomial<BigRational>) a.subtract(a);
    assertTrue("a-a = 0", c.isZERO());

    b = (QuotSolvablePolynomial<BigRational>) a.sum(a);
    c = (QuotSolvablePolynomial<BigRational>) b.subtract(a);
    assertEquals("a+a-a = a", c, a);

    b = ring.random(kl, ll, el, q);
    c = (QuotSolvablePolynomial<BigRational>) b.sum(a);
    d = (QuotSolvablePolynomial<BigRational>) a.sum(b);
    assertEquals("a+b = b+a", c, d);

    c = ring.random(kl, ll, el, q);
    d = (QuotSolvablePolynomial<BigRational>) a.sum(b.sum(c));
    e = (QuotSolvablePolynomial<BigRational>) a.sum(b).sum(c);
    assertEquals("a+(b+c) = (a+b)+c", d, e);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    //System.out.println("e = " + e);

    ExpVector u = ExpVector.EVRAND(rl, el, q);
    SolvableQuotient<BigRational> x = qcring.random(kl);
    //System.out.println("x = " + x);
    //System.out.println("u = " + u);

    b = ring.getONE().multiply(x, u);
    c = (QuotSolvablePolynomial<BigRational>) a.sum(b);
    d = (QuotSolvablePolynomial<BigRational>) a.sum(x, u);
    //System.out.println("a = " + a);
    //System.out.println("b = " + b);
    //System.out.println("c = " + c);
    //System.out.println("d = " + d);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (QuotSolvablePolynomial<BigRational>) a.subtract(b);
    d = (QuotSolvablePolynomial<BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);

    a = ring.getZERO();
    b = ring.getONE().multiply(x, u);
    c = (QuotSolvablePolynomial<BigRational>) b.sum(a);
    d = (QuotSolvablePolynomial<BigRational>) a.sum(x, u);
    assertEquals("a+p(x,u) = a+(x,u)", c, d);

    c = (QuotSolvablePolynomial<BigRational>) a.subtract(b);
    d = (QuotSolvablePolynomial<BigRational>) a.subtract(x, u);
    assertEquals("a-p(x,u) = a-(x,u)", c, d);
}
 
開發者ID:kredel,項目名稱:java-algebra-system,代碼行數:55,代碼來源:QuotSolvablePolynomialTest.java


注:本文中的edu.jas.poly.ExpVector.EVRAND屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。