First thank you for reporting the bug, and thank you even more for taking the
time to write a test case.
Your bug has been referenced as bug0096 and is listed in LAPACK 3.4.1 Errata
file : http://www.netlib.org/lapack/Errata/index2.html
You are completely right, the sorting is not done for N=2.
I followed your suggestion and corrected accordingly.
The bug fix is available in the LAPACK repository (revision 1307).
On Jun 26, 2012, at 11:41 AM, Joseph Young wrote:
There appears to be an inconsistency and possible bug in the dstemr
implementation. When calculating the eigenvalues of a matrix, the returned
eigenvalues are supposed to be returned in ascending order. Although this
appears to be the case for N >= 3, it does not appear to be the case for N=2.
I believe this happens because the dstemr routine has special cases for
N=0,1, and 2, which immediately return after their computation. Because
these cases return immediately, they do not call the sorting routines around
line 723 (in LAPACK version 3.4.1). As such, a simple fix would be to have
the N=2 case call this sorting code rather than returning. In any case, I'm
attaching two different C files that demonstrate this problem. The first is
test01.c, which calls the routine on a 2x2 matrix. It correctly calculates
the eigenvalues, but they are printed in the wrong order. The second is
test02.c, which calls the routine on a 3x3 matrix. It also correctly
calculates the eigenvalues and correctly returns the eigenvalues in ascending
order. For reference, these C files use C99, so you may need the compiler
flag -std=c99 if you compile with gcc. They demonstrate the problem when
linking both LAPACK versions 3.4.1 and 3.2.1.
If you've any questions or if there's a better place to file a bug report,
please let me know. Thanks.
Lapack mailing list