Skip to contents

tda_msvd returns just the singular values – TDA's msvd. tda_msvd1 returns the full decomposition A = U %*% diag(d) %*% t(V) – TDA's msvd1, matching base R's svd() convention exactly (singular vectors as columns of u/v). A must have at least as many rows as columns for either. As with any singular vector, each column's sign is arbitrary and need not match svd()'s choice.

Usage

tda_msvd(A, dir = tempfile("tda"))

tda_msvd1(A, dir = tempfile("tda"))

Arguments

A

a numeric matrix with at least as many rows as columns.

dir

working directory.

Value

tda_msvd returns a plain numeric vector of singular values. tda_msvd1 returns a list: d, the singular values; u, v, the singular vectors as columns.

Examples

A <- matrix(c(1, 3, 5, 2, 4, 7), 3, 2)
tda_msvd(A)     # == svd(A)$d
#> [1] 10.1914283  0.3671377
tda_msvd1(A)    # == svd(A), up to per-column sign
#> $d
#> [1] 10.1914283  0.3671377
#> 
#> $u
#>           [,1]        [,2]
#> [1,] 0.2167839  0.93892288
#> [2,] 0.4904541 -0.34146390
#> [3,] 0.8440732 -0.04273442
#> 
#> $v
#>           [,1]       [,2]
#> [1,] 0.5797531 -0.8147922
#> [2,] 0.8147922  0.5797531
#>