Learn R Programming

lrstat (version 0.2.13)

svdcpp: Singular Value Decomposition of a Matrix

Description

Computes the singular-value decomposition of a rectangular matrix.

Usage

svdcpp(X, outtransform = 1L, decreasing = 1L)

Value

A list with the following components:

  • d: A vector containing the singular values of \(X\).

  • U: A matrix whose columns contain the left singular vectors of \(X\).

  • V: A matrix whose columns contain the right singular vectors of \(X\).

Arguments

X

A numeric matrix whose SVD decomposition is to be computed.

outtransform

Whether the orthogonal matrices composing of the left and right singular vectors are to be computed.

decreasing

Whether the singular values should be sorted in decreasing order and the corresponding singular vectors rearranged accordingly.

Author

Kaifeng Lu, kaifenglu@gmail.com

Details

Given \(A \in R^{m\times n} (m \geq n)\), the following algorithm overwrites \(A\) with \(U^T A V = D\), where \(U\in R^{m\times m}\) is orthogonal, \(V \in R^{n\times n}\) is orthogonal, and \(D \in R^{m\times n}\) is diagonal.

References

Gene N. Golub and Charles F. Van Loan. Matrix Computations, second edition. Baltimore, Maryland: The John Hopkins University Press, 1989, p.434.

Examples

Run this code

A <- matrix(c(1,0,0,0, 1,2,0,0, 0,1,3,0, 0,0,1,4), 4, 4)
svdcpp(A)

Run the code above in your browser using DataLab