code: public static int cardinality(long[] v) {
      int sum = 0;
      for(int i = 0; i < v.length; i++) {
        sum += Long.bitCount(v[i]);
      }
      return sum;
    }
docs: Compute the cardinality (number of set bits)
  <p>
  Low-endian layout for the array.
  
  @param v Value
  @return Number of bits set in long[]