catch illegal matrix operations