checks for sparse matrix construction with I,J,V

fixes #8225
Merge pull request #8230 from tanmaykm/fix8225

checks for sparse matrix construction with I,J,V