check if matrix is defined