svd2: singular value decomposition with automatic error handling

Description Usage Arguments Details Value See Also Examples

View source: R/svd2.R

Description

The 'svd' function in R 2.5.1 occasionally throws an error with a cryptic message. In some such cases, changing the LINPACK argument has worked.

Usage

1
  svd2(x, nu = min(n, p), nv = min(n, p), LINPACK = FALSE)

Arguments

x, nu, nv, LINPACK

as for the 'svd' function in the 'base' package.

Details

In R 2.5.1, the 'svd' function sometimes stops with a cryptic error message for a matrix x for which a second call to 'svd' with !LINPACK will produce an answer.

When such conditions occur, write a warning and save the matrix with the result to a file with a name like 'svd.LINPACK.error.matrix*.rda' in the working directory.

Except for these rare pathologies, 'svd2' should work the same as 'svd'.

NOTE: This function was written to get past a pathology without isolating a replicable example. The problem may have long been fixed. It is maintained in case it has not.

Value

a list with components d, u, and v, as described in the help file for 'svd' in the 'base' package.

See Also

svd

Examples

1
2
3
4
5
6
7
8
# example from svd
hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") }
X <- hilbert(9)[, 1:6]
s <- svd(X)

s2 <- svd2(X)

all.equal(s, s2)

fda documentation built on May 2, 2019, 5:12 p.m.