cholupdate
1级更新to Cholesky factorization
Syntax
R1 = cholupdate(R,x)
R1 = cholupdate(R,x,'+')
R1 = cholupdate(R,x,'-')
[R1,p] = cholupdate(R,x,'-')
Description
R1 = cholupdate(R,x)
whereR = chol(A)
is the original Cholesky factorization ofA
, returns the upper triangular Cholesky factor ofA + x*x'
, wherex
is a column vector of appropriate length.cholupdate
uses only the diagonal and upper triangle ofR
. The lower triangle ofR
is ignored.
R1 = cholupdate(R,x,'+')
is the same asR1 = cholupdate(R,x)
.
R1 = cholupdate(R,x,'-')
returns the Cholesky factor ofA - x*x'
. An error message reports when R is not a valid Cholesky factor or when the downdated matrix is not positive definite and so does not have a Cholesky factorization.
[R1,p] = cholupdate(R,x,'-')
will not return an error message. Ifp
is0
,R1
is the Cholesky factor ofA - x*x'
. Ifp
is greater than0
,R1
is the Cholesky factor of the originalA
. Ifp
is1
,cholupdate
failed because the downdated matrix is not positive definite. Ifp
is2
,cholupdate
失败了,因为上面的三角形R
was not a valid Cholesky factor.
Examples
A = pascal(4) A = 1 1 1 1 1 2 3 4 1 3 6 10 1 4 10 20 R = chol(A) R = 1 1 1 1 0 1 2 3 0 0 1 3 0 0 0 1 x = [0 0 0 1]';
This is called a rank one update toA
sincerank(x*x')
is1
:
A + x*x' ans =
1 1 1 1 1 2 3 4 1 3 6 10 1 4 10 21
Instead of computing the Cholesky factor withR1 = chol(A + x*x')
, we can usecholupdate
:
R1 = cholupdate(R,x) R1 =
1.0000 1.0000 1.0000 1.0000 0 1.0000 2.0000 3.0000 0 0 1.0000 3.0000 0 0 0 1.4142
Next destroy the positive definiteness (and actually make the matrix singular) by subtracting1
from the last element ofA
. The downdated matrix is:
A - x*x' ans = 1 1 1 1 1 2 3 4 1 3 6 10 1 4 10 19
Comparechol
withcholupdate
:
R1 = chol(A-x*x') Error using chol Matrix must be positive definite. R1 = cholupdate(R,x,'-') Error using cholupdate Downdated matrix must be positive definite.
However, subtracting0.5
from the last element ofA
produces a positive definite matrix, and we can usecholupdate
to compute its Cholesky factor:
x = [0 0 0 1/sqrt(2)]'; R1 = cholupdate(R,x,'-') R1 = 1.0000 1.0000 1.0000 1.0000 0 1.0000 2.0000 3.0000 0 0 1.0000 3.0000 0 0 0 0.7071
Tips
cholupdate
works only for full matrices.