So, I am kind of confused here. In my code, a maxV = maximum(V) is labeled 
as Core.Box in @code_warntype, but if I remove a line after the line where 
maxV is calculated, it is correctly labelled as eltype(V). Can anyone 
explain what happens/what I am doing wrong here? This is not the whole 
function, I've tried to remove all irrelevant code.
V = [0.,]
P = Vector{Float64}[[0.0,], [0.0,]]
U = Vector{Float64}[[1.,], [1.,]]
F = Matrix{Float64}[eye(1), eye(1)]
b = 0.9

function c!{T}(P, U, b::T, F, V)
if length(P) > 2
        maxV = maximum(V)
        d = sum(exp(U[ia]+b*F[ia]*V-maxV) for ia = 1:length(P))::T
    end
    P
end

# This shows maxV as Core.Box
@code_warntype    c!(P, U, β, F, V)


function c!{T}(P, U, b::T, F, V)
if length(P) > 2
        maxV = maximum(V)
    end
    P
end

# This does not show maxV as Core.Box, but as eltype(V) as I expected
@code_warntype    c!(P, U, β, F, V)

Thanks

Reply via email to