[ADOL-C] Using ADOLC on a function performing an interpolation

Pierre Martinon martinon at cmap.polytechnique.fr
Fri Dec 7 09:50:20 EST 2012


Hi everyone,

I have been using AdolC in conjunction with Ipopt for some time, and 
recently came across a problem.
I need to compute a basic linear 1D interpolation, which looks like

----------------------------
// Note: x is a Tdouble, x_tab and y_tab are double arrays

// find position of x in x_tab
int i = locate(x,x_tab);

// perform linear interpolation
Tdouble y = y_tab[i] +  (y_tab[i+1] - y_tab[i]) * (x - x_tab[i]) / 
(x_tab[i+1] - x_tab[i]);

----------------------------

The problem is that the 'locate' function contains branching instructions.
As the function is called tens of thousands of time, I don't think 
retaping is an option.
Is there a way to tell AdolC to just ignore this function and consider 
the index 'i' as a constant ?
If not, is there another way to write the interpolation so that AdolC 
can handle it ?

Thanks,
Pierre Martinon


More information about the ADOL-C mailing list