MaxIterationsExceededException in SVD (EigenDecompositionImpl.findEigenVectors
) caused by NaN
----------------------------------------------------------------------------------------------
Key: MATH-383
URL: https://issues.apache.org/jira/browse/MATH-383
Project: Commons Math
Issue Type: Bug
Affects Versions: 2.1
Environment: Java 6
Reporter: Alexander Kushkuley
In the following code fragment from EigenDecompositionImpl.findEigenVectors
....................................................................
for (int j = 0; j < n; j++) {
int its = 0;
int m;
do {
for (m = j; m < n - 1; m++) {
double delta = Math.abs(realEigenvalues[m]) +
Math.abs(realEigenvalues[m + 1]);
if (Math.abs(e[m]) + delta == delta) {
break;
}
}
if (m != j) {
.........................................
the test for "(Math.abs(e[m]) + delta == delta)" is not executed when m is
equal to n -1.
As a result e[m] == 0 (does happen!) causes variables q and
realEigenvalues[m] to become NaN that in turn causes "Math.abs(e[m]) + delta
== delta)" to become always false.
My guess (seems to work) is that another test for e[m] == 0 is needed, so that
the code becomes
for (int j = 0; j < n; j++) {
int its = 0;
int m;
do {
for (m = j; m < n - 1; m++) {
double delta = Math.abs(realEigenvalues[m]) +
Math.abs(realEigenvalues[m + 1]);
if (Math.abs(e[m]) + delta == delta) {
break;
}
}
// begin patch
if ( m == n - 1 && e[m-1] == 0 )
break;
// end patch
if (m != j) {
.........................................
or something like that
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.