98 double eval(
const RealVector& parameters)
const {
108 double betaInv = parameters.back();
110 betaInv = std::exp(betaInv);
116 RealMatrix t = createBatch<RealVector>(m_dataset.
labels().
elements());
118 blas::cholesky_decomposition<RealMatrix> cholesky(M);
122 double logDet = 2* trace(log(cholesky.lower_factor()));
128 RealMatrix z = solve(cholesky.lower_factor(),t,blas::lower(), blas::left());
132 double e = 0.5 * (-logDet - norm_sqr(to_vector(z)) - N * std::log(2.0 * M_PI));
150 derivative.resize(1 + kp);
156 double betaInv = parameters.back();
158 betaInv = std::exp(betaInv);
163 RealMatrix t = createBatch<RealVector>(m_dataset.
labels().
elements());
166 blas::cholesky_decomposition<RealMatrix> cholesky(M);
182 RealMatrix W= blas::identity_matrix<double>(N);
183 cholesky.solve(W,blas::left());
186 RealMatrix z = prod(W,t);
191 noalias(W) += prod(z,trans(z));
200 double betaInvDerivative = 0.5 * trace(W) ;
202 betaInvDerivative *= betaInv;
205 noalias(derivative) = - (kernelGradient | betaInvDerivative);
208 for(std::size_t i=0; i<derivative.size(); i++)
209 if(std::abs(derivative(i)) < m_derivativeThresholds(i)) derivative(i) = 0;
213 double logDetM = 2* trace(log(cholesky.lower_factor()));
214 double e = 0.5 * (-logDetM - inner_prod(to_vector(t), to_vector(z)) - N * std::log(2.0 * M_PI));