@Test
  public final void testDotProduct() {
    fill(mF43, range(0, dim43.capacity() - 1));
    fill(mF4, range(0, dim4.capacity() - 1));

    assertDotProductFalse(mF324, mF43);
    assertDotProductFalse(mF324, mF4);

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

    BooleanValue[] result = new BooleanValue[dim324.dot(dim43).capacity()];
    for (int i = 0; i < result.length; i++) {
      result[i] = BooleanAccumulator.treeGate(Operator.Nary.OR);
    }
    int rows43 = dim324.dimension(dim324.numDimensions() - 1);
    int rows324 = dim324.capacity() / rows43;
    int cols43 = dim43.capacity() / rows43;
    for (int i = 0; i < rows324; i++) {
      for (int j = 0; j < cols43; j++) {
        for (int k = 0; k < rows43; k++) {
          int index324 = i * rows43 + k;
          int index43 = j + k * cols43;
          int indexR = cols43 * i + j;
          ((BooleanAccumulator) result[indexR]).add(f.and(mF324.get(index324), mF43.get(index43)));
        }
      }
    }
    for (int i = 0; i < result.length; i++) {
      result[i] = f.accumulate((BooleanAccumulator) result[i]);
    }

    assertTrue(equivalent(mF324.dot(mF43), result));

    for (int i = 0; i < dim324.capacity(); i += 2) {
      mF324.set(i, FALSE);
    }
    for (int i = 1; i < dim4.capacity(); i += 2) {
      mF4.set(i, FALSE);
    }

    assertDotProductFalse(mF324, mF4);
  }
 private final void assertDotProductFalse(BooleanMatrix mF, BooleanMatrix m) {
   BooleanMatrix product = mF.dot(m);
   assertEquals(0, product.density());
   assertTrue(equivalent(mF.dimensions().dot(m.dimensions()), product.dimensions()));
 }