Next: , Previous: , Up: Matrix Functions   [Contents][Index]


16.4.2.7 Matrix Algebra Functions

Matrix Function: CHOL (M)

Matrix M must be an n×n symmetric positive-definite matrix. Returns an n×n matrix B such that B^T×B=M.

CHOL({4, 12, -16; 12, 37, -43; -16, -43, 98}) ⇒
  2  6 -8
  0  1  5
  0  0  3
Matrix Function: DESIGN (M)

Returns a design matrix for M. The design matrix has the same number of rows as M. Each column c in M, from left to right, yields a group of columns in the output. For each unique value v in c, from top to bottom, add a column to the output in which v becomes 1 and other values become 0.

PSPP issues a warning if a column only contains a single unique value.

DESIGN({1; 2; 3}) ⇒ {1, 0, 0; 0, 1, 0; 0, 0, 1}
DESIGN({5; 8; 5}) ⇒ {1, 0; 0, 1; 1, 0}
DESIGN({1, 5; 2, 8; 3, 5}){1, 0, 0, 1, 0; 0, 1, 0, 0, 1; 0, 0, 1, 1, 0}
DESIGN({5; 5; 5}) ⇒ (warning)
Matrix Function: DET (M)

Returns the determinant of square matrix M.

DET({3, 7; 1, -4}) ⇒ -19

Matrix Function: EVAL (M)

Returns a column vector containing the eigenvalues of symmetric matrix M, sorted in ascending order.

Use CALL EIGEN (see CALL EIGEN) to compute eigenvalues and eigenvectors of a matrix.

EVAL({2, 0, 0; 0, 3, 4; 0, 4, 9}) ⇒ {11; 2; 1}

Matrix Function: GINV (M)

Returns the k×n matrix A that is the generalized inverse of n×k matrix M, defined such that M×A×M=M and A×M×A=A.

GINV({1, 2}) ⇒ {.2; .4} (approximately)
{1:9} * GINV(1:9) * {1:9} ⇒ {1:9} (approximately)

Matrix Function: GSCH (M)

M must be a n×m matrix, mn, with rank n. Returns an n×n orthonormal basis for M, obtained using the Gram-Schmidt process.

GSCH({3, 2; 1, 2}) * SQRT(10) ⇒ {3, -1; 1, 3} (approximately)

Matrix Function: INV (M)

Returns the n×n matrix A that is the inverse of n×n matrix M, defined such that M×A = A×M = I, where I is the identity matrix. M must not be singular, that is, \det(M) ≠ 0.

INV({4, 7; 2, 6}) ⇒ {.6, -.7; -.2, .4} (approximately)

Matrix Function: KRONEKER (Ma, Mb)

Returns the pm×qn matrix P that is the Kroneker product of m×n matrix Ma and p×q matrix Mb. One may view P as the concatenation of multiple p×q blocks, each of which is the scalar product of Mb by a different element of Ma. For example, when A is a 2×2 matrix, KRONEKER(A, B) is equivalent to {A(1,1)*B, A(1,2)*B; A(2,1)*B, A(2,2)*B}.

KRONEKER({1, 2; 3, 4}, {0, 5; 6, 7}) ⇒
   0   5   0  10
   6   7  12  14
   0  15   0  20
  18  21  24  28
Matrix Function: RANK (M)

Returns the rank of matrix M, a integer scalar whose value is the dimension of the vector space spanned by its columns or, equivalently, by its rows.

RANK({1, 0, 1; -2, -3, 1; 3, 3, 0}) ⇒ 2
RANK({1, 1, 0, 2; -1, -1, 0, -2}) ⇒ 1
RANK({1, -1; 1, -1; 0, 0; 2, -2}) ⇒ 1
RANK({1, 2, 1; -2, -3, 1; 3, 5, 0}) ⇒ 2
RANK({1, 0, 2; 2, 1, 0; 3, 2, 1}) ⇒ 3
Matrix Function: SOLVE (Ma, Mb)

Ma must be an n×n matrix, with \det(Ma) ≠ 0, and Mb an n×k matrix. Returns an n×k matrix X such that Ma × X = Mb.

All of the following examples show approximate results:

SOLVE({2, 3; 4, 9}, {6, 2; 15, 5}) ⇒
   1.50    .50
   1.00    .33
SOLVE({1, 3, -2; 3, 5, 6; 2, 4, 3}, {5; 7; 8}) ⇒
 -15.00
   8.00
   2.00
SOLVE({2, 1, -1; -3, -1, 2; -2, 1, 2}, {8; -11; -3}) ⇒
   2.00
   3.00
  -1.00
Matrix Function: SVAL (M)

Given n×k matrix M, returns a \min(n,k)-element column vector containing the singular values of M in descending order.

Use CALL SVD (see CALL SVD) to compute the full singular value decomposition of a matrix.

SVAL({1, 1; 0, 0}) ⇒ {1.41; .00}
SVAL({1, 0, 1; 0, 1, 1; 0, 0, 0}) ⇒ {1.73; 1.00; .00}
SVAL({2, 4; 1, 3; 0, 0; 0, 0}) ⇒ {5.46; .37}
Matrix Function: SWEEP (M, nk)

Given r×c matrix M and integer scalar k = nk such that 1 ≤ k ≤ \min(r,c), returns the r×c sweep matrix A.

If M_{kk} ≠ 0, then:

A_{kk} = 1/M_{kk},
A_{ik} = -M_{ik}/M_{kk} for i ≠ k,
A_{kj} = M_{kj}/M_{kk} for j ≠ k, and
A_{ij} = M_{ij} - M_{ik}M_{kj}/M_{kk} for i ≠ k and j ≠ k.

If M_{kk} = 0, then:

A_{ik} = A_{ki} = 0 and
A_{ij} = M_{ij}, for i ≠ k and j ≠ k.

Given M = {0, 1, 2; 3, 4, 5; 6, 7, 8}, then (approximately):

SWEEP(M, 1) ⇒
   .00   .00   .00
   .00  4.00  5.00
   .00  7.00  8.00
SWEEP(M, 2) ⇒
  -.75  -.25   .75
   .75   .25  1.25
   .75 -1.75  -.75
SWEEP(M, 3) ⇒
 -1.50  -.75  -.25
  -.75  -.38  -.63
   .75   .88   .13

Next: Matrix Statistical Distribution Functions, Previous: Matrix Rank Ordering Functions, Up: Matrix Functions   [Contents][Index]