You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Phil Steitz (JIRA)" <ji...@apache.org> on 2010/07/26 12:13:50 UTC
[jira] Updated: (MATH-383) MaxIterationsExceededException in SVD
(EigenDecompositionImpl.findEigenVectors ) caused by NaN
[ https://issues.apache.org/jira/browse/MATH-383?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Phil Steitz updated MATH-383:
-----------------------------
Fix Version/s: 2.2
Description:
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
was:
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
Thanks for reporting this.
> 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
> Fix For: 2.2
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> 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.