the (Index % Number) way of things, what exactly does it do here. |
In this instance, using the modulus operator % that @Keskiverto has explained above allows you derive successive terms in things like matrix expansions by
cyclic permutation.
For example, if you wanted to add 1 to each term, you would want (0,1,2) to become (1,2,3), but 3 would be outside the index allowed, so using %3 cycles the result correctly to (1,2,0).
The inverse of a matrix is given by:
(transpose of matrix of cofactors) / determinant
If you can find just one term of the inverse matrix, say B
00 (counting from 0, with B the inverse matrix of A), then you can find all others just by cyclic permutation of first or second index.
For example, the (0,0) term comes from i=0,j=0 on line 32:
(cofactor A)
T00 = (cofactor A)
00 = a
11a
22-a
12a
21
But once you have this you can just increase the i and/or j indices and cyclically permute where necessary; e.g.
(cofactor A)
T01 = (cofactor A)
10 = a
21a
32-a
22a
31 , incorrectly using a 3 index, but the % allows you to correct this to
a
21a
02-a
22a
01
Note that the unusual case of having a j index coming before the i index on the right-hand side of line 32 arises from transposing a matrix in finding the inverse.