Is there a way to display matrices in a shorter form similar to Short
or Shallow
?
I find that I very often want to inspect the initial and final rows and columns of matrices just to make sure I didn't do something completely silly when generating it. For matrices larger than the truncation size (say Partition[Range[10^6], 1000]
, Mathematica outputs (...1...)
in a box with the options "show less", "show more", "show all", and "set size limit...".
I don't know if "show more" is supposed to do something similar to what I want, but clicking it doesn't do anything. I also don't really want to see the entire matrix. I'd like functionality similar to what Short
does for 1D lists (i.e. Range[10^6]//Short
produces something like:
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,<<999966>>,999984,999985,999986,999987,999988,999989,999990,999991,999992,999993,999994,999995,999996,999997,999998,999999,1000000}
Ideally, I'd like something nearly as easy to read as the TableForm or MatrixForm of the full matrix, just with fewer lines. I realize I could do something like:
matrix[[Flatten[{Range[10], Range[-10, -1]}], Flatten[{Range[10], Range[-10, -1]}]]]
each time, but that seems tedious.
I haven't seen anything come up in my Google and MMA.SE searches, so perhaps this isn't a problem other people worry about. I've created my own code to deal with this in a way that's pleasing to my eye, so I'll post the code as an answer in case it helps anyone else. However, if anyone else has a better or more robust way please post an answer and I'll be glad to accept it!