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

No method for isless(::Complex128,::Int64) #21273

Closed
jebej opened this issue Apr 4, 2017 · 6 comments
Closed

No method for isless(::Complex128,::Int64) #21273

jebej opened this issue Apr 4, 2017 · 6 comments

Comments

@jebej
Copy link
Contributor

jebej commented Apr 4, 2017

It seems that there is no method for comparing complex numbers to integers, which seems to be required for (some) matrix exponentials, and for all complex matrix exponentials.

i.e., the following happens intermitently, depending on the random matrix

julia> rand(3,3)^2.3
ERROR: MethodError: no method matching isless(::Complex{Float64}, ::Int64)
Closest candidates are:
  isless(::AbstractFloat, ::Real) at operators.jl:98
  isless(::Real, ::Real) at operators.jl:266
Stacktrace:
 [1] (::Base.LinAlg.##17#18)(::Complex{Float64}) at .\<missing>:0
 [2] broadcast_t(::Function, ::Type{Any}, ::Tuple{Base.OneTo{Int64}}, ::Cartesia
nRange{CartesianIndex{1}}, ::Array{Complex{Float64},1}) at .\broadcast.jl:255
 [3] broadcast_c at .\broadcast.jl:298 [inlined]
 [4] broadcast(::Function, ::Array{Complex{Float64},1}) at .\broadcast.jl:415
 [5] ^(::Array{Float64,2}, ::Float64) at .\linalg\dense.jl:320

but this always throws an error:

julia> rand(Complex128,3,3)^2.3
ERROR: MethodError: no method matching isless(::Complex{Float64}, ::Int64)
...
@tkelman
Copy link
Contributor

tkelman commented Apr 4, 2017

how would you compare complex numbers to real integers?

it's a bug in the matrix exponential, being worked on in #21184, that it's trying to do this

@jebej
Copy link
Contributor Author

jebej commented Apr 4, 2017

It seems that defining

Base.isless(a::Complex,b::Real) = isless(norm(a),b)

gives the right matrix exponential, and I think this is how MATLAB defines < as well.

@jebej
Copy link
Contributor Author

jebej commented Apr 4, 2017

Actually scratch that, it seems MATLAB compares the real part only.

@JeffBezanson
Copy link
Member

Complex numbers don't have a well-defined total order. We should just fix matrix exponential.

@jebej
Copy link
Contributor Author

jebej commented Apr 4, 2017

Yes. Does #21184 also take care of complex matrix exponentials? If so we can close this issue.

@ararslan
Copy link
Member

ararslan commented Apr 4, 2017

Does #21184 also take care of complex matrix exponentials?

Yes

@ararslan ararslan closed this as completed Apr 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants