about Cholesky factorization function pspotrf

Open discussion regarding features, bugs, issues, vendors, etc.

about Cholesky factorization function pspotrf

Postby PingFeng » Tue May 30, 2006 4:51 am

I compute Cholesky factorization of A with pspotrf function ,A is SPD,but I find the result is not correct. I make sure that the parameters all are correct. The A is
1 1 1 1 1 1
1 2 3 4 5 6
1 3 6 10 15 21
1 4 10 20 35 56
1 5 15 35 70 126
1 6 21 56 126 252
the reslut of using chol function in other mathmatic library is:
1 0 0 0 0 0
1 1 0 0 0 0
1 2 1 0 0 0
1 3 3 1 0 0
1 4 6 4 1 0
1 51010 5 1
but the result pspotrf is :
1 1 1 1 1 1
1 1 2 3 4 5
1 3 1 3 6 10
1 4 10 1 4 10
1 5 15 35 1 5
1 6 21 56 126 1
how can i use the result? the UPLO='l'
thanks!
PingFeng
 
Posts: 7
Joined: Tue Apr 18, 2006 9:32 pm

Postby sven » Tue May 30, 2006 6:12 am

I think that PSPOTRF has worked as advertised. I presume that you have set UPLO = 'U' and you can see that the Cholesky factor is returned in the upper triangular part of A. The strictly lower triangular part of A is not been altered.

If you set UPLO = 'L', then the Cholesky factor would be returned in the lower triangular part of A and the strictly upper triangular part would not be altered.

Best wishes,

Sven Hammarling.
sven
 
Posts: 146
Joined: Wed Dec 22, 2004 4:28 am

Postby PingFeng » Tue May 30, 2006 8:14 pm

Thank you!
what you said i have found in the result, but there is a little different. that is ,when i set UPLO = 'U',i found that the Cholesky factor is returned in the lower triangular . The strictly upper triangular part of A is not been altered. The same to the function PDPOTRI: the upper triangular part of A is not been altered--i ignore it. But the result PDPOTRI computed is not correct :the lower triangular factor is very different with matlab and other math tools.
PingFeng
 
Posts: 7
Joined: Tue Apr 18, 2006 9:32 pm

Postby PingFeng » Tue May 30, 2006 8:28 pm

I make a mistake,:). i should use the function PSTRTRI instead of PSPOTRI.
PingFeng
 
Posts: 7
Joined: Tue Apr 18, 2006 9:32 pm

Postby Julien Langou » Tue May 30, 2006 8:33 pm

Hello,
when i set UPLO = 'U',i found that the Cholesky factor is returned in the lower triangular

I just see one explanation: are you using row major or column major to store your matrices?
Default format in C for 2D arrays is row-major format.
LAPACK assumes column major. ScaLAPACK as well. This is the format that you get from Fortran.
If you provide a matrix in column-major format, ask LAPACK to work on the upper part, it will work on the upper part of your matrix and the lower part is unaltered (as Sven as said).
Now, sure, if you provide a matrix that you view in row format and ask LAPACK to work on the upper part, it will work on the lower part of the row-major matrix.

Glad that you get it right for your other problem,
Julien
Julien Langou
 
Posts: 834
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 4 guests