MATH-432 fixed

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@912413 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dimitri Pourbaix 2010-02-21 21:46:12 +00:00
parent ccf7732750
commit 05361c5a34
3 changed files with 34 additions and 3 deletions

View File

@ -479,6 +479,29 @@ public class EigenDecompositionImpl implements EigenDecomposition {
}
realEigenvalues[n - 1] = main[n - 1];
e[n - 1] = 0.0;
// Determine the largest main and secondary value in absolute term.
double maxAbsoluteValue=0.0;
for (int i = 0; i < n; i++) {
if (Math.abs(realEigenvalues[i])>maxAbsoluteValue) {
maxAbsoluteValue=Math.abs(realEigenvalues[i]);
}
if (Math.abs(e[i])>maxAbsoluteValue) {
maxAbsoluteValue=Math.abs(e[i]);
}
}
// Make null any main and secondary value too small to be significant
if (maxAbsoluteValue!=0.0) {
for (int i=0; i < n; i++) {
if (Math.abs(realEigenvalues[i])<=MathUtils.EPSILON*maxAbsoluteValue) {
realEigenvalues[i]=0.0;
}
if (Math.abs(e[i])<=MathUtils.EPSILON*maxAbsoluteValue) {
e[i]=0.0;
}
}
}
for (int j = 0; j < n; j++) {
int its = 0;
int m;
@ -568,7 +591,7 @@ public class EigenDecompositionImpl implements EigenDecomposition {
}
// Determine the largest eigen value in absolute term.
double maxAbsoluteValue=0.0;
maxAbsoluteValue=0.0;
for (int i = 0; i < n; i++) {
if (Math.abs(realEigenvalues[i])>maxAbsoluteValue) {
maxAbsoluteValue=Math.abs(realEigenvalues[i]);

View File

@ -88,11 +88,12 @@ public class SingularValueDecompositionImpl implements
// create A^T*A
//
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int j = i; j < n; j++) {
matATA[i][j] = 0.0;
for (int k = 0; k < m; k++) {
matATA[i][j] += localcopy[k][i] * localcopy[k][j];
}
matATA[j][i]=matATA[i][j];
}
}
@ -101,11 +102,12 @@ public class SingularValueDecompositionImpl implements
// create A*A^T
//
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
for (int j = i; j < m; j++) {
matAAT[i][j] = 0.0;
for (int k = 0; k < n; k++) {
matAAT[i][j] += localcopy[i][k] * localcopy[j][k];
}
matAAT[j][i]=matAAT[i][j];
}
}
int p;

View File

@ -39,6 +39,12 @@ The <action> type attribute can be add,update,fix,remove.
</properties>
<body>
<release version="2.1" date="TBD" description="TBD">
<action dev="dimpbx" type="fix" issue="MATH-342">
In SVD, the matrices passed to EigenDecomposition are now symmetric
by construction (rather than simply by definition). In EigenDecomposition,
once the tridiagonal form is obtained, the non-significant elements are
set to 0.
</action>
<action dev="dimpbx" type="fix" issue="MATH-333">
A EigenDecompositionImpl simplified makes it possible to compute
the SVD of a singular matrix (with the right number of elements in