Problem with "magma_zhegvx" function

Open discussion for MAGMA

Problem with "magma_zhegvx" function

Postby Edu_Cepas » Mon Mar 12, 2012 8:43 am

Hi!!

I'm trying to use "magma_zhegvx" with a simple example, but I always get the same error, described in the documentation:

http://icl.cs.utk.edu/magma/docs/zhegvx_8cpp.html

INFO (output) INTEGER
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
> 0: ZPOTRF or ZHEEVX returned an error code:
<= N: if INFO = i, ZHEEVX failed to converge;
i eigenvectors failed to converge. Their indices
are stored in array IFAIL.
> N: if INFO = N + i, for 1 <= i <= N, then the leading
minor of order i of B is not positive definite.

The factorization of B could not be completed and
no eigenvalues or eigenvectors were computed.

I'm getting INFO = 6, and my N =3, so i = 3. I really don't understand well the meaning of this error. Specifically, the phrase: "then the leading minor of order i of B is not positive definite". Would you mind explaining me this error and what does the value i=3 mean in more detail??

I'm using the following input:

itype=1; // specifies A*x = lambda*B*x
jobz='V'; // Compute eigenvalues and eigenvectors
uplo='U'; // Upper triangle of A is stored
range='I'; // 'I': the IL-th through IU-th eigenvalues will be found.
N = 3 ; // 3x3 matrix
lda = ldb = 3;
// A
cuDoubleComplex h_A[] = {{1.0,0.0}, {2.0,0.0}, {3.0,0.0},
{3.0,0.0}, {6.0,0.0}, {8.0,0.0},
{5.0,0.0}, {9.0,0.0}, {2.0,0.0}};
// B
cuDoubleComplex h_B[] = {{3.0,0.0}, {5.0,0.0}, {7.0,0.0},
{1.0,0.0}, {7.0,0.0}, {9.0,0.0},
{4.0,0.0}, {6.0,0.0}, {2.0,0.0}};
vl = vu = 0.0;
il = 1;
iu = 1..N

// Z
cuDoubleComplex h_Z[size*size];
ldz = 3 ;

The others parameters are outputs. Have I set some input parameter wrong?
Any idea of what am I doing wrong¿?

Thank you so much in advance.
Edu_Cepas
 
Posts: 4
Joined: Fri Feb 10, 2012 6:43 am

Re: Problem with "magma_zhegvx" function

Postby mgates3 » Tue Mar 13, 2012 10:31 am

I'm confused by your matrices. You have the following matrices (note Magma is column-wise):

A =
[ 1, 3, 5 ]
[ 2, 6, 9 ]
[ 3, 8, 2 ]

B =
[ 3, 1, 4 ]
[ 5, 7, 6 ]
[ 7, 9, 2 ]

The first question is, if your numbers are actually all real, why are you specifying them as complex?
The second question is, the A and B you show are not symmetric; why? Since you are calling a symmetric (Hermitian) routine with uplo=U, MAGMA will ignore the lower triangle. So MAGMA thinks the matrices are:

A =
[ 1, 3, 5 ]
[ 3, 6, 9 ]
[ 5, 9, 2 ]

B =
[ 3, 1, 4 ]
[ 1, 7, 6 ]
[ 4, 6, 2 ]

The error you get is because that B matrix is not positive definite, as you can check in Matlab or Python by trying to take its Cholesky factorization. Recall from your linear algebra class that (symmetric or Hermitian) positive definite means x^T B x > 0 for all non-zero x. Practically, this means that while doing a Cholesky factorization, it encountered the square root of a negative number on the diagonal. In your case, when factoring the 3rd column. Here's a B that is positive definite and should work:

[ 3, 1, 4 ]
[ 1, 7, 6 ]
[ 4, 6, 9 ]

The only difference being a larger B(3,3) entry.

-mark
mgates3
 
Posts: 438
Joined: Fri Jan 06, 2012 2:13 pm

Re: Problem with "magma_zhegvx" function

Postby Edu_Cepas » Wed Mar 14, 2012 6:43 am

Hi Mark, and thanks for your accurate and fast answer!

--Respecting to your second question, yes, the matrices I was using were wrong since they weren't symmetric... I was looking for sample matrices for the "generalized eigenvalue problem" and I found them somewhere... I hadn't realized that the matrices were column-wise either, thank you. Your sample works wonders!

--Regarding to your first question, I have a code wich use the DSPGVX LAPACK function, and I would like to move my code to a GPU (specifically a nVidia CUDA GPU). I wasn't sure which was the equivalent function in MAMGA, so I asked in the LAPACK FORUM:

http://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=14&t=3117

and as you can see:

"We have the routine in MAGMA 1.1 but only in complex arithmetic
http://icl.cs.utk.edu/magma/docs/zhegvx_8cpp.html
Double can be easily derived from it and will be added in the next release."

, they tell me that I should use MAGMA "zhegvx" function. That's the reason why I'm specifying real numbers as complex.
Do you think I'm using the wrong function¿?
Do you know any other MAGMA function more suitable for that case?

Thank you so much again in advance,
EDU.


--
Edu_Cepas
 
Posts: 4
Joined: Fri Feb 10, 2012 6:43 am

Re: Problem with "magma_zhegvx" function

Postby mgates3 » Wed May 02, 2012 3:31 pm

No, that's the correct function to use. I didn't realize that function had only the complex version.
-mark
mgates3
 
Posts: 438
Joined: Fri Jan 06, 2012 2:13 pm


Return to User discussion

Who is online

Users browsing this forum: No registered users and 6 guests