Statistics
| Revision:

root / branches / pthreads-737 / docs / manuals / autodif / userfun.cpp @ 765

History | View | Annotate | Download (328 Bytes)

1
\begin{lstlisting}
2
// file: userfin.cpp 
3

    
4
#include <fvar.hpp> 
5

    
6
double userfun(dvar_vector& x) 
7
{ 
8
  dvariable z,tmp; 
9
  int min,max; 
10
  min=x.indexmin(); 
11
  max=x.indexmax(); 
12
  tmp=x[min]-1; 
13
  z+=tmp*tmp; 
14
  for (int i=min;i<max;i++) 
15
  {  
16
    tmp=x[i+1]-x[i]; 
17
    z+=tmp*tmp; 
18
  } 
19
  return(value(z)); 
20
} 
21
\end{lstlisting}