Le jeudi 22 mai 2014 15:23:53 UTC+2, sam cooper a écrit :
>
> 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.
>
Did you profile your code?
>From my experience (which you might not share), the most probable slow par
of the code would most certainly be "odesolve" in which case, fhandle is
not your problem. Please first profile your code and then let's see what we
can do for you.
>
> Thankyou in advance for any help and advice
>
> Best,
> Sam
>
>