5 double LambertW(
double x) {
7 double y = (logx > 0 ? logx : 0);
9 for (; i < niter; i++) {
10 if ( fabs( logx - log(y) - y) < 1e-9)
break;
11 y -= (y - exp(logx - y)) / (1 + y);
13 if (i == niter) Rf_warning(
"W: failed convergence");
24 ty[0] = LambertW(tx[0]);
28 Type DW = 1. / (exp(W) * (1. + W));
34 Type LambertW(Type x){
35 CppAD::vector<Type> tx(1);
37 return LambertW(tx)[0];
44 Type objective_function<Type>::operator() ()
47 Type f = LambertW(x).sum();
#define VECTORIZE1_t(FUN)
Vectorize 1-argument functions.
Includes and sets all stuff needed to compile the user defined objective function.
#define PARAMETER_VECTOR(name)
Get parameter vector from R and declare it as vector<Type>
#define TMB_ATOMIC_VECTOR_FUNCTION( ATOMIC_NAME, OUTPUT_DIM, ATOMIC_DOUBLE, ATOMIC_REVERSE)
Construct atomic vector function based on known derivatives.