Learn R Programming

kazaam (version 0.1-0)

svd: svd

Description

Singular value decomposition.

Usage

# S4 method for shaq
svd(x, nu = min(n, p), nv = min(n, p), LINPACK = FALSE)

Arguments

x

A shaq.

nu

number of left singular vectors to return.

nv

number of right singular vectors to return.

LINPACK

Ignored.

Value

A list of elements d, u, and v, as with R's own svd(). The elements are, respectively, a regular vector, a shaq, and a regular matrix.

Communication

The operation is completely local except for forming the crossproduct, which is an allreduce() call, quadratic on the number of columns.

Details

The factorization works by first forming the crossproduct \(X^T X\) and then taking its eigenvalue decomposition. In this case, the square root of the eigenvalues are the singular values. If the left/right singular vectors \(U\) or \(V\) are desired, then in either case, \(V\) is computed (the eigenvectors). From these, \(U\) can be reconstructed, since if \(X = U\Sigma V^T\), then \(U = XV\Sigma^{-1}\).

Examples

Run this code

library(kazaam)
x = ranshaq(runif, 10, 3)

svd = svd(x)
comm.print(svd$d) # a globally owned vector
svd$u # a shaq
comm.print(svd$v) # a globally owned matrix

finalize()


Run the code above in your browser using DataLab