check for matrix size