public static int scalarProduct(final long[] x,final long[] y){
  int sum=0;
  for (int i=y.length; i-- != 0; ) {
    final long high=x[i] & 0xAAAAAAAAAAAAAAAAL;
    final long low=x[i] & 0x5555555555555555L;
    final long highShift=high >>> 1;
    final long t=(y[i] ^ (high | highShift)) & (x[i] | highShift | low << 1);
    sum+=Long.bitCount(t & 0xAAAAAAAAAAAAAAAAL) * 2 + Long.bitCount(t & 0x5555555555555555L);
  }
  return sum;
}

public static int scalarProduct ( final long [ ] x , final long [ ] y ) { int sum = 0 ; for ( int i = y . length ; i -- != 0 ; ) { final long high = x [ i ] & 0xAAAAAAAAAAAAAAAAL ; final long low = x [ i ] & 0x5555555555555555L ; final long highShift = high > > > 1 ; final long t = ( y [ i ] ^ ( high | highShift ) ) & ( x [ i ] | highShift | low << 1 ) ; sum += Long . bitCount ( t & 0xAAAAAAAAAAAAAAAAL ) * 2 + Long . bitCount ( t & 0x5555555555555555L ) ; } return sum ; }
returns the modulo - 3 scalar product of the two provided bit vectors .
