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

Change eigvals(::Number) to return a scalar #27730

Merged
merged 1 commit into from
Jun 24, 2018

Conversation

perrutquist
Copy link
Contributor

@perrutquist perrutquist commented Jun 22, 2018

This is a proposal for how eigvals could return a scalar when given a scalar input, in line with what svdvals does. (This avoids allocating a vector to store just one element.) See issue JuliaLang/LinearAlgebra.jl#536

Promotion to float is also skipped. Just like svdvals, eigvals will now return an Integer for a scalar Integer input. For a Complex scalar input, the return type will depend on whether the imaginary component is zero, as before.

Since Julia allows indexing into and iterating over a scalar as if it were a length-1 vector, existing code that assumes that a vector is returned will likely continue to work.

This is a proposal for how eigvals could return a scalar when given a
scalar input, in line with what svdvals does. (See issue #27687)

Promotion to float is also skipped. (Just like svdvals, eigvals will now
return an integer for scalar real integer input.) For complex scalar
input, the return type will depend on whether the imaginary component is
zero, as before.

Since Julia allows indexing into, and iterating over, a scalar as if it
were a length-1 vector, this change should have minimal effect on
existing code.
@perrutquist perrutquist changed the title Change eigvals(::Number) to return a scalar (#27687) Change eigvals(::Number) to return a scalar Jun 22, 2018
@andreasnoack andreasnoack added linear algebra Linear algebra bugfix This change fixes an existing bug labels Jun 24, 2018
@andreasnoack andreasnoack merged commit 41d7bcc into JuliaLang:master Jun 24, 2018
@perrutquist perrutquist deleted the scalareigvals branch June 25, 2018 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants