Hello everyone,
I’m trying to use a complex Schur decomposition and retrieve the generalized eigenvalues. A very much simplified example is here:
const A = complex(randn(10,10))
const B = complex(randn(10,10))
function schur_test(A, B)
F = schurfact(A, B)
gen_ev = F[:values]
return gen_ev
end
gen_ev = schur_test(A, B)
However, the type of F[:values]
can’t be inferred.
@code_warntype schur_test(A, B)
Variables:
#self# <optimized out>
A::Array{Complex{Float64},2}
B::Array{Complex{Float64},2}
F::Base.LinAlg.GeneralizedSchur{Complex{Float64},Array{Complex{Float64},2}}
gen_ev::Any
Body:
begin
$(Expr(:inbounds, false))
# meta: location linalg/schur.jl schurfact 197
SSAValue(1) = $(Expr(:foreigncall, :(:jl_array_copy), Ref{Array{Complex{Float64},2}}, svec(Any), :(A), 0))
SSAValue(0) = $(Expr(:foreigncall, :(:jl_array_copy), Ref{Array{Complex{Float64},2}}, svec(Any), :(B), 0))
# meta: location linalg/schur.jl schurfact! 184
SSAValue(2) = $(Expr(:invoke, MethodInstance for gges!(::Char, ::Char, ::Array{Complex{Float64},2}, ::Array{Complex{Float64},2}), :($(QuoteNode(Base.LinAlg.LAPACK.gges!))), 'V', 'V', SSAValue(1), SSAValue(0)))
# meta: pop location
# meta: pop location
$(Expr(:inbounds, :pop))
F::Base.LinAlg.GeneralizedSchur{Complex{Float64},Array{Complex{Float64},2}} = $(Expr(:new, Base.LinAlg.GeneralizedSchur{Complex{Float64},Array{Complex{Float64},2}},:((Core.getfield)(SSAValue(2), 1)::Array{Complex{Float64},2}), :((Core.getfield)(SSAValue(2), 2)::Array{Complex{Float64},2}), :((Core.getfield)(SSAValue(2), 3)::Array{Complex{Float64},1}), :((Core.getfield)(SSAValue(2), 4)::Array{Complex{Float64},1}), :((Core.getfield)(SSAValue(2), 5)::Array{Complex{Float64},2}), :((Core.getfield)(SSAValue(2), 6)::Array{Complex{Float64},2}))) # line 145:
gen_ev::Any = $(Expr(:invoke, MethodInstance for getindex(::Base.LinAlg.GeneralizedSchur{Complex{Float64},Array{Complex{Float64},2}}, ::Symbol), :(Main.getindex), :(F), :(:values))) # line 146:
return gen_ev::Any
end::Any
Putting type information on the function arguments or on gen_ev = Array{Complex{Float64},1}(F[:values])
doesn’t change the fact that gen_env
and any variables that I want to construct using it are not type stable.
Any hints are very much appreciated.
Thanks, Benjamin
System:
Julia Version 0.6.4
Commit 9d11f62bcb (2018-07-09 19:09 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin17.7.0)
CPU: Intel(R) Core(TM) i7-6567U CPU @ 3.30GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=16)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, skylake)