bit matrix impl