Vastly faster ndarray comparison funciton.