Skip to contents

Three different things, despite the similar names – read the one you need. tda_minvs is the actual matrix inverse of a symmetric positive-definite matrix (TDA's minvs, via a Cholesky-based algorithm; refuses if not positive definite). tda_minvd inverts only the diagonal elements of A, element by element – not a matrix inverse at all, and off-diagonal entries are ignored entirely (TDA's minvd; a zero diagonal entry is silently left as 0 rather than inverted). tda_mginv is the Moore-Penrose pseudoinverse, requiring at least as many rows as columns and full column rank (TDA's mginv; prints the pseudorank as a side effect, discarded here – read it from attr(x, "run")$output if needed).

Usage

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

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

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

Arguments

A

a numeric matrix: square for tda_minvs; any shape for tda_minvd; at least as many rows as columns for tda_mginv.

dir

working directory.

Value

A numeric matrix.

Examples

A <- matrix(c(4, 2, 2, 3), 2)
tda_minvs(A)            # == solve(A) for symmetric positive-definite A
#>        [,1]  [,2]
#> [1,]  0.375 -0.25
#> [2,] -0.250  0.50
tda_minvd(matrix(c(2, 1, 4, 5, 3, 8, 9, 7, 1), 3))  # diag(1/diag(.))
#>      [,1]      [,2] [,3]
#> [1,]  0.5 0.0000000    0
#> [2,]  0.0 0.3333333    0
#> [3,]  0.0 0.0000000    1
tda_mginv(matrix(c(1, 1, 1, 1, 2, 3), 3))
#>           [,1]         [,2]       [,3]
#> [1,]  1.333333 3.333333e-01 -0.6666667
#> [2,] -0.500000 5.551115e-17  0.5000000