sparse_learn/c/head_tail_proj.c
double min_pi(
        const double *prizes, double *total_prizes, int n, double err_tol,
        int verbose) {
    *total_prizes = 0.0;
    double positive_min = INFINITY;
    for (int ii = 0; ii < n; ii++) {
        *total_prizes += prizes[ii];
        if ((prizes[ii] < positive_min) && (prizes[ii] > 0.0)) {
            positive_min = prizes[ii];
        }
    }
    /**
     * Warning: There is a precision issue here. We may need to define a
     * minimum precision. In our experiment,  we found that some very
     * small positive number could be like 1.54046e-310, 1.54046e-310.
     * In this case, the fast-pcst cannot stop!!!
     */
    if (positive_min < err_tol) {
        if (verbose > 0) {
            printf("warning too small positive val found.\n");
        }
        positive_min = err_tol;
    }
    return positive_min;
}
// get positive minimum prize in prizes vector.
get positive minimum prize in prizes vector.
get positive minimum prize in prizes vector .
double min_pi(
        const double *prizes, double *total_prizes, int n, double err_tol,
        int verbose) {
    *total_prizes = 0.0;
    double positive_min = INFINITY;
    for (int ii = 0; ii < n; ii++) {
        *total_prizes += prizes[ii];
        if ((prizes[ii] < positive_min) && (prizes[ii] > 0.0)) {
            positive_min = prizes[ii];
        }
    }
    if (positive_min < err_tol) {
        if (verbose > 0) {
            printf("warning too small positive val found.\n");
        }
        positive_min = err_tol;
    }
    return positive_min;
}
double min_pi ( const double * prizes , double * total_prizes , int n , double err_tol , int verbose ) { * total_prizes = 0.0 ; double positive_min = INFINITY ; for ( int ii = 0 ; ii < n ; ii ++ ) { * total_prizes += prizes [ ii ] ; if ( ( prizes [ ii ] < positive_min ) && ( prizes [ ii ] > 0.0 ) ) { positive_min = prizes [ ii ] ; } } if ( positive_min < err_tol ) { if ( verbose > 0 ) { printf ( " \n " ) ; } positive_min = err_tol ; } return positive_min ; }
get positive minimum prize in prizes vector.
get positive minimum prize in prizes vector .
/**
     * Warning: There is a precision issue here. We may need to define a
     * minimum precision. In our experiment,  we found that some very
     * small positive number could be like 1.54046e-310, 1.54046e-310.
     * In this case, the fast-pcst cannot stop!!!
     */