コード例 #1
0
  /** Test module and polynomial and module list. */
  public void testModulePolynomialModuleList() {
    List<List<GenPolynomial<BigRational>>> l = new ArrayList<List<GenPolynomial<BigRational>>>();
    for (int i = 0; i < 4; i++) {
      List<GenPolynomial<BigRational>> r = new ArrayList<GenPolynomial<BigRational>>();
      for (int j = 0; j < 3; j++) {
        a = pfac.random(kl, ll, el, q);
        assertTrue("length( a" + i + " ) <> 0", a.length() >= 0);
        assertTrue(" not isZERO( a" + i + " )", !a.isZERO());
        assertTrue(" not isONE( a" + i + " )", !a.isONE());
        r.add(a);
      }
      l.add(r);
    }
    m = new ModuleList<BigRational>(pfac, l);
    // System.out.println("m = "+m);
    assertTrue("m == m", m.equals(m));
    assertEquals("m.length", 4, m.list.size());

    p = m.getPolynomialList();
    // System.out.println("p = "+p);
    assertTrue("p == p", p.equals(p));
    assertEquals("p.length", 4, p.list.size());

    ModuleList<BigRational> m2 = null;
    m2 = p.getModuleList(3);
    // System.out.println("m2 = "+m2);
    assertTrue("m2 == m2", m2.equals(m2));
    assertEquals("m2.length", 4, m2.list.size());

    assertTrue("m == m2", m.equals(m2));
  }
コード例 #2
0
  /** Test polynomial list. */
  public void testPolynomialList() {
    List<GenPolynomial<BigRational>> l = new ArrayList<GenPolynomial<BigRational>>();
    for (int i = 0; i < 7; i++) {
      a = pfac.random(kl, ll + i, el, q);
      assertTrue("length( a" + i + " ) <> 0", a.length() >= 0);
      assertTrue(" not isZERO( a" + i + " )", !a.isZERO());
      assertTrue(" not isONE( a" + i + " )", !a.isONE());
      l.add(a);
    }
    p = new PolynomialList<BigRational>(pfac, l);
    // System.out.println("p = "+p);

    assertTrue("p == p", p.equals(p));
    assertEquals("p.length", 7, p.list.size());
  }
コード例 #3
0
 /**
  * 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 GenSolvablePolynomial<C> random(int k, int l, int d, float q, Random rnd) {
   GenSolvablePolynomial<C> r = getZERO(); // .clone();
   // copy( ZERO );
   // new GenPolynomial<C>( this, getZERO().val );
   ExpVector e;
   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 = (GenSolvablePolynomial<C>) r.sum(a, e);
     // somewhat inefficient but clean
   }
   return r;
 }
コード例 #4
0
 /**
  * Query if this ring is associative. Test if the relations define an associative solvable ring.
  *
  * @return true, if this ring is associative, else false.
  */
 @Override
 public boolean isAssociative() {
   GenSolvablePolynomial<C> Xi, Xj, Xk, p, q;
   for (int i = 0; i < nvar; i++) {
     Xi = univariate(i);
     for (int j = i + 1; j < nvar; j++) {
       Xj = univariate(j);
       for (int k = j + 1; k < nvar; k++) {
         Xk = univariate(k);
         p = Xk.multiply(Xj).multiply(Xi);
         q = Xk.multiply(Xj.multiply(Xi));
         if (!p.equals(q)) {
           if (true || debug) {
             logger.info("Xi = " + Xi + ", Xj = " + Xj + ", Xk = " + Xk);
             logger.info("p = ( Xk * Xj ) * Xi = " + p);
             logger.info("q = Xk * ( Xj * Xi ) = " + q);
           }
           return false;
         }
       }
     }
   }
   return coFac.isAssociative();
 }
コード例 #5
0
  /** Test module and polynomial and module and polynomial list with WeylRelations. */
  public void testWeylModulePolynomialModuleListPolynomial() {
    int rloc = 4;
    pfac = new GenSolvablePolynomialRing<BigRational>(cfac, rloc);

    RelationGenerator<BigRational> wl = new WeylRelations<BigRational>();
    wl.generate(pfac);
    RelationTable table1 = pfac.table;
    RelationTable table2 = null;
    RelationTable table3 = null;
    RelationTable table4 = null;
    RelationTable table5 = null;
    // System.out.println("table 1 = " + table1);
    // System.out.println("ring = " + ring);

    List<List<GenPolynomial<BigRational>>> l = new ArrayList<List<GenPolynomial<BigRational>>>();
    for (int i = 0; i < 4; i++) {
      List<GenPolynomial<BigRational>> r = new ArrayList<GenPolynomial<BigRational>>();
      for (int j = 0; j < 3; j++) {
        a = pfac.random(kl, ll, el, q);
        assertTrue("length( a" + i + " ) <> 0", a.length() >= 0);
        assertTrue(" not isZERO( a" + i + " )", !a.isZERO());
        assertTrue(" not isONE( a" + i + " )", !a.isONE());
        r.add(a);
      }
      l.add(r);
    }
    m = new ModuleList<BigRational>(pfac, l);
    // System.out.println("m = "+m);
    assertTrue("m == m", m.equals(m));
    assertEquals("m.length", 4, m.list.size());

    table2 = ((GenSolvablePolynomialRing<BigRational>) m.ring).table;
    // System.out.println("table 2 = " + table2);
    assertEquals("table1 == table2", table1, table2);

    p = m.getPolynomialList();
    // System.out.println("p = "+p);
    assertTrue("p == p", p.equals(p));
    assertEquals("p.length", 4, p.list.size());

    table3 = ((GenSolvablePolynomialRing<BigRational>) p.ring).table;
    // System.out.println("table 3 = " + table3);

    ModuleList<BigRational> m2 = null;
    m2 = p.getModuleList(3);
    // System.out.println("m2 = "+m2);
    assertTrue("m2 == m2", m2.equals(m2));
    assertEquals("m2.length", 4, m2.list.size());

    assertTrue("m == m2", m.equals(m2));

    table4 = ((GenSolvablePolynomialRing<BigRational>) m2.ring).table;
    // System.out.println("table 4 = " + table4);
    assertEquals("table2 == table4", table2, table4);
    assertEquals("table1 == table4", table1, table4);

    PolynomialList<BigRational> p2 = null;
    p2 = m2.getPolynomialList();
    // System.out.println("p2 = "+p2);
    assertTrue("p2 == p2", p2.equals(p2));
    assertEquals("p2.length", 4, p2.list.size());

    assertTrue("p == p2", p.list.equals(p2.list));
    table5 = ((GenSolvablePolynomialRing<BigRational>) p2.ring).table;
    // System.out.println("table 5= " + table5);
    assertEquals("table2 == table4", table3.table, table5.table);
  }