Thread: [Mplapack-devel] possibly a bug in Cheev
Status: Pre-Alpha
Brought to you by:
nakatamaho
From: Akira S. <aki...@ni...> - 2012-07-26 10:21:31
|
Dear Dr. Maho NAKATA, I am a postdoc working on quantum information and the matrices I have to handle are quite often Hermitian matrices with some eigenvalues degenerate or close to each other. I am trying several libraries as well as writing my own library for matrix calculations required in my research. I would like to report some issue as I think this is possibly a bug of MPACK. Or, it might be a problem in my code or the environment. I tried Cheev of MPACK with GMP but could not get correct results for some simple matrices. For example, it does not diagonalize the 3 x 3 matrix 1 0 1 0 0 0 1 0 1 and gives me "#Rlaev2 Checkpoint 13 Not checked". It works fine for diag(1,0,0) and a matrix filled with 1's among others. I am using mpack-0.7.0 on Fedora 15 where GMP 4.3.2 exists. Thanks for your attentions. Regards, Akira SAITOH, NII, Japan =========================================== [saitoh@localhost test_cheev]$ g++ test.cpp -L/usr/local/lib -lmlapack_gmp -lmblas_gmp -lmblas_gmp_ref -lmlapack_gmp_ref -lgmp -lmpfr -lgmpxx -lgomp -g /usr/bin/ld: warning: libgmp.so.3, needed by /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../lib64/libmpfr.so, may conflict with libgmp.so.10 [saitoh@localhost test_cheev]$ LD_LIBRARY_PATH=/usr/local/lib ./a.out 1 0 1 0 0 0 1 0 1 A = 1 0 1 0 0 0 1 0 1 #Rlaev2 Checkpoint 13 Not checked [saitoh@localhost test_cheev]$ LD_LIBRARY_PATH=/usr/local/lib ./a.out 1 0 0 0 0 0 0 0 0 A = 1 0 0 0 0 0 0 0 0 Eigenvalues: 0 0 1 Unitary matrix: 0+i*0 0+i*0 1+i*0 1+i*0 0+i*0 0+i*0 0+i*0 1+i*0 0+i*0 =========================================== test.cpp: =========================================== #include <gmpxx.h> #include <mpack/mpack_config.h> #include <mpack/mpc_class.h> #include <mpack/mlapack_gmp.h> #include <cstdlib> #include <iostream> int main (int argc, char* argv[]) { mpf_set_default_prec(512); mpackint n = 3; mpc_class *A = new mpc_class [n * n]; mpackint lda = n; mpf_class *w = new mpf_class [n]; mpc_class *work = new mpc_class [2 * n - 1]; mpackint lwork = 2 * n - 1; mpf_class *rwork = new mpf_class [3 * n - 2]; mpackint info; for (int i = 1; i < argc && i < n * n + 1; i++) A[i-1] = ::atof(argv[i]); std::cout << "A = " << std::endl; for (int i = 0; i < n; i ++) { for (int j = 0; j < n; j++) std::cout << A[i + n * j].real().get_d() << " "; std::cout << std::endl; } Cheev ("V", "U", n, A, lda, w, work, lwork, rwork, &info); std::cout << "Eigenvalues: " << std::endl; for (int i = 0; i < n; i++) std::cout << w[i].get_d() << " "; std::cout << std::endl; std::cout << "Unitary matrix:" << std::endl; for (int i = 0; i < n; i ++) { for (int j = 0; j < n; j++) std::cout << A[i + n * j].real().get_d() << "+i*" << A[i + n * j].imag().get_d() << " "; std::cout << std::endl; } delete [] A, w, work, rwork; return 0; } =========================================== |
From: Maho N. <ch...@ma...> - 2012-07-27 06:19:07
|
Dear Saitoh-san Thanks for your e-mail. I'll investigate... -- Nakata Maho http://accc.riken.jp/maho/ , JA OOO http://ja.openoffice.org/ http://blog.goo.ne.jp/nakatamaho/ ,GPG: http://accc.riken.jp/maho/maho.pgp.txt |
From: Maho N. <ch...@ma...> - 2012-08-09 01:23:13
|
Akira SaiTohさま すいません、遅くなって。 まだ解決してませんでしょうか。 singularじゃなさそうな行列を適当に入れてみたら 如何でしょうか。 thanks |
From: Akira S. <aki...@ni...> - 2012-08-09 05:25:43
|
Dear Nakata-san, Thanks for your suggestion. Indeed, the matrix in the previous email was a singular matrix. But sometimes Cheev fails to find eigenvalues also for a small non-singular Hermitian matrix. A typical example is 2 0 1 0 2 0 1 0 2 Its eigenvalues are 1, 2, and 3. For this matrix, Cheev stops together with the message "#Rlaev2 Checkpoint 13 Not checked" as is similar to the previous example. I am not sure if this phenomenon is dependent on a system environment. Could somebody test Cheev with the above matrix? Thank you for your attentions. Regards, Akira SaiToh 2012-08-09 10:22 Maho NAKATA wrote: > Akira SaiTohさま > > すいません、遅くなって。 > まだ解決してませんでしょうか。 > > singularじゃなさそうな行列を適当に入れてみたら > 如何でしょうか。 > thanks |
From: Maho N. <ma...@ri...> - 2012-08-09 09:43:56
|
Hi Saitoh-san Please apply following patch. $ diff -u mlapack/reference/Rlaev2.cpp~ mlapack/reference/Rlaev2.cpp --- Rlaev2.cpp~ 2012-08-09 14:56:17.156927491 +0900 +++ Rlaev2.cpp 2012-08-09 18:37:00.635038092 +0900 @@ -142,8 +142,6 @@ *cs1 = one; *sn1 = zero; } else { - printf("#Rlaev2 Checkpoint 13 Not checked\n"); - exit(1); tn = -cs / tb; *cs1 = one / sqrt(one + tn * tn); *sn1 = tn * (*cs1); This should work. Thanks Nakata Maho From: Akira SaiToh <aki...@ni...> Subject: Re: [Mplapack-devel] possibly a bug in Cheev Date: Thu, 09 Aug 2012 14:25:35 +0900 > Dear Nakata-san, > > Thanks for your suggestion. > Indeed, the matrix in the previous email was a singular matrix. > But sometimes Cheev fails to find eigenvalues also for a small > non-singular Hermitian matrix. A typical example is > > 2 0 1 > 0 2 0 > 1 0 2 > > Its eigenvalues are 1, 2, and 3. For this matrix, Cheev stops > together with the message "#Rlaev2 Checkpoint 13 Not checked" > as is similar to the previous example. > > I am not sure if this phenomenon is dependent on a system > environment. Could somebody test Cheev with the above matrix? > > Thank you for your attentions. > Regards, > Akira SaiToh > > 2012-08-09 10:22 Maho NAKATA wrote: >> Akira SaiTohさま >> >> すいません、遅くなって。 >> まだ解決してませんでしょうか。 >> >> singularじゃなさそうな行列を適当に入れてみたら >> 如何でしょうか。 >> thanks > |
From: Akira S. <aki...@ni...> - 2012-08-10 16:25:37
|
Hello, Nakata-san, Thank you for your effort. With your patch, I could get correct eigenvalues for the previous examples. However, I encountered another problem. For the matrix 2 0 1 0 2 0 1 0 2 Cheev returns correct eigenvalues, 1, 2, and 3. Then, for the matrix 20 0 10 0 20 0 10 0 20 expected eigenvalues are 10, 20, and 30. However, Cheev returns 20, 20, and 20. I guess probably Cheev should be modified so that an appropriate scaling is internally performed. ------------------------------------------------------- [saitoh@localhost test_cheev]$ LD_LIBRARY_PATH=/usr/local/lib ./a.out 2 0 1 0 2 0 1 0 2 A = 2 0 1 0 2 0 1 0 2 Eigenvalues: 1 2 3 Unitary matrix: 0.707107+i*0 0+i*0 0.707107+i*0 0+i*0 -1+i*0 0+i*0 -0.707107+i*0 0+i*0 0.707107+i*0 [saitoh@localhost test_cheev]$ LD_LIBRARY_PATH=/usr/local/lib ./a.out 20 0 10 0 20 0 10 0 20 A = 20 0 10 0 20 0 10 0 20 Eigenvalues: 20 20 20 Unitary matrix: -1+i*0 4.85181e-173+i*0 0+i*0 0+i*0 -1+i*0 0+i*0 0+i*0 0+i*0 1+i*0 ------------------------------------------------------- Regards, Akira SaiToh |
From: Maho N. <ch...@ma...> - 2012-08-10 22:43:27
|
Hello From: Akira SaiToh <aki...@ni...> Subject: Re: [Mplapack-devel] possibly a bug in Cheev Date: Sat, 11 Aug 2012 01:25:28 +0900 > Hello, Nakata-san, > > Thank you for your effort. With your patch, I could get > correct eigenvalues for the previous examples. However, I Congratulations! > encountered another problem. Ah :-( I'm sorry to hear that. > For the matrix > > 2 0 1 > 0 2 0 > 1 0 2 > > Cheev returns correct eigenvalues, 1, 2, and 3. Then, for > the matrix > > 20 0 10 > 0 20 0 > 10 0 20 > > expected eigenvalues are 10, 20, and 30. However, Cheev > returns 20, 20, and 20. I guess probably Cheev should be > modified so that an appropriate scaling is internally > performed. Yes, many thanks for your bug report. I'll fix hopefully soon. Thanks Nakata Maho > ------------------------------------------------------- > [saitoh@localhost test_cheev]$ LD_LIBRARY_PATH=/usr/local/lib ./a.out > 2 0 1 0 2 0 1 0 2 > A = > 2 0 1 > 0 2 0 > 1 0 2 > Eigenvalues: > 1 2 3 > Unitary matrix: > 0.707107+i*0 0+i*0 0.707107+i*0 > 0+i*0 -1+i*0 0+i*0 > -0.707107+i*0 0+i*0 0.707107+i*0 > [saitoh@localhost test_cheev]$ LD_LIBRARY_PATH=/usr/local/lib ./a.out > 20 0 10 0 20 0 10 0 20 > A = > 20 0 10 > 0 20 0 > 10 0 20 > Eigenvalues: > 20 20 20 > Unitary matrix: > -1+i*0 4.85181e-173+i*0 0+i*0 > 0+i*0 -1+i*0 0+i*0 > 0+i*0 0+i*0 1+i*0 > ------------------------------------------------------- > > Regards, > Akira SaiToh > |
From: Maho N. <ma...@ri...> - 2012-08-09 07:05:20
|
Hi Sorry for being late. > I tried Cheev of MPACK with GMP but could not get correct results > for some simple matrices. For example, it does not diagonalize the > 3 x 3 matrix > > 1 0 1 > 0 0 0 > 1 0 1 > > and gives me "#Rlaev2 Checkpoint 13 Not checked". It works fine > for diag(1,0,0) and a matrix filled with 1's among others. I have just reproduced your result! Thanks Nakata Maho From: Akira SaiToh <aki...@ni...> Subject: [Mplapack-devel] possibly a bug in Cheev Date: Thu, 26 Jul 2012 19:05:41 +0900 > Dear Dr. Maho NAKATA, > > I am a postdoc working on quantum information and the matrices > I have to handle are quite often Hermitian matrices with some > eigenvalues degenerate or close to each other. I am trying several > libraries as well as writing my own library for matrix calculations > required in my research. > > I would like to report some issue as I think this is possibly a > bug of MPACK. Or, it might be a problem in my code or the environment. > > I tried Cheev of MPACK with GMP but could not get correct results > for some simple matrices. For example, it does not diagonalize the > 3 x 3 matrix > > 1 0 1 > 0 0 0 > 1 0 1 > > and gives me "#Rlaev2 Checkpoint 13 Not checked". It works fine > for diag(1,0,0) and a matrix filled with 1's among others. > > I am using mpack-0.7.0 on Fedora 15 where GMP 4.3.2 exists. > > Thanks for your attentions. > Regards, > Akira SAITOH, NII, Japan > > =========================================== > [saitoh@localhost test_cheev]$ g++ test.cpp -L/usr/local/lib > -lmlapack_gmp -lmblas_gmp -lmblas_gmp_ref -lmlapack_gmp_ref -lgmp -lmpfr > -lgmpxx -lgomp -g > /usr/bin/ld: warning: libgmp.so.3, needed by > /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../lib64/libmpfr.so, may > conflict with libgmp.so.10 > [saitoh@localhost test_cheev]$ LD_LIBRARY_PATH=/usr/local/lib ./a.out 1 > 0 1 0 0 0 1 0 1 > A = > 1 0 1 > 0 0 0 > 1 0 1 > #Rlaev2 Checkpoint 13 Not checked > [saitoh@localhost test_cheev]$ LD_LIBRARY_PATH=/usr/local/lib ./a.out 1 > 0 0 0 0 0 0 0 0 > A = > 1 0 0 > 0 0 0 > 0 0 0 > Eigenvalues: > 0 0 1 > Unitary matrix: > 0+i*0 0+i*0 1+i*0 > 1+i*0 0+i*0 0+i*0 > 0+i*0 1+i*0 0+i*0 > =========================================== > > test.cpp: > > =========================================== > #include <gmpxx.h> > #include <mpack/mpack_config.h> > #include <mpack/mpc_class.h> > #include <mpack/mlapack_gmp.h> > #include <cstdlib> > #include <iostream> > int main (int argc, char* argv[]) > { > mpf_set_default_prec(512); > mpackint n = 3; > mpc_class *A = new mpc_class [n * n]; > mpackint lda = n; > mpf_class *w = new mpf_class [n]; > mpc_class *work = new mpc_class [2 * n - 1]; > mpackint lwork = 2 * n - 1; > mpf_class *rwork = new mpf_class [3 * n - 2]; > mpackint info; > > for (int i = 1; i < argc && i < n * n + 1; i++) > A[i-1] = ::atof(argv[i]); > > std::cout << "A = " << std::endl; > for (int i = 0; i < n; i ++) > { > for (int j = 0; j < n; j++) > std::cout << A[i + n * j].real().get_d() << " "; > std::cout << std::endl; > } > > Cheev ("V", "U", n, A, lda, w, work, lwork, rwork, &info); > > std::cout << "Eigenvalues: " << std::endl; > for (int i = 0; i < n; i++) > std::cout << w[i].get_d() << " "; > std::cout << std::endl; > > std::cout << "Unitary matrix:" << std::endl; > for (int i = 0; i < n; i ++) > { > for (int j = 0; j < n; j++) > std::cout << A[i + n * j].real().get_d() << "+i*" > << A[i + n * j].imag().get_d() << " "; > std::cout << std::endl; > } > > delete [] A, w, work, rwork; > return 0; > } > =========================================== > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Mplapack-devel mailing list > Mpl...@li... > https://lists.sourceforge.net/lists/listinfo/mplapack-devel > |
From: Maho N. <ch...@ma...> - 2012-08-09 11:30:43
|
Hi Saitoh-san After patching, my result now seems to be correct: $ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/maho/MPACK//lib ./test 1 0 1 0 0 0 1 0 1 A = 1 0 1 0 0 0 1 0 1 Eigenvalues: 0 0 2 Unitary matrix: 0+i*0 0.707107+i*0 0.707107+i*0 -1+i*0 0+i*0 0+i*0 0+i*0 -0.707107+i*0 0.707107+i*0 . Thanks Nakata Maho From: Akira SaiToh <aki...@ni...> Subject: Re: [Mplapack-devel] possibly a bug in Cheev Date: Thu, 09 Aug 2012 14:25:35 +0900 > Dear Nakata-san, > > Thanks for your suggestion. > Indeed, the matrix in the previous email was a singular matrix. > But sometimes Cheev fails to find eigenvalues also for a small > non-singular Hermitian matrix. A typical example is > > 2 0 1 > 0 2 0 > 1 0 2 > > Its eigenvalues are 1, 2, and 3. For this matrix, Cheev stops > together with the message "#Rlaev2 Checkpoint 13 Not checked" > as is similar to the previous example. > > I am not sure if this phenomenon is dependent on a system > environment. Could somebody test Cheev with the above matrix? > > Thank you for your attentions. > Regards, > Akira SaiToh > > 2012-08-09 10:22 Maho NAKATA wrote: >> Akira SaiTohさま >> >> すいません、遅くなって。 >> まだ解決してませんでしょうか。 >> >> singularじゃなさそうな行列を適当に入れてみたら >> 如何でしょうか。 >> thanks > |