/** * @return true if all cells in m have the same value as the corresponding cell in bs. The method * assumes that m.dimensions==b.dimensions. */ private static final boolean equivalent(BooleanMatrix m, BooleanMatrix b) { if (!(equivalent(m.dimensions(), b.dimensions()) && m.density() == b.density())) return false; int max = m.dimensions().capacity(); for (int i = 0; i < max; i++) { if (m.get(i) != b.get(i)) return false; } return true; }
@Test public final void testTranspose() { BooleanMatrix mF43t = mF43.transpose(); assertEquals(mF43.density(), mF43t.density()); assertTrue(equivalent(dim43.transpose(), mF43t.dimensions())); fill(mF43, range(0, dim43.capacity() - 1)); BooleanValue[] result = new BooleanValue[dim43.capacity()]; final int a = dim43.dimension(0), b = dim43.dimension(1); for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { result[j * a + i] = vars[i * b + j]; } } mF43t = mF43.transpose(); assertEquals(mF43.density(), mF43t.density()); assertTrue(equivalent(dim43.transpose(), mF43t.dimensions())); assertTrue(equivalent(mF43t, result)); }
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())); }