Mat solveQurdOpt(SpMat L, SpMat C, VectorXd alpha_star){ // omp_set_num_threads(1); Eigen::setNbThreads(1); cout << "solving quadratic optimization proble .............." << endl; double lambda = 0.000001; SpMat D(L.rows(), L.cols()); D.setIdentity(); SpMat b = alpha_star.sparseView(); SpMat A, alpha; A = L + C + lambda * D; b = C * b; Eigen::SimplicialLDLT<SpMat> solver; cout << "begin to factorize A" << endl; solver.compute(A); if(solver.info() != Eigen::Success) cout << "decomposition failed" << endl; else cout << "decomposition success" << endl; cout << "begin to solve !" << endl; alpha = solver.solve(b); cout << "solve success" << endl; Mat alpha_mat; eigen2cv(MatrixXd(alpha), alpha_mat); alpha_mat = alpha_mat.t(); alpha_mat = alpha_mat.reshape(0, imgSize.width).t(); alpha_mat = alpha_mat * 0.5 + 0.5; alpha_mat = max(min(alpha_mat, 1), 0); //showSavePicLBDM("alpha", alpha_mat, showImgLBDM, saveImgLBDM); return alpha_mat; }