示例#1
0
  @Test
  public final void testCrossProduct() {
    final BooleanMatrix mT43 = mF43.not();

    fill(mT43, range(0, dim43.capacity() - 1));
    fill(mF4, range(0, dim4.capacity() - 1));

    assertCrossProductFalse(mF324, mT43);
    assertCrossProductFalse(mF324, mF4);

    fill(mT324, range(0, dim324.capacity() - 1));

    BooleanValue[] result = new BooleanValue[dim324.cross(dim43).capacity()];
    Arrays.fill(result, TRUE);

    final int c324 = dim324.capacity(), c43 = dim43.capacity();
    final int c32443 = c324 * c43;

    for (int i = 0; i < c32443; i++) {
      result[i] = f.and(mT324.get(i / c43), mT43.get(i % c43));
    }
    assertTrue(equivalent(mT324.cross(mT43), result));

    mT324.set(1, TRUE);
    for (int i = c43; i < c43 * 2; i++) {
      result[i] = mT43.get(i % c43);
    }

    assertTrue(equivalent(mT324.cross(mT43), result));

    mT43.set(5, TRUE);
    for (int i = 0; i < c324; i++) {
      result[i * c43 + 5] = mT324.get(i);
    }

    assertTrue(equivalent(mT324.cross(mT43), result));

    mT324.set(10, FALSE);
    for (int i = c43 * 10; i < c43 * 11; i++) {
      result[i] = FALSE;
    }

    assertTrue(equivalent(mT324.cross(mT43), result));
    // System.out.println(Arrays.asList(result));
    // System.out.println(mT324.crossProduct(mT43));

  }
示例#2
0
 private final void assertCrossProductFalse(BooleanMatrix mF, BooleanMatrix m) {
   BooleanMatrix product = mF.cross(m);
   assertEquals(0, product.density());
   assertTrue(equivalent(mF.dimensions().cross(m.dimensions()), product.dimensions()));
 }