I've just read more about composite types, they sound like they might give 
an advatage I'll implement them and try. p definitelly can be part of a 
composite type I can even initialise it with a defined length I guess this 
should speed thing up.

Thankyou!

On Thursday, May 22, 2014 3:18:42 PM UTC+1, Tobias Knopp wrote:
>
> It sounds to me that this should be handles using a composite type instead 
> of a tuple. It may even be immutable if only the content of p changes but 
> not the variable (pointer) itself.
>
> Am Donnerstag, 22. Mai 2014 15:23:53 UTC+2 schrieb sam cooper:
>>
>> 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