Statistics
| Revision:

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

History | View | Annotate | Download (438 Bytes)

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

    
4
#include <fvar.hpp>
5

    
6
void hemholtz_energy(int n, dmatrix A, dvector b, dvar_vector x, double& f)
7
{
8
  double R=.00005;
9
  double T=290;
10
  double root2=pow(2.,.5);
11
  dvariable btx = b*x;
12
  dvariable log_one_minus_btx = log(1-btx);
13
  dvariable z = R * T * ( x * (log(x)-log_one_minus_btx) );
14
  z -= (x * A * x)/(2*root2*btx) * log((1+(1+root2)*btx)/(1+(1-root2)*btx));
15
  f=value(z);
16
}
17
\end{lstlisting}