template<class Type, class Functor>
struct laplace_t {
Functor f;
int niter;
f(f_), u(u_), niter(niter_) {}
Type operator()(){
for (int i=0; i<niter; i++){
}
ans -= .5 * Type(u.size()) * log(2.0 * M_PI);
return ans;
}
};
template<class Type, class Functor>
laplace_t<Type, Functor> L(f, u, niter);
return L();
}
template<class Type>
struct joint_nll {
Type a;
Type log_sigma;
Type a_,
Type log_sigma_) :
y(y_), X(X_), dd(dd_), b(b_),
a(a_), log_sigma(log_sigma_) {}
template <typename T>
int n = u.size();
T res=0;
eta = eta + mu.template cast<T>();
for (int i=0; i<n; i++)
{
cov(i,i) = 1.0;
for (int j=0; j<i; j++)
{
cov(i,j) = exp(-a * dd(i,j));
cov(j,i) = cov(i,j);
}
}
res += neg_log_density(u);
for(int i=0; i<y.size(); i++)
res -= T(y[i]) * eta[i] - exp(eta[i]);
return res;
}
};
template<class Type>
Type objective_function<Type>::operator() ()
{
int n = dd.rows();
joint_nll<Type> jnll(y, X, dd, b, a, log_sigma);
u.setZero();
Type res = laplace(jnll, u, niter);
return res;
}