Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upeigs problem #8
eigs problem #8
Comments
|
Thanks @xshi19 , I'll look into this problem shortly. |
|
This seems to be a known problem that |
|
Hi @xshi19 ## 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. |
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)