In case you're interested, the answer is "yes, in principle".
If your fit function file has code like
void _myFitFunction(
//Fit Parameter(s)
double MyPar_1,/*...*/MyPar_N;
..
..)
// Beginning of editable part
NLFitContext *pCtxt = Project.GetNLFitContext();
if ( pCtxt )
/*static double initializes to 0.0*/
static double MyOldPar_1,/*...*/MyOldPar_N;
// If parameters were updated, we will recalculate what is required to
BOOL bIsNewParamValues = pCtxt->IsNewParamValues();
if ( bIsNewParamValues )
{
//check which parameters changed
BOOL bP_1_ch = MyPar_1 && MyOldPar_1;
/*[etc]*/
BOOL bP_N_ch = MyPar_N && MyOldPar_N;
//calculate only what's required according to bP_n_ch
then I can speed up calculation quite a bit if only the changes induced by the actual parameter change(s) are taken into account.
Of course this requires that at the end of the fit function code we have a sequence of parameter updates:
} //endif bIsNewParamValues
y=ReturnValue;
//update parameter values into static variables
MyOldPar_1=MyPar_1;
/* etc. */
MyOldPar_N=MyPar_N;
}
However, I see a possible issue with this:
Suppose more than one dataset is being fitted with myFitFunction. I would think that then there are several active instances of myFitFunction running. Due to the static statement, all would (have) to work on the same copies of MyOldPar_n (Q: isn't that true?)
No problem with shared parameters. But how about the non-shared ones? Is there a way to remember parameter values for successive calls of myFitFunction for successive calls concerning the same dataset while having them distinct for different datasets?
Any thoughts or help would be appreciated.