[Lapackpp-devel] Re: LaEigSolveVecIP (was: Complex Matrix Support)
Status: Beta
Brought to you by:
cstim
From: Christian S. <sti...@tu...> - 2006-05-08 07:56:10
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear Andrew, thanks for this detailed bug report. Indeed the output of the LaEigSolveVecIP function is not what we would expect. However, the documentation of that function immediately explains what is going on: http://lapackpp.sourceforge.net/html/laslv_8h.html#a16 and the laslv.h header file says: "This function calculates all eigenvalues and eigenvectors of a symmetric matrix A, not a general matrix A!", and since you passed a non-symmetric matrix into that function, it is clear that it won't calculate what you expected. Instead, you have to use the function LaEigSolve() and this will do what you expected. I've modified your test file so that you can see what is going on. The output of LaEigSolve() will fortunately match up with the MATLAB output again. The LaEigSolve() function will return potentially complex-valued eigenvalues, but this is perfectly correct for a general (non-symmetric) matrix. Only in your particular case all eigenvalues happened to be real-valued. As for the "Additionally, for each run, the values do not match each other" remark: This is also correct, because the function name suffix "IP" stands for "in-place" (and also the matrix argument is non-const) which means the given matrix M will be modified during calculation. This is useful if you don't need the matrix any longer, because then lapack internally doesn't have to allocate an extra copy of the matrix. If you don't want to have your original matrix modified, either use a non-"IP" version of that function (if it exists), or create a temporary copy and pass that one into the function (which is just what the non-IP functions will do for you). You can read the manual page of the underlying lapack function "dsyev" for more details by typing the command "man dsyev" (if the package "lapack-manpages" is installed). Thank you again for this detailed bug report. This made it very clear to me how to explain the problem here. I'm sorry if the documentation was not clear enough about this function. I should probably change the function name into something less ambiguous, like "LaEigSolveVeryMisleadingOnlyForSymmetricMatrixIP" :-) but I will try to improve the function documentation. Regards, Christian Stimming Andrew Oh schrieb: > Hey > > Attached is the C++ code and the M file I used. The C++ code has some > more detailed results in the commenting. > > The machine I ran this on is a SuSe 10.0 from Novell. This is what I > get when I type "uname -a" > > Linux mnp 2.6.13-15.8-smp #1 SMP Tue Feb 7 11:07:24 UTC 2006 i686 i686 > i386 GNU/Linux > > But the RPMs I installed for SuSe all had the i586 suffix on them. > > These are the versions of the relevant compilers/rpms: > > gcc-4.0.2_20050901-3 > gcc-fortran-4.0.2_20050901-3 > f2c-0.11-1052 > > When I compile test.cpp I type: > > g++ test.cpp -I/usr/include -I/usr/include/lapackpp -L/usr/lib -llapackpp > > and execute by typing "./a.out". > > The m-file is just two simple lines and you can see the results in > MATLAB and compare to the values printed out by test.cpp. Thanks for > your help. > > Andy > ------------------------------------------------------------------------ > > M = [1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16]; > eig(M) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.1 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iQCVAwUBRF76DGXAi+BfhivFAQLDFgP+Pk794zU4TTl2qKP4fgao8SPhr7p9jESj sac5X/Tc8okSt1l/oP4acisdp5J7pVmoUYPm0ygZTJO+U/xMLEcWlxRZ17FBlh/c ynYjT+lHq1KSAq2okBglQxL0L7ELQyzJ/zC9XqXbw/RJ73CpS6nN1cLbjDjcgML9 +GtUDp3gRRY= =Loys -----END PGP SIGNATURE----- |