Please do file an issue <https://github.com/JuliaLang/julia/issues> if you haven't already.
On Fri, Jul 24, 2015 at 5:09 AM, Mauro <[email protected]> wrote: > > I recently poked around a bit with the @code_warntype macro in my code > and > > quickly realized that a lot of my variables were assigned "Any" at > compile > > time. I tried to find the reason for it and got down to the eig function: > > > > julia> @code_warntype eig(rand(Float64, 5,5)) > > Variables: > > A::Array{Float64,2} > > args::Tuple{} > > > > Body: > > begin $(Expr(:line, 66, symbol("linalg/eigen.jl"), symbol(""))) > > GenSym(8) = (top(ccall))(:jl_alloc_array_1d,$(Expr(:call1, > > :(top(apply_type)), :Array, Any, 1)),$(Expr(:call1, :(top(svec)), :Any, > > :Int)),Array{Any,1},0,0,0)::Array{Any,1} > > GenSym(9) = GenSym(8) > > return __eig#179__(GenSym(9),A::Array{Float64,2})::Tuple{Any,Any} > > end::Tuple{Any,Any} > > > > > > Is there a reason this returns Tuple{Any, Any} instead of > Tuple{Complex128, > > Complex128} as you might expect? As far as I understand it this causes > > everything touched by the eig function to become type unstable. > > The reason is the method getindex(A::Union{Eigen,GeneralizedEigen}, > d::Symbol) near the top of base/linalg/eigen.jl which is not type > stable. This is then used in eig. Have a look at it with > > @edit eig(rand(Float64, 5,5)) > > I suspect this is a bug, you should file a report. In the meantime you > can monkey patch by adding this to your code: > > function Base.eig(A::Union{Number, AbstractMatrix}, args...; kwargs...) > F = eigfact(A, args...; kwargs...) > F.values, F.vectors > end >
