pair<double, MatrixXf> TargetProbEstimatorGivenBG::probify(const MatrixXf& scoremat) { // initial guest at lambda TargetProbFunction target_func(bgfreq, scoremat); double lamb; double fx; for (lamb = 1. / scoremat.maxCoeff(); lamb < 50.; lamb *= 2.) { fx = target_func.fx(lamb); if (fx > 0) break; } // use Newton/Raphson method to find the optimal lambda NewtonRaphsonRootFinder solver; lamb = solver.find_root(target_func, lamb); MatrixXf prob(scoremat.rows(), scoremat.cols()); prob = (bgfreq * bgfreq.transpose()).cwiseProduct((lamb * scoremat).unaryExpr(&exp)); return make_pair(lamb, prob); }
int main(int argc, char *argv[]) { int pid; switch(pid = fork()) { case 0: target_func(pid); break; case -1: fprintf(stderr, "ERROR: fork\n"); break; default: dummy_func(pid); break; } return 0; }