Computes the Bunch-Kaufman factorization of an \(n \times n\) real, symmetric matrix \(A\), which has the general form $$A = U D_{U} U' = L D_{L} L'$$ where \(D_{U}\) and \(D_{L}\) are symmetric, block diagonal matrices composed of \(b_{U}\) and \(b_{L}\) \(1 \times 1\) or \(2 \times 2\) diagonal blocks; \(U = \prod_{k = 1}^{b_{U}} P_{k} U_{k}\) is the product of \(b_{U}\) row-permuted unit upper triangular matrices, each having nonzero entries above the diagonal in 1 or 2 columns; and \(L = \prod_{k = 1}^{b_{L}} P_{k} L_{k}\) is the product of \(b_{L}\) row-permuted unit lower triangular matrices, each having nonzero entries below the diagonal in 1 or 2 columns.

Methods are built on LAPACK routines dsytrf and dsptrf.

BunchKaufman(x, ...)
# S4 method for class 'dsyMatrix'
BunchKaufman(x, warnSing = TRUE, ...)
# S4 method for class 'dspMatrix'
BunchKaufman(x, warnSing = TRUE, ...)
# S4 method for class 'matrix'
BunchKaufman(x, uplo = "U", ...)

Arguments

x

a finite symmetric matrix or Matrix to be factorized. If x is square but not symmetric, then it will be treated as symmetric; see uplo.

warnSing

a logical indicating if a warning should be signaled for singular x.

uplo

a string, either "U" or "L", indicating which triangle of x should be used to compute the factorization.

...

further arguments passed to or from methods.

Value

An object representing the factorization, inheriting from virtual class BunchKaufmanFactorization. The specific class is BunchKaufman unless x inherits from virtual class packedMatrix, in which case it is pBunchKaufman.

See also

Classes BunchKaufman and pBunchKaufman and their methods.

Classes dsyMatrix and dspMatrix.

Generic functions expand1 and expand2, for constructing matrix factors from the result.

Generic functions Cholesky, Schur, lu, and qr, for computing other factorizations.

References

The LAPACK source code, including documentation; see https://netlib.org/lapack/double/dsytrf.f and https://netlib.org/lapack/double/dsptrf.f.

Golub, G. H., & Van Loan, C. F. (2013). Matrix computations (4th ed.). Johns Hopkins University Press. doi:10.56021/9781421407944

Examples

showMethods("BunchKaufman", inherited = FALSE)
#> Function: BunchKaufman (package Matrix)
#> x="dspMatrix"
#> x="dsyMatrix"
#> x="matrix"
#> 
set.seed(0)

data(CAex, package = "Matrix")
class(CAex) # dgCMatrix
#> [1] "dgCMatrix"
#> attr(,"package")
#> [1] "Matrix"
isSymmetric(CAex) # symmetric, but not formally
#> [1] TRUE

A <- as(CAex, "symmetricMatrix")
class(A) # dsCMatrix
#> [1] "dsCMatrix"
#> attr(,"package")
#> [1] "Matrix"

## Have methods for denseMatrix (unpacked and packed),
## but not yet sparseMatrix ...
if (FALSE) { # \dontrun{
(bk.A <- BunchKaufman(A))
} # }
(bk.A <- BunchKaufman(as(A, "unpackedMatrix")))
#> Bunch-Kaufman factorization of Formal class 'BunchKaufman' [package "Matrix"] with 5 slots
#>   ..@ uplo    : chr "U"
#>   ..@ x       : num [1:5184] 4.16e-16 0.00 0.00 0.00 0.00 ...
#>   ..@ perm    : int [1:72] 1 2 3 4 5 6 7 8 9 10 ...
#>   ..@ Dim     : int [1:2] 72 72
#>   ..@ Dimnames:List of 2
#>   .. ..$ : NULL
#>   .. ..$ : NULL

## A ~ U DU U' in floating point
str(e.bk.A <- expand2(bk.A), max.level = 2L)
#> List of 3
#>  $ U :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
#>  $ DU:Formal class 'dsCMatrix' [package "Matrix"] with 7 slots
#>  $ U.:Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
stopifnot(all.equal(as(A, "matrix"), as(Reduce(`%*%`, e.bk.A), "matrix")))