BitSetUtils { public static boolean innerProduct(BitSet a, BitSet b) { BitSet buffer = copy(a); buffer.and(b); return isOdd(buffer.cardinality()); } private  BitSetUtils(); static BitSet copy(BitSet b); static BitSet getRandomBits(int n, Random random); static String toString(BitSet bits, int n); static String toString(BitSet bits); static boolean innerProduct(BitSet a, BitSet b); static BitSet fromList(List<Boolean> list); static BitSet fromArray(boolean[] array); static boolean[] toArray(BitSet bitset, int length); static List<Boolean> toList(BitSet bitset, int n);  }
@Test public void testInnerProduct() { BitSet a = new BitSet(8); a.set(0); a.set(5); a.set(7); BitSet b = new BitSet(8); b.set(0); b.set(5); Assert.assertFalse(BitSetUtils.innerProduct(a, b)); b.set(1); Assert.assertFalse(BitSetUtils.innerProduct(a, b)); b.set(7); Assert.assertTrue(BitSetUtils.innerProduct(a, b)); BitSet c = new BitSet(10); Assert.assertFalse(BitSetUtils.innerProduct(a, c)); c.set(10); Assert.assertFalse(BitSetUtils.innerProduct(a, c)); c.set(0); Assert.assertTrue(BitSetUtils.innerProduct(a, c)); }