Skip to contents

Finds a symmetric permutation that puts a square matrix into block lower-triangular (tda_mpbl) or block upper-triangular (tda_mpbu) form (Duff & Reid, CACM 529) – TDA's mpbl/mpbu. B[i, j] == A[p[i], p[j]] for every i, j; block gives, for each row/column of B, which block it belongs to (blocks numbered in the order B is arranged, so entries between an earlier and a later block are always zero on the side tda_mpbl/tda_mpbu promises – confirmed on an instance with cross-block coupling, not one where every block trivially has size 1).

Usage

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

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

Arguments

A

a square numeric matrix.

dir

working directory.

Value

A list: B, the permuted, block-triangular matrix; p, the permutation (B == A[p, p]); block, an integer vector the same length as p giving each position's block number.

Examples

A <- matrix(c(1, 2, 0, 0, 0, 1, 0, 0, 0, 0, 1, 3, 0, 0, 0, 1), 4, 4)
r <- tda_mpbl(A)
r$B
#>      [,1] [,2] [,3] [,4]
#> [1,]    1    0    0    0
#> [2,]    2    1    0    0
#> [3,]    0    0    1    0
#> [4,]    0    0    3    1