Next: swp() Up: MacAnova Help File Previous: sum()   Contents

# svd()

Usage:
 ```svd(x [,left:T or F,right:T or F, all:T, maxit:N, nonconvok:T]), x a REAL matrix, N > 0 an integer ```

Keywords: matrix algebra
```Function svd() computes some or all of the parts (singular values, left
singular vectors and right singular vectors) of the singular value
decomposition (SVD) of a matrix.

svd(x) computes the vector of singular values in order of decreasing
size, of the m by n REAL matrix x.  When m < n, the last n - m elements
of values are 0.

svd(x,left:T) computes the singular values and the m by n matrix of
orthonormal left singular vectors in a structure with components
'values' and 'leftvectors'.  When m < n, the last n - m elements of
values are 0 as are the last n - m columns of leftvectors.

svd(x,right:T) computes the singular values and the orthogonal n by n
matrix of right singular vectors in a structure with components 'values'
and 'rightvectors'.  When m < n, the last n - m elements of values are 0
and the last n - m columns of rightvectors are orthonormal vectors
orthogonal to the first n columns, but are otherwise arbitrary.

svd(x,all:T) and svd(x,left:T,right:T) both compute a structure with
components 'values', 'leftvectors', and 'rightvectors'

svd(x,all:T,vals:F) computes a structure with components 'leftvectors'
and 'rightvectors' only.  Other combinations of all:T and other keywords
are possible and do what you would expect.

If x has labels, the row labels of the matrices of left and right
singular vectors are the row and column labels of x, respectively.  The
column labels are numerical.  The vector of singular values is
unlabelled.  See topic 'labels'.

If l and r are the matrices of left and right singular vectors and s is
the vector of singular values then they satisfy (except for rounding
error) l %*% dmat(s) %*% r' = x and l %c% l = r %c% r = I-sub-m (when m
< n, only the upper left m by m block of l %c% l is I-sub-m).

Non-convergence
It is possible for the algorithm used by svd() not to converge, although
it rarely happens.  When it happens, the message
ERROR: singular value algorithm in svd() did not converge
is printed.  Keywords 'maxit' and 'nonconvok' may be helpful in this
situation.

svd(x [,keywords], maxit:N), where N > 0 is an integer, computes the
singular value decomposition, but sets the maximum number of iterations
in the algorithm to N.  The default value is 30.  By using N > 30, this
may allow you to compute the SVD.

svd(x [,keywords] ,nonconvok:T) does the same, except failure to
converge is not an error.  When convergence does not occur, no message
printed and NULL is returned.  You can use this in a macro to make it
possible to recover from failure to converge, perhaps by invoking svd()
again using 'maxit' to increase the number of iterations.