Skip to contents

Eigenvalues and eigenvectors of a symmetric matrix – TDA's mevs. Eigenvalues come back in descending order, same as base R's eigen(A, symmetric = TRUE). The eigenvectors come back as the columns of vectors, same convention as eigen()$vectors (column i satisfies A %*% vectors[, i] == values[i] * vectors[, i]); an initial 2x2 test matrix was checked first and satisfied this equally well as rows, which turned out to be a coincidence of that specific matrix's eigenvector matrix happening to be symmetric, not a real property of TDA's convention – worth recording since it is exactly the kind of false confirmation a too-simple test case can produce. As with any eigenvector, the sign of each one is arbitrary; TDA's and R's choices need not agree.

Usage

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

Arguments

A

a symmetric numeric matrix (only the lower triangle is read).

dir

working directory.

Value

A list: values, the eigenvalues in descending order; vectors, a matrix whose columns are the corresponding unit-norm eigenvectors.

Examples

A <- matrix(c(4, 1, 0,
              1, 3, 1,
              0, 1, 2), 3)
e <- tda_mevs(A)
e$values                      # descending, as eigen(A)$values
#> [1] 4.732051 3.000000 1.267949
A %*% e$vectors[, 1] - e$values[1] * e$vectors[, 1]   # zero: an eigenpair
#>              [,1]
#> [1,] 4.440892e-16
#> [2,] 4.440892e-16
#> [3,] 2.220446e-16