Hi,

I have an inner loop function which uses a 'constant' tuple:

fhandle = (expdat,obsv,expdev,t)

with types

fhandle::(Matrix{Float64},Vector{Int64},Float64,Vector{Int64})

Currently I am passing fhandle to the function each time it's called and 
then reallocating a set of variables i.e.

function sqrerror(fhandle::(Matrix{Float64},Vector{Int64},Float64,Vector{
Int64}),p::Vector{Float64})

    (expdat,obsv,expdev,tsample) = fhandle
    (obs,error_flag) = odesolve(p,tsample,obsv)

    if error_flag
        return(1e16)
    end
    error_val = sum((expdat.-obs).^2,1)
    error_val = sum(error_val./(expdev.^2))
    return(error_val)
end


Only 'p' is changed each time the function is called but fhandle is 
constant but needs to be defined in another file really.

Can I speed this up? I was thinking about using a module with const global 
variables but the documentation suggested global variables are slower.

Thankyou in advance for any help and advice

Best,
Sam

Reply via email to