Skip to content

Arrays

The number of rows of A (0 for a number).

rows([1, 2, 3; 4, 5, 6]) = 2

The number of columns of A.

cols([1, 2, 3; 4, 5, 6]) = 3

The number of elements of the vector v.

length([4; 5; 6; 7]) = 4

The index of the last element of v, counting from ORIGIN.

last([4; 5; 6; 7]) = 3

An m×n matrix whose element (i, j) is f(i, j), i and j counting from 0.

f(i, j) := i + 10*j
matrix(2, 3, f) = [0, 10, 20; 1, 11, 21]

The n×n identity matrix.

identity(3) = [1, 0, 0; 0, 1, 0; 0, 0, 1]

The matrices side by side; they need the same number of rows.

augment([1; 2], [3; 4]) = [1, 3; 2, 4]

The matrices one above the other; they need the same number of columns.

stack([1, 2], [3, 4]) = [1, 2; 3, 4]

The part of A from row ir to jr and column ic to jc, counting from ORIGIN.

M := [1, 2, 3; 4, 5, 6; 7, 8, 9]
submatrix(M, 1, 2, 0, 1) = [4, 5; 7, 8]

The trace of the square matrix M, the sum of its diagonal.

tr([1, 2; 3, 4]) = 5

The elements of v in reverse order (the rows of a matrix).

reverse([1; 2; 3]) = [3; 2; 1]

The elements of v in ascending order.

sort([3; 1; 2]) = [1; 2; 3]

The rows of A sorted by column j.

csort([3, 30; 1, 10; 2, 20], 0) = [1, 10; 2, 20; 3, 30]

The columns of A sorted by row i.

rsort([3, 1, 2; 30, 10, 20], 0) = [1, 2, 3; 10, 20, 30]

n values evenly spaced from a to b, as a column.

linspace(0 m, 1 m, 5) = [0; 0.25; 0.5; 0.75; 1]*m

n values from a to b, evenly spaced on a log scale.

logspace(1, 1000, 4) = [1; 10; 100; 1000]

The cross product of the three-element vectors u and v.

cross([1; 0; 0], [0; 1; 0]) = [0; 0; 1]

The eigenvalues of the square matrix M, as a column.

eigenvals([2, 0; 0, 3]) = [2; 3]

The eigenvectors of M, one per column, in the order of eigenvals(M), each of length 1.

eigenvecs([2, 1; 1, 2]) = [0.707, 0.707; -0.707, 0.707]

The eigenvector of M for the eigenvalue λ, of length 1.

eigenvec([2, 1; 1, 2], 3) = [0.707; 0.707]

The positions in A of the value z, or with mode “near”, “lt”, “gt”, “leq” or “geq” of the nearest value, the one just below or just above.

match(5, [2; 5; 7]) = [1]
match(6, [2; 5; 7], "lt") = [1]

The elements of column j of A in the rows whose first element is z.

vlookup(2, [1, 10; 2, 20; 3, 30], 1) = [20]

The elements of row i of A in the columns whose first element is z.

hlookup(2, [1, 2, 3; 10, 20, 30], 1) = [20]

The elements of B in the places where A holds z.

lookup(2, [1; 2; 3], [10; 20; 30]) = [20]

A range of a named table’s grid, written as in a spreadsheet, the header being row 1.

1 if x is an array, 0 if not.

IsArray([1; 2]) = 1

1 if x is a number, 0 if not.

IsScalar(3 m) = 1