Two indices separated a semicolon A[i; j]

In an index expression like A[i; j], we still call i the row index and j the column index. If both i and j are scalars, then A[i; j] is the same as A[i, j]. Otherwise, one entry of the row index i matches one or more entries of the column index j. There are three types of match.

Firstly, if the row and column indices are vectors of the same length, then the two parts form matched pairs - The result of the index expression is a column vector of elements of the indexed matrix whose row and column indices are specified by i and j, namely, the numbers A[i[1], j[1]], A[i[2], j[2]], ...

For example, if both i and j have five elements, then the expression X[i; j] refers to the following matrix

In particular, if A is an matrix, then A[1:6; 1:6] returns the main diagonal of A, and A[2:6; 1:5] returns the first sub diagonal of A.

Second, if the length of the row index equals the number of rows of the column index then each entry of row index matches a row of the column index. For example, A[1:3; [1,2,3; 2,3,4; 3,4,5]] would form the following matrix

If the number of columns of the row index equals the length of the column index then each column of row index matches one entry of the column index. For example, A[[[1;2;3],[2;3;4], [3;4;5]]; [1,2,3]] would form the following matrix

oz 2009-12-22