Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

why does my cholesky decomposition fail?

hagai_sela
Beginner
971 Views
I wrote this piece of C code:

double Matrix[] =
{
1, -1,
-1, 1
};

int nInfo;
char chUpper = 'U';
int nSize = 2;
dpotrf(
&chUpper,
&nSize,
Matrix,
&nSize,
&nInfo);

As far as my limited math understanding goes, my matrix is positive semidefinite, but nInfo is 2... Am I doing anything wrong?

Hagai.
0 Kudos
3 Replies
Melvin_Robinson
New Contributor I
971 Views
Quoting - hagai_sela
I wrote this piece of C code:

double Matrix[] =
{
1, -1,
-1, 1
};

int nInfo;
char chUpper = 'U';
int nSize = 2;
dpotrf(
&chUpper,
&nSize,
Matrix,
&nSize,
&nInfo);

As far as my limited math understanding goes, my matrix is positive semidefinite, but nInfo is 2... Am I doing anything wrong?

Hagai.

Your matrix is not positive definite which is why nInfo returns a value greater than zero. Here is the return information from LAPACK:
INFO (output) INTEGER
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
> 0: if INFO = i, the leading minor of order i is not
positive definite, and the factorization could not be
completed.

I tried this with [2 1;1 2] and it worked fine.

0 Kudos
hagai_sela
Beginner
971 Views
it's not positive definite, but it is semi-positive definite. Isn't that enough?

Hagai.
0 Kudos
Melvin_Robinson
New Contributor I
971 Views
Quoting - hagai_sela
it's not positive definite, but it is semi-positive definite. Isn't that enough?

Hagai.
The documention of the call assumes positive definite matrices. This likely explains some of the trouble. http://www.netlib.org/lapack/double/dpotrf.f
0 Kudos
Reply