multi-layer repository/Static Index/PQ_quantizer.cpp
idx_t PQ_quantizer::spaceID_2_label(const idx_t * index, const idx_t group_id){
        idx_t idx = 0;

        for (size_t i = 0; i < M; i++){
            idx += index[i] * new_pow(exact_ksubs[group_id], i);
        }
        idx_t result_idx = CentroidDistributionMap[group_id] + idx; 
        if (result_idx >= layer_nc){
            std::cout << group_id << " " << CentroidDistributionMap[group_id] << " " << idx << " " << layer_nc << std::endl;
        }
        assert(result_idx < layer_nc);
        return result_idx;
    }
/**
     * 
     * The transfer function between index and id
     * 
     * Input: 
     * index: the id for sub vector in each subspace  size: M
     * group_id: the group_id for computing base_id
     * 
     * Output:
     * id: the id for an data vector in the whole range [0, nc_upper * nc_per_group]
     * 
     **/
The transfer function between index and id

the id for sub vector in each subspace  size: M
group_id: the group_id for computing base_id

the id for an data vector in the whole range [0, nc_upper * nc_per_group]
The transfer function between index and id the id for sub vector in each subspace size : M group_id : the group_id for computing base_id the id for an data vector in the whole range [ 0 nc_upper * nc_per_group ]
idx_t PQ_quantizer::spaceID_2_label(const idx_t * index, const idx_t group_id){
        idx_t idx = 0;
        for (size_t i = 0; i < M; i++){
            idx += index[i] * new_pow(exact_ksubs[group_id], i);
        }
        idx_t result_idx = CentroidDistributionMap[group_id] + idx; 
        if (result_idx >= layer_nc){
            std::cout << group_id << " " << CentroidDistributionMap[group_id] << " " << idx << " " << layer_nc << std::endl;
        }
        assert(result_idx < layer_nc);
        return result_idx;
    }
idx_t PQ_quantizer :: spaceID_2_label ( const idx_t * index , const idx_t group_id ) { idx_t idx = 0 ; for ( size_t i = 0 ; i < M ; i ++ ) { idx += index [ i ] * new_pow ( exact_ksubs [ group_id ] , i ) ; } idx_t result_idx = CentroidDistributionMap [ group_id ] + idx ; if ( result_idx >= layer_nc ) { std :: cout << group_id << " " << CentroidDistributionMap [ group_id ] << " " << idx << " " << layer_nc << std :: endl ; } assert ( result_idx < layer_nc ) ; return result_idx ; }
The transfer function between index and id
The transfer function between index and id