1function [L, w] = chol_downdate (L, w)
2%CHOL_DOWNDATE downdate a Cholesky factorization.
3% Example
4%   [L, w] = chol_downdate (L, w)
5% See also: cs_demo
6
7% Copyright 2006-2012, Timothy A. Davis, http://www.suitesparse.com
8
9beta = 1 ;
10n = size (L,1) ;
11for j = 1:n
12    alpha = w (j) / L (j,j) ;
13    beta2 = sqrt (beta^2 - alpha^2) ;
14    if (~isreal (beta2))
15        error ('not positive definite') ;
16    end
17    gamma = alpha / (beta2 * beta) ;
18    delta = beta2 / beta ;
19    L (j,j) = delta * L (j,j) ;
20    w (j) = alpha ;
21    beta = beta2 ;
22    if (j == n)
23        return
24    end
25    w (j+1:n) = w (j+1:n) - alpha * L (j+1:n,j) ;
26    L (j+1:n,j) = delta * L (j+1:n,j) - gamma * w (j+1:n) ;
27end
28