glk63
12-06-2011, 04:43 PM
Apparently there is an error in code hqr2
Look at the code fragment:
...
if (anorm! = 0.0) {
for (nn = n-1; nn> = 0; nn --) {
p = real (wri [nn]);
q = imag (wri [nn]);
na = nn-1;
...
If nn = 0, the value na =- 1, but then:
...
} Else if (q <0.0) {
m = na;
if (abs (a [nn] [na])> abs (a [na] [nn])) {
a [na] [na] = q / a [nn] [na];
...
Thus, when nn = 0 there is a reference to a [0] [-1]. For example, when calculating the eigenvalues and eigenvectors of the matrix:
A = {{7,1,2}, {2,3,1}, {-8, -2, -1}} an incorrect addressing error occurs in hqr2 code.
Look at the code fragment:
...
if (anorm! = 0.0) {
for (nn = n-1; nn> = 0; nn --) {
p = real (wri [nn]);
q = imag (wri [nn]);
na = nn-1;
...
If nn = 0, the value na =- 1, but then:
...
} Else if (q <0.0) {
m = na;
if (abs (a [nn] [na])> abs (a [na] [nn])) {
a [na] [na] = q / a [nn] [na];
...
Thus, when nn = 0 there is a reference to a [0] [-1]. For example, when calculating the eigenvalues and eigenvectors of the matrix:
A = {{7,1,2}, {2,3,1}, {-8, -2, -1}} an incorrect addressing error occurs in hqr2 code.