Returns the first two dimensions of an array as matrix
matrix(A)
Returns promote(A,2), if A is a scalar or vector and otherwise returns the elements of the first two dimensions as a matrix. size(A,i) = 1 is required for 2 < i ≤ ndims(A).
Function promote(A,n) fills dimensions of size 1 from the right to array A up to dimension n, where "n > ndims(A)" is required. Let C = promote(A,n), with nA = ndims(A), then
ndims(C) = n, size(C,j) = size(A,j) for 1 ≤ j ≤ nA, size(C,j) = 1 for nA+1 ≤ j ≤ n, C[i_1, ..., i_nA, 1, ..., 1] = A[i_1, ..., i_nA].