If x1, ..., x6 or coeff are Float64 arrays, then the initialization
u1 = 0; u2 = 0; u3 = 0; u4 = 0; u5 = 0; u6 = 0
is problematic as soon as you get to
for k=1:nVar
u1 += x1[i + ni*( k-1 + nk* (t-1))]*coeff[k]
u2 += x2[i + ni*( k-1 + nk* (t-1))]*coeff[k]
u3 += x3[i + ni*( k-1 + nk* (t-1))]*coeff[k]
u4 += x4[i + ni*( k-1 + nk* (t-1))]*coeff[k]
u5 += x5[i + ni*( k-1 + nk* (t-1))]*coeff[k]
u6 += x6[i + ni*( k-1 + nk* (t-1))]*coeff[k]
end
because you're initializing them to be integers but then they get converted
into Float64. A more careful approach is to do something like this:
T = typeof(one(eltype(x1))*one(eltype(coeff))
TT = typeof(one(T) + one(T))
u1 = u2 = u3 = u4 = u5 = u6 = zero(TT)
In general, code_typed is your friend: look for Union types.
T = Vector{Float64}
code_typed(ll, (T, T, T, T, T, T, T, T, T, T, T, T, T, Float64, Int, Int))
and you'll see Union types all over the place. (TypeCheck also, but it didn't
seem to pick up this error.) And see the Performance Tips section of the
manual.
--Tim
> >>>>>>>> Andreas Noack Jensen