Statistics
| Revision:

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

History | View | Annotate | Download (840 Bytes)

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

    
4
#include <fvar.hpp>
5

    
6
double fcomp(int, dvar_vector); // Function prototype declaration
7
#ifdef __BCPLUSPLUS__
8
  extern unsigned _stklen = 20000;
9
#endif
10
#ifdef __ZTC__
11
  long _stack = 20000;
12
#endif
13
void main()
14
{
15
  int nvar=20; // This is the number of independent variables
16
  independent_variables x(1,nvar); // these are the independent variables
17
  double f; // This is the dependent variable
18
  dvector g(1,nvar); // Holds the vector of partial derivatives (gradient)
19
  fmm fmc(nvar); // Create structure to manage minimization
20
  BEGIN_MINIMIZATION(nvar,f,x,g,fmc) // Macro to set up beginning of
21
  // minimization loop
22
  f=fcomp(nvar,x);
23
  END_MINIMIZATION(nvar,g) // Macro to set up end of minimization loop
24
  cout << " The minimizing values are\n" << x << "\n"; //Print out answer
25
}
26
\end{lstlisting}