/** * Computes the inner product of two lists of StrictBitVector objects. The product will be based * on Galois multiplication in the binary extension field of the individual elements of the lists, * but without reducing modulo a reduction polynomial. Thus the inner product is computed purely * using shifts and XOR operations. <br/> * All elements of both lists MUST have equal size! And both lists MUST contain an equal amount of * entries! * * @param alist The first input list, with all elements of equal size * @param blist The second input list, with all elements of equal size * @return The inner product represented as a StrictBitVector */ protected static StrictBitVector computeInnerProduct(List<StrictBitVector> alist, List<StrictBitVector> blist) { // All elements of each list MUST have equal size so we find the size using the first element. StrictBitVector res = new StrictBitVector(alist.get(0).getSize() + blist.get(0).getSize()); List<StrictBitVector> products = IntStream.range(0, alist.size()).parallel() .mapToObj(i -> multiplyWithoutReduction(alist.get(i), blist.get(i))) .collect(Collectors.toList()); products.stream().reduce(res, (a, b) -> { a.xor(b); return a; }); return res; }