# How to denote matrix elements succinctly? [closed]

Is there a more elegant way of dealing with the following subscripting?

Do[threetest =
MatrixRank[{{threepoints[[i]][[2]][[1]] -
threepoints[[i]][[1]][[1]],
threepoints[[i]][[2]][[2]] - threepoints[[i]][[1]][[2]]},
{threepoints[[i]][[3]][[1]] - threepoints[[i]][[1]][[1]],
threepoints[[i]][[3]][[2]] - threepoints[[i]][[1]][[2]]}}];
If[threetest < 2, Break[], 1], {i, Binomial[n, 3]}]

• If the last dimension of threePoints is two, then you might try something like MatrixRank[threepoints[[i, 2 ;; 3]] - threepoints[[i, 1]]]. – WReach Apr 26 '19 at 18:29

If threepoints is defined with any kind of regularity, then threepoints[[i]][[2]][[1]] is the same as threepoints[[i,2,1]]. See the documentation of Part.

Further, you can do vector processing with ;;, along the lines of

Do[threetest =
MatrixRank[{threepoints[[i, 2, 1 ;; 2]] - threepoints[[i, 1, 1 ;; 2]],
threepoints[[i, 3, 1 ;; 2]] - threepoints[[i, 1, 1 ;; 2]]}];
If[threetest < 2, Break[], 1],
{i, Binomial[n, 3]}]


If the third coordinate of threetest has only two slots (that is, if Dimensions[threetest] returns {something,something,2}), then the above can also be written as

Do[threetest =
MatrixRank[{threepoints[[i, 2]] - threepoints[[i, 1]],
threepoints[[i, 3]] - threepoints[[i, 1]]}];
If[threetest < 2, Break[], 1],
{i, Binomial[n, 3]}]


The other thing I do is to use the stylized brackets in all of my MMA code. Stackexchange mangles it, so have to use a picture to demonstrate: