Skip to content

Commit

Permalink
check if smallest eigenvalue is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
haifengl committed Jul 22, 2020
1 parent a1580b1 commit 1826b2f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/src/main/java/smile/manifold/LLE.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,14 @@ public static LLE of(double[][] data, int k, int d) {
Matrix.EVD eigen = ARPACK.syev(new M(Wt), ARPACK.SymmOption.SM, Math.min(10*(d+1), n-1));

Matrix V = eigen.Vr;
// Sometimes, ARPACK doesn't compute the smallest eigenvalue (i.e. 0).
// Maybe due to numeric stability.
int offset = eigen.wr[eigen.wr.length - 1] < 1E-12 ? 2 : 1;
//System.out.println(Arrays.toString(eigen.wr));
//System.out.println(V.toString(10, V.nrows()-1));
double[][] coordinates = new double[n][d];
for (int j = d; --j >= 0; ) {
int c = V.ncols() - j - 2;
int c = V.ncols() - j - offset;
for (int i = 0; i < n; i++) {
coordinates[i][j] = V.get(i, c);
}
Expand Down

0 comments on commit 1826b2f

Please sign in to comment.