H
Hicham Mouline
Hello
I have a function
double f( const Parameters& p );
the object Parameters is big. sizeof(Parameters) is big.
we wish to calculate the senstivity of f to 1 of the parameters inside p,
a naive implementation is
// forward difference
double fprime( const Parameters& p )
{
const double y = f(p);
Parameters pup = p;
pup.p3 += epsilon;
const double yup = f(pup);
return (yup-y)/epsilon;
}
on a profiler, the problem here looks to be the deep copy of p into pup.
Is there an alternative way that remains readable and concise?
regards,
I have a function
double f( const Parameters& p );
the object Parameters is big. sizeof(Parameters) is big.
we wish to calculate the senstivity of f to 1 of the parameters inside p,
a naive implementation is
// forward difference
double fprime( const Parameters& p )
{
const double y = f(p);
Parameters pup = p;
pup.p3 += epsilon;
const double yup = f(pup);
return (yup-y)/epsilon;
}
on a profiler, the problem here looks to be the deep copy of p into pup.
Is there an alternative way that remains readable and concise?
regards,