premature optimization alert!
I wonder if this would be faster if the arrays where float32 instead of integers, the float boolean operations are vectorized while the integers are not (yet), would probably needs range checks to avoid rounding issues