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

sortby keywords not supported in eigvals() with Symmetric matrices #883

Closed
Weiyu-USTC opened this issue Oct 30, 2021 · 2 comments · Fixed by JuliaLang/julia#42900
Closed
Labels
good first issue Good for newcomers

Comments

@Weiyu-USTC
Copy link

Weiyu-USTC commented Oct 30, 2021

I am trying to sort the eigenvalues of a symmetric matrix in a different order. Then with the Symmetric type of matrices, the keyword sortby can work for the function eigen() but not eigvals(). An example:

M = Symmetric([1 2 3; 2 3 4; 3 4 5])
eigen(M, sortby = x -> -x)

The above one-line code can work and output the eigens in descending order:

Eigen{Float64, Float64, Matrix{Float64}, Vector{Float64}}
values:
3-element Vector{Float64}:
9.623475382979782
-7.771561172376096e-16
-0.6234753829797993
vectors:
3×3 Matrix{Float64}:
0.38509 0.408248 0.827671
0.55951 -0.816497 0.142414
0.733931 0.408248 -0.542844

However, for

M = Symmetric([1 2 3; 2 3 4; 3 4 5])
eigvals(M, sortby = x -> -x)

an error shows up:

MethodError: no method matching eigvals!(::LinearAlgebra.Symmetric{Float64, Matrix{Float64}}; sortby=var"#60#62"{typeof(-)}(-))

@Chandu-4444
Copy link

Can you please format the code a bit more elegantly?

You can use :
```Julia
print("Hello world!")
```
This formats to:

print("Hello world!")

@Weiyu-USTC
Copy link
Author

Can you please format the code a bit more elegantly?

You can use : Julia print("Hello world!") This formats to:

print("Hello world!")

Thanks, done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants