Computes Choleski decomposition of a (symmetric positive definite) tri-diagonal matrix stored as a leading diagonal and sub/super diagonal.

trichol(ld,sd)

Arguments

ld

leading diagonal of matrix

sd

sub-super diagonal of matrix

Value

A list with elements ld and sd. ld is the leading diagonal and sd is the super diagonal of bidiagonal matrix \(\bf B\) where \({\bf B}^T{\bf B} = {\bf T}\) and \(\bf T\) is the original tridiagonal matrix.

Details

Calls dpttrf from LAPACK. The point of this is that it has \(O(n)\) computational cost, rather than the \(O(n^3)\) required by dense matrix methods.

See also

Author

Simon N. Wood simon.wood@r-project.org

References

Anderson, E., Bai, Z., Bischof, C., Blackford, S., Dongarra, J., Du Croz, J., Greenbaum, A., Hammarling, S., McKenney, A. and Sorensen, D., 1999. LAPACK Users' guide (Vol. 9). Siam.

Examples

require(mgcv)
## simulate some diagonals...
set.seed(19); k <- 7
ld <- runif(k)+1
sd <- runif(k-1) -.5

## get diagonals of chol factor...
trichol(ld,sd)
#> $ld
#> [1] 1.056944 1.216233 1.254832 1.017814 1.164840 1.105459 1.105716
#> 
#> $sd
#> [1]  0.06933549  0.27677293  0.18014527 -0.09189728 -0.04316683  0.26319837
#> 

## compare to dense matrix result...
A <- diag(ld);for (i in 1:(k-1)) A[i,i+1] <- A[i+1,i] <- sd[i]
R <- chol(A)
diag(R);diag(R[,-1])
#> [1] 1.056944 1.216233 1.254832 1.017814 1.164840 1.105459 1.105716
#> [1]  0.06933549  0.27677293  0.18014527 -0.09189728 -0.04316683  0.26319837