matrix multiplication for checking