check whether the matrix format is valid
If True, rigorous check, O(N) operations. Otherwise basic check, O(1) operations (default True).