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

Missing function name eigs #69

Open
jpfairbanks opened this issue Aug 28, 2018 · 3 comments
Open

Missing function name eigs #69

jpfairbanks opened this issue Aug 28, 2018 · 3 comments
Labels

Comments

@jpfairbanks
Copy link

jpfairbanks commented Aug 28, 2018

Hi @haampie, is there a reason this package doesn't export a function eigs satisfying the old interface?

it looks like the correct way to use it is

function eigs(A; kwargs)
     schur_to_eigen(partial_schur(A; kwargs...)[1])
end

Is there something else to it?

@haampie
Copy link
Member

haampie commented Aug 29, 2018

Hey, yes, I should still write the utility functions. Right now the API is more or less similar to ARPACK (a function for matrix -> schur and one that does some post-processing with partial schur -> eigen). The eigs function in Arpack.jl is actually implemented in Julia itself and does more or less what you have there.

@jpfairbanks
Copy link
Author

jpfairbanks commented Sep 9, 2018

Here is the version that is working for me in LG.

function eigs(A; kwargs...)
    schr =partialschur(A; kwargs...)
    vals, vectors = partialeigen(schr[1])
    reved = (kwargs[:which] == LR() || kwargs[:which] == LM())
    k = get(kwargs, :nev, length(vals))
    k = min(k, length(vals))
    perm = 1:k
    if vals[1] isa(Real)
        perm = sortperm(vals, rev=reved)
        perm = perm[1:k]
    end
    λ = vals[perm]
    Q = vectors[:, perm]
    return λ, Q
end

I can make a PR. I don't know about the other corner cases. These work for my needs which are mostly limited to Adjacency and Laplacian Matrices of graphs.

@haampie
Copy link
Member

haampie commented Sep 10, 2018

So, the order of the eigenvalues has been fixed now when calling partialschur. Also the eigenvalues appear in the PartialSchur struct as decomp.eigenvalues. Further, partialeigen retains the order.

In the end eigs is basically no different from calling partialeigen(partialschur(...)[1]) then. I would be fine with a PR that implements this! Maybe it's good to throw when the method did not converge (?).

@haampie haampie added v0.4 v0.3 and removed v0.4 labels Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants