Eigen::MatrixXddK1=pow(12,-1)*(6*pdist2(x1.transpose(),x2.transpose()).cwiseProduct(substr(x1.row(0).transpose(),x2.row(0)))-6*p(0)*substr(x1.row(0).transpose(),x2.row(0)));// Derivative along x1
Eigen::MatrixXddK2=pow(12,-1)*(6*pdist2(x1.transpose(),x2.transpose()).cwiseProduct(substr(x1.row(1).transpose(),x2.row(1)))-6*p(0)*substr(x1.row(1).transpose(),x2.row(1)));// Derivative along x2
std::vector<Eigen::MatrixXd>dK;
dK.push_back(dK1);
dK.push_back(dK2);
if(flag_noiseObs==true)
{
K=K+p(1)*Eigen::MatrixXd::Identity(x1.cols(),x2.cols());//Consideration of noisy observation y
J=1e2*(a.array().tanh().replicate(2,1).cwiseProduct(J.array()).cwiseQuotient(J.array().square().colwise().sum().sqrt().replicate(2,1)));// Vector moving away from interior of shape