# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
require 'narray'
+require 'pp'
BitsInChar = 8
end
# Method that returns the number of bits set "on" in a bit array.
- def bits_on
- bits_on = 0
-
- self.byte_array.each do |byte|
- bits_on += @count_array[byte]
- end
-
- bits_on
+ def bits_on
+ index = NArray.sint(*self.byte_array.shape)
+ index[] = self.byte_array
+ NArray.to_na(@count_array)[index].sum
end
# Method that returns the number of bits set "off" in a bit array.