9.5 Vector and Matrix Arithmetic

Basic arithmetic operations like addition and multiplication are defined for vectors and matrices as well as for numbers. Division of matrices, in the sense of multiplying by the inverse, is supported. (Division by a matrix actually uses LU-decomposition for greater accuracy and speed.) See Basic Arithmetic.

The following functions are applied element-wise if their arguments are vectors or matrices: change-sign, conj, arg, re, im, polar, rect, clean, float, frac. See Index of Algebraic Functions.

The V J (calc-conj-transpose) [ctrn] command computes the conjugate transpose of its argument, i.e., ‘conj(trn(x))’.

The A (calc-abs) [abs] command computes the Frobenius norm of a vector or matrix argument. This is the square root of the sum of the squares of the absolute values of the elements of the vector or matrix. If the vector is interpreted as a point in two- or three-dimensional space, this is the distance from that point to the origin.

The v n (calc-rnorm) [rnorm] command computes the infinity-norm of a vector, or the row norm of a matrix. For a plain vector, this is the maximum of the absolute values of the elements. For a matrix, this is the maximum of the row-absolute-value-sums, i.e., of the sums of the absolute values of the elements along the various rows.

The V N (calc-cnorm) [cnorm] command computes the one-norm of a vector, or column norm of a matrix. For a plain vector, this is the sum of the absolute values of the elements. For a matrix, this is the maximum of the column-absolute-value-sums. General ‘k’-norms for ‘k’ other than one or infinity are not provided. However, the 2-norm (or Frobenius norm) is provided for vectors by the A (calc-abs) command.

The V C (calc-cross) [cross] command computes the right-handed cross product of two vectors, each of which must have exactly three elements.

The & (calc-inv) [inv] command computes the inverse of a square matrix. If the matrix is singular, the inverse operation is left in symbolic form. Matrix inverses are recorded so that once an inverse (or determinant) of a particular matrix has been computed, the inverse and determinant of the matrix can be recomputed quickly in the future.

If the argument to & is a plain number ‘x’, this command simply computes ‘1/x’. This is okay, because the ‘/’ operator also does a matrix inversion when dividing one by a matrix.

The V D (calc-mdet) [det] command computes the determinant of a square matrix.

The V L (calc-mlud) [lud] command computes the LU decomposition of a matrix. The result is a list of three matrices which, when multiplied together left-to-right, form the original matrix. The first is a permutation matrix that arises from pivoting in the algorithm, the second is lower-triangular with ones on the diagonal, and the third is upper-triangular.

The V T (calc-mtrace) [tr] command computes the trace of a square matrix. This is defined as the sum of the diagonal elements of the matrix.

The V K (calc-kron) [kron] command computes the Kronecker product of two matrices.