 gp2d ill-conditioned'</span>); keyboard; <span class="keyword">end</span>
    iR = R\eye(D);
    ij = bsxfun(@rdivide,inp,exp(2*X(1:D,j)'));
    L = exp(bsxfun(@plus,k(:,i),k(:,j)')+maha(ii,-ij,R\s/2)); <span class="comment">% called Q in thesis</span>
    A = beta(:,i)*beta(:,j)'; A = A.*L; ssA = sum(sum(A));
    S(i,j) = t*ssA; S(j,i) = S(i,j);

    zzi = ii*(R\s);
    zzj = ij*(R\s);
    zi = ii/R; zj = ij/R;

    tdX  = -0.5*t*sum(iR'.*bsxfun(@times,s,-2*exp(-2*X(1:D,i)')-2*exp(-2*X(1:D,i)')));
    tdX