Improve error trace for bad matrix definitions