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

eigs problem #8

Closed
xshi19 opened this issue Jun 24, 2015 · 3 comments
Closed

eigs problem #8

xshi19 opened this issue Jun 24, 2015 · 3 comments

Comments

@xshi19
Copy link

@xshi19 xshi19 commented Jun 24, 2015

Hi Yixuan,

I find a problem with eigs(). I generate a simple Hankel matrix H and define a function myfun() which returns H%*%x. eigs() works well if the first argument is H. But when the first argument becomes myfun() it produces following error:

Warning message:
In eigs.fun(A, k, which, sigma, opts, ..., mattype = "function", :
no converged eigenvalues found

The problem can be solved by setting retvec = FALSE or ncv = nrow(H), but it would be extremely slow if the dimension is high.

Thanks!

Here is my code:

library('rARPACK')
library('igraph')

myfun <- function(x, H) {
return(H %*% x)
}

hankel <- function(x, y = NULL) {

Generate Hankel matrix using outer product

m = length(x)
if (is.null(y)) {
y = rep(0, m)
}
n = length(y)
h = c(x, y[2:n])
H = outer(1:m, 1:n, function(u, v) h[u + v - 1])
return(H)
}

n = 100
h = 1 / sqrt(1:n)
H = hankel(h)
ord = 10

r1 = eigs(H, k = ord)
r2 = arpack(myfun, extra = H, sym = TRUE, options = list(n = n, nev = ord, ncv = 20))
r3 = eigs(myfun, k = ord, n = length(h), args = H)

@yixuan
Copy link
Owner

@yixuan yixuan commented Jun 27, 2015

Thanks @xshi19 , I'll look into this problem shortly.

@yixuan
Copy link
Owner

@yixuan yixuan commented Jul 3, 2015

This seems to be a known problem that retvec = TRUE and retvec = FALSE can give different results. It is somewhat related to the ARPACK library, and should be fixed either by updating ARPACK included in the source, or using a rewritten C++ version that I'm working on.
I would try to fix it in the next version of rARPACK. Thanks for your report.

@yixuan
Copy link
Owner

@yixuan yixuan commented Aug 15, 2015

Hi @xshi19
This issue has been resolved in the development version of rARPACK. I added a symmetric argument in eigs.function() to force using a symmetric eigen solver.

## This will correctly return complex-typed eigenvalues
## with imaginary parts being zero
r3 = eigs(myfun, k = ord, n = length(h), args = H)
## Directly return real-typed eigenvalues since we use a symmetric eigensolver
r4 = eigs(myfun, k = ord, n = length(h), args = H, symmetric = TRUE)

You can install the new version from github or waiting for a CRAN version.

@yixuan yixuan closed this Aug 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.