I am writting a c++ program in which I define a function $$\displaystyle F(t) = \sum_{i}r_i\,H(t-t_i)$$ where $H$ is the heaviside function, $t_i$ are optimal parameters which are mutable.
The program is derived by automatic differentiation using ADOL-C. I am wondering whether I should be careful when I am implementing the function $f$ regarding branching and looping.
I would create the function:
template <class Tdouble> Tdouble myfunF ( Tdouble t, Tdouble *tis, int nbti)
{
Tdouble res = 0.;
double ri = 0.;
for(int id=0;i<nbti;++i)
{
ri = ...;
if (t>ti){
res = res + ri;
}
}
return res ;
}
The Tdouble type is similar to the adouble type in ADOL-C. How to analyze if this construction is suitable for automatic differentiation using ADOL-C and rewrite the code ?