예제 #1
0
  @Test
  public final void testOr() {
    assertTrue(equivalent(mT324, mT324.or(mT324)));
    assertTrue(equivalent(mF324, mF324.or(mF324)));
    assertTrue(equivalent(mT324, mT324.or(mF324)));
    assertTrue(equivalent(mT324.or(mF324), mF324.or(mT324)));

    Arrays.fill(mCells, TRUE);

    for (int i = mR[1].min(); i <= mR[1].max(); i++) {
      mT324.set(i, vars[i]);
      mF324.set(i, vars[2 * i % vars.length]);
      mCells[i] = f.or(vars[i], vars[2 * i % vars.length]);
    }
    assertTrue(equivalent(mT324.or(mF324), mCells));

    mT324.set(mR[0].max(), vars[mR[0].max()]);
    mF324.set(mR[2].min(), vars[mR[2].min()]);
    mCells[mR[0].max()] = vars[mR[0].max()];
    assertTrue(equivalent(mT324.or(mF324), mCells));

    // System.out.println(mT324);
    // System.out.println(mF324);
    // System.out.println(Arrays.asList(mCells));

  }
예제 #2
0
  @Test
  public final void testOverride() {
    assertTrue(equivalent(mT324.override(mT324), mT324));
    assertTrue(equivalent(mT324.override(mF324), mT324));
    assertTrue(equivalent(mF324.override(mT324), mT324));
    assertTrue(equivalent(mF324.override(mF324), mF324));

    final BooleanMatrix mF324c = mF324.clone(), mT324c = mT324.clone();

    mF324.set(3, vars[3]);
    mF324.set(17, vars[17]);
    mF324.set(22, vars[22]);
    assertTrue(equivalent(mF324.override(mF324c), mF324));
    assertTrue(equivalent(mF324.override(mT324), mT324));

    mF324c.set(9, vars[9]);
    assertTrue(equivalent(mF324.override(mF324c), mF324.or(mF324c)));

    mT324.set(0, BooleanConstant.FALSE);
    assertTrue(equivalent(mF324.override(mT324), mT324));
    assertTrue(equivalent(mT324.override(mT324c), mT324c));
    assertTrue(equivalent(mT324c.override(mT324), mT324));

    final BooleanMatrix mFoF = f.matrix(dim324);
    mF324.set(10, vars[10]);
    mF324c.set(3, vars[4]);
    mF324c.set(20, vars[20]);
    mF324c.set(19, vars[19]);

    mFoF.set(3, f.or(vars[4], f.and(vars[3], f.not(vars[4]))));
    mFoF.set(9, vars[9]);
    mFoF.set(10, f.and(vars[10], f.not(vars[9])));
    mFoF.set(17, f.and(vars[17], f.and(f.not(vars[19]), f.not(vars[20]))));
    mFoF.set(22, f.and(vars[22], f.and(f.not(vars[19]), f.not(vars[20]))));
    mFoF.set(20, vars[20]);
    mFoF.set(19, vars[19]);

    assertTrue(equivalent(mF324.override(mF324c), mFoF));

    mT324.set(3, vars[4]);
    mT324.set(11, vars[11]);
    for (int i = 16; i < 24; i++) mT324.set(i, vars[i - 16]);

    final BooleanMatrix mFoT = f.matrix(dim324);
    for (int i = 0; i < 16; i++) mFoT.set(i, mT324.get(i));

    final BooleanAccumulator g = BooleanAccumulator.treeGate(Operator.AND);
    for (int i = 0; i < 8; i++) g.add(f.not(vars[i]));
    final BooleanValue v3 = f.accumulate(g);

    for (int i = 16; i < 24; i++) mFoT.set(i, f.or(f.and(v3, mF324.get(i)), mT324.get(i)));

    assertTrue(equivalent(mF324.override(mT324), mFoT));

    final BooleanMatrix mToF = f.matrix(dim324);
    for (int i = 0; i < 8; i++)
      mToF.set(i, f.or(mF324.get(i), f.and(mT324.get(i), f.not(vars[3]))));
    for (int i = 8; i < 16; i++)
      mToF.set(i, f.or(mF324.get(i), f.and(mT324.get(i), f.not(vars[10]))));
    for (int i = 16; i < 24; i++)
      mToF.set(i, f.or(mF324.get(i), f.and(mT324.get(i), f.and(f.not(vars[17]), f.not(vars[22])))));

    assertTrue(equivalent(mT324.override(mF324), mToF));

    final BooleanMatrix mToT = f.matrix(dim324).not();
    mT324c.set(11, vars[12]);
    mT324c.set(12, vars[13]);
    mT324c.set(18, vars[18]);
    for (int i = 0; i < 16; i++) mToT.set(i, mT324.get(i));
    for (int i = 16; i < 24; i++) mToT.set(i, f.or(mT324.get(i), f.and(mT324c.get(i), v3)));

    assertTrue(equivalent(mT324c.override(mT324), mToT));
  }