Learn R Programming

gputools (version 0.26)

gpuSvd: Singular Value Decomposition of a Matrix with a GPU

Description

Compute the singular-value decomposition of a rectangular matrix using the Cula library to compute the decomposition using a GPU.

Usage

gpuSvd(x, nu = min(n, p), nv = min(n, p))

Arguments

x
a real matrix whose SVD decomposition is to be computed.
nu
the number of left singular vectors to be computed. This must between 0 and n = nrow(x).
nv
the number of right singular vectors to be computed. This must be between 0 and p = ncol(x).

Value

  • The SVD decomposition of the matrix, $$\bold{X = U D V'},$$ where $\bold{U}$ and $\bold{V}$ are orthogonal, $\bold{V'}$ means V transposed, and $\bold{D}$ is a diagonal matrix with the singular values $D_{ii}$. Equivalently, $\bold{D = U' X V}$, which is verified in the examples, below.

    The returned value is a list with components

  • da vector containing the singular values of x, of length min(n, p).
  • ua matrix whose columns contain the left singular vectors of x, present if nu > 0. Dimension c(n, nu).
  • va matrix whose columns contain the right singular vectors of x, present if nv > 0. Dimension c(p, nv).

Details

The computation will be more efficient if nu <= min(n,="" p)<="" code=""> and nv <= min(n,="" p)<="" code="">, and even more efficient if one or both are zero.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

Dongarra, J. J., Bunch, J. R., Moler, C. B. and Stewart, G. W. (1978) LINPACK Users Guide. Philadelphia: SIAM Publications.

Anderson. E. and ten others (1999) LAPACK Users' Guide. Third Edition. SIAM. Available on-line at http://www.netlib.org/lapack/lug/lapack_lug.html.

See Also

eigen, qr.

Examples

Run this code
hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") }
X <- hilbert(9)[,1:6]
(s <- gpuSvd(X))
D <- diag(s$d)
s$u %*% D %*% t(s$v) #  X = U D V'
t(s$u) %*% X %*% s$v #  D = U' X V

Run the code above in your browser using DataLab