Error using chol Matrix must be positive definite.

조회 수: 39 (최근 30일)
Francois
Francois 2014년 6월 16일
댓글: Junho Kweon 2023년 2월 22일
I have a positive definite matrix C for which R=chol(C) works well. I want to apply the chol function to a new matrix A = U*C*U' where U is a unitary matrix obtained as output from SVD, i.e. from [V,S,U] = dvd(T); but I get an error telling me that A is not positive definite. I checked that det(U) = 1.0 so I don't understand why the symmetric matrix A is not positive definite.
Given that C is positive definite then y'*C*y>0 and if I let y = U'*x then x'*U*C*U'*x>0 which implies that U*C*U'is also positive definite.
Is this problem due to round off or am I missing some important linear algebra concept. If not is there a way around this problem?
  댓글 수: 8
John D'Errico
John D'Errico 2016년 6월 18일
The most common reason for this is NOT the difference in code, which should not be, but how you pass the array between. Too often people think they can pass an ascii file between the two machines, that this is sufficient.
Unless the array is passed EXACTLY between machines as a .mat file, you are NOT making a proper comparison. Without use of a .mat file, there will be tiny errors in the least significant bits.
Zhiyong Niu
Zhiyong Niu 2017년 11월 10일
편집: Zhiyong Niu 2017년 11월 10일
The diagnal of a positive definite matrix is real. However, if you obtain A by A = U*C*U' ,the diagnal of A may have imagenary parts, even though they are extremely tiny, on the order of 1e-17i. if so, the chol() may give you an error when the elements of diagnal was checked.

댓글을 달려면 로그인하십시오.

채택된 답변

John D'Errico
John D'Errico 2014년 6월 17일
One solution is to use my nearestSPD code as found on the file exchange. It handles the semi-definite matrix, finding the smallest perturbation into a positive definite matrix, one that will be ASSUREDLY factorizable using chol.
  댓글 수: 1
Junho Kweon
Junho Kweon 2023년 2월 22일
I totally agree with this. Due to the limitation of the computation in MATLAB, sometimes minor computational error cause sight asymmetric or slightly-not-positive-definite matrix. I had same issue with @Francois, but the code as @John D'Errico showed solved this problem very well.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Youssef  Khmou
Youssef Khmou 2014년 6월 16일
this an interesting problem,
Generally, the matrix C must contain some negative and positive eigenvalues ( eig(C)) according the description, in the other hand, the matrix A is positive semi definite only if C is diagonal matrix with the diagonal elements being the eigenvalues corresponding the eigenvectors U(:,1),....U(:,N).
In this case you multiply C whether diagonal or not with non corresponding eigenvectors, so A can not be positive semi definite .
  댓글 수: 1
Matt J
Matt J 2014년 6월 17일
편집: Matt J 2014년 6월 17일
A is positive semi definite only if C is diagonal matrix with the diagonal elements being the eigenvalues corresponding the eigenvectors U(:,1),....U(:,N).
Not true. Suppose U=eye(N). Then A=C and both are positive (semi) definite simultaneously, regardless of whether C is diagonal.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by