예제 #1
0
ind_t VarSizeList_get(const PVarSizeList pset, uint32 i, ind_t* data, ind_t max_dim){
    assert(i < pset->count());
    auto cur = pset->get(i);
    for (int i=0;i<max_dim;i++)
        data[i] = cur[i];
    return cur.size();
}
예제 #2
0
PVarSizeList GetIndexSet(PVarSizeList pRet,
                         const PProfitCalculator profCalc,
                         double max_prof,
                         double **p_profits) {
    ind_t max_d = profCalc->max_dim();
    ind_mul_ind_t ind_set;
    ind_set.push_back(setprof_t(mul_ind_t(), profCalc->calc_log_prof(mul_ind_t())));

    double cur_prof;
    ind_mul_ind_t::iterator itrCur = ind_set.begin();
    while (itrCur != ind_set.end()) {
        if (itrCur->size < max_d) {
            mul_ind_t cur_ind = itrCur->ind;
            ind_set.push_back(setprof_t(cur_ind, -1, itrCur->size+1));

            ind_t cur_size = itrCur->size;
            cur_ind.step(cur_size);
            while ((cur_prof=profCalc->calc_log_prof(cur_ind)) <= max_prof){
                ind_set.push_back(setprof_t(cur_ind, cur_prof));
                cur_ind.step(cur_size);
            }
            // if (added > 0)  // This assumes that dimensions are ordered!

        }
        // If this iterator has negative profit it means it's temporary and
        //  can be deleted safely (since all derivatives are already added)
        if (itrCur->profit < 0)
            itrCur = ind_set.erase(itrCur); // erase returns the next iterator
        else
            itrCur++;
    }

    ind_set.sort(compare_setprof);

    if (p_profits)
        *p_profits = static_cast<double*>(malloc(sizeof(double) * ind_set.size()));

    uint32 i=0;
    if (!pRet)
        pRet = new VarSizeList(ind_set.size());

    for (auto itr=ind_set.begin();itr!=ind_set.end();itr++){
        if (!pRet->has_ind(itr->ind))
            pRet->push_back(itr->ind);
        if (p_profits)
            (*p_profits)[i++] = itr->profit;
    }
    return pRet;
}
예제 #3
0
PVarSizeList VarSizeList_from_matrix(const ind_t *sizes, uint32 count,
                                     const ind_t *j, uint32 j_size,
                                     const ind_t *data, uint32 data_size){
    PVarSizeList pset = new VarSizeList(count);
    uint32 total_size = 0;
    for (uint32 i=0;i<count;i++){
        total_size += sizes[i];
        assert(j_size >= total_size);
        assert(data_size >= total_size);

        pset->push_back(mul_ind_t(j, data, sizes[i]));
        j += sizes[i];
        data += sizes[i];
    }
    return pset;
}
예제 #4
0
double VarSizeList_estimate_bias(const PVarSizeList pset,
                                 const double *err_contributions,
                                 uint32 count,
                                 const double *rates, uint32 rates_size){
    return pset->estimate_bias(err_contributions, count,
                               rates, rates_size);
}
예제 #5
0
void VarSizeList_get_adaptive_order(const PVarSizeList pset,
                                    const double *error,
                                    const double *work,
                                    uint32 *adaptive_order,
                                    uint32 count,
                                    ind_t seedLookahead){
    pset->get_adaptive_order(error, work, adaptive_order, count, seedLookahead);
}
예제 #6
0
PVarSizeList VarSizeList_expand_set(const PVarSizeList pset,
                                    const double* error,
                                    const double* work,
                                    uint32 count,
                                    ind_t dimLookahead){
    PVarSizeList result = new VarSizeList();
    *result = pset->expand_set(error, work, count, dimLookahead);
    return result;
}
예제 #7
0
ind_t VarSizeList_get(const PVarSizeList pset, uint32 i, ind_t* data,
                      ind_t* j, ind_t size){
    const mul_ind_t& cur = pset->get(i);
    i=0;
    assert(cur.active() <= size);
    for (auto itr=cur.begin();itr!=cur.end();itr++, i++) {
        data[i] = itr->value;
        j[i] = itr->ind;
    }
    return cur.active();
}
예제 #8
0
PVarSizeList VarSizeList_from_matrix(PVarSizeList pset,
                                     const ind_t *sizes, uint32 count,
                                     const ind_t *j, uint32 j_size,
                                     const ind_t *data, uint32 data_size){
    if (!pset)
        pset = new VarSizeList(count);
    uint32 total_size = 0;
    for (uint32 i=0;i<count;i++){
        total_size += sizes[i];
        assert(j_size >= total_size);
        assert(data_size >= total_size);
        //std::cout << "adding: " << mul_ind_t(j, data, sizes[i]) << "of size" << sizes[i] << std::endl;
        pset->push_back(mul_ind_t(j, data, sizes[i]));
        j += sizes[i];
        data += sizes[i];
    }
    return pset;
}
예제 #9
0
void VarSizeList_to_matrix(const PVarSizeList pset, ind_t *ij, uint32 ij_size,
                           ind_t *data, uint32 data_size){
    pset->to_matrix(ij, ij_size, data, data_size);
}
예제 #10
0
void VarSizeList_all_active_dim(const PVarSizeList pset, uint32 *active_dim, uint32 size){
    pset->all_active_dim(active_dim, size);
}
예제 #11
0
void VarSizeList_all_dim(const PVarSizeList pset, uint32 *dim, uint32 size){
    pset->all_dim(dim, size);
}
예제 #12
0
ind_t VarSizeList_get_active_dim(const PVarSizeList pset, uint32 i){
    return pset->get(i).active();
}
예제 #13
0
ind_t VarSizeList_get_dim(const PVarSizeList pset, uint32 i){
    return pset->get(i).size();
}
예제 #14
0
void CalculateSetProfit(const PVarSizeList pset,
                        const PProfitCalculator profCalc,
                        double *log_prof, uint32 size){
    pset->calc_set_profit(profCalc, log_prof, size);
}
예제 #15
0
void VarSizeList_is_parent_of_admissible(const PVarSizeList pset, unsigned char *out, uint32 count){
    pset->is_parent_of_admissible(out, count);
}
예제 #16
0
void VarSizeList_check_errors(const PVarSizeList pset, const double *errors, unsigned char* strange, uint32 count){
    pset->check_errors(errors, strange, count);
}
예제 #17
0
PVarSizeList VarSizeList_set_union(const PVarSizeList lhs, const PVarSizeList rhs){
    PVarSizeList result = new VarSizeList();
    *result = lhs->set_union(*rhs);
    return result;
}
예제 #18
0
void MakeProfitsAdmissible(const PVarSizeList pset, ind_t d_start, ind_t d_end,
                           double *pProfits){
    pset->make_profits_admissible(d_start, d_end, pProfits, pset->count());
}
예제 #19
0
void CheckAdmissibility(const PVarSizeList pset, ind_t d_start, ind_t d_end,
                        unsigned char *admissible){
    pset->check_admissibility(d_start, d_end, admissible, pset->count());
}
예제 #20
0
int VarSizeList_find(const PVarSizeList pset, ind_t *j, ind_t *data,
                     ind_t size){
    uint32 index;
    bool bfound = pset->find_ind(SparseMIndex(j, data, size), index);
    return bfound ? index:-1;
}
예제 #21
0
void CheckAdmissibility(const PVarSizeList pset, ind_t d_start, ind_t d_end,
                        bool *admissible){
    pset->CheckAdmissibility(d_start, d_end, admissible, pset->count());
}
예제 #22
0
//////// ------------------------------------------------
/// C-Accessors to C++ methods
double GetMinOuterProfit(const PVarSizeList pset,
                         const PProfitCalculator profCalc){
    return pset->get_min_outer_profit(profCalc);
}
예제 #23
0
void VarSizeList_count_neighbors(const PVarSizeList pset, ind_t *out_neighbors, uint32 count){
    pset->count_neighbors(out_neighbors, count);
}
예제 #24
0
uint32 VarSizeList_count(const PVarSizeList pset){
    return pset->count();
}
예제 #25
0
ind_t VarSizeList_max_dim(const PVarSizeList pset){
    return pset->max_dim();
}
예제 #26
0
void CalculateSetProfit(const PVarSizeList pset,
                        const PProfitCalculator profCalc,
                        double *log_error, double *log_work){
    pset->CalculateSetProfit(profCalc, log_error, log_work, pset->count());
}