Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SortRule::SmallestMagn sometimes omits the last (near-zero) eigenvalues #129

Closed
LTLA opened this issue Oct 1, 2021 · 1 comment
Closed

Comments

@LTLA
Copy link

LTLA commented Oct 1, 2021

As a result of some of the issues with shift-and-invert mentioned in #126, I decided to use SortRule::SmallestMagn to get my smallest eigenvalues. However, it seems that - under certain conditions - the last eigenvalue is completely omitted from the output. In this case, the last eigenvalue is very close to zero, which probably contributes to its omission.

I have set up a reproducible example at https://github.com/LTLA/DebuggingSpectra using the debug2.* scripts. (Note the 2, not the 1 used in #126.) Again, I only use R to handle the boilerplate I/O in debug2.R, the real problem occurs in the C++ code in debug2.cpp. I compare the output of SortRule::SmallestMagn against shift-and-invert, and the output from debug2.R is:

  0.013475 # where's my last eigenvalue?
0.00652111
0.00390492

  0.00652111 # shift and invert gives me what I want
  0.00390492
-1.17311e-16

Some additional observations:

  • Turning down tol = 1e-12 or lower in SymEigsSolver::compute() is enough to recover the lost eigenvalue.
  • The eigenvalue is not lost when I do run_shift(test@x, test@i, test@p, order=nrow(test), 3) instead of 2.

Is this a known behavior? Incidentally, RSpectra has no problems with the same matrix in the same mode:

library(RSpectra)
eigs_sym(test, k=3, which="SM")$value
## [1] 6.521110e-03 3.904921e-03 9.011210e-16
@yixuan
Copy link
Owner

yixuan commented Apr 6, 2022

I suppose a better scheme was already proposed in #126, so let me close this one.

@yixuan yixuan closed this as completed Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants