<
boolLWA=false,
boolRWA=false>
85 size_tmem_used = (capacity *
sizeof(
gap_word_t));
123 if(!safe_inc) safe_inc = 1024;
206std::cout <<
bc_arr[
i] <<
", ";
210std::cout << std::endl;
218 template<
typenameFirst,
typenameSecond>
244 template<
typenameBI_TYPE>
256 template<
typenameRTYPE>
266 template<
typenameRTYPE>
269RTYPE idx = bm::get_super_block_start<RTYPE>(
i);
302 tmp=
n- ((
n>> 1) & 033333333333)
303- ((
n>> 2) & 011111111111);
304 return((
tmp+ (
tmp>> 3)) & 030707070707) % 63;
322x = x - ((x >> 1) & m1);
323y = y - ((y >> 1) & m1);
324u = u - ((u >> 1) & m1);
325v = v - ((v >> 1) & m1);
326x = (x & m2) + ((x >> 2) & m2);
327y = (y & m2) + ((y >> 2) & m2);
328u = (u & m2) + ((u >> 2) & m2);
329v = (v & m2) + ((v >> 2) & m2);
332x = (x & m3) + ((x >> 4) & m3);
333u = (u & m3) + ((u >> 4) & m3);
339 returnx & 0x000001FFU;
354 template<
typenameT,
typenameF>
357 for(
unsignedsub_octet = 0; w != 0; w >>= 4, sub_octet += 4)
370func(sub_octet, sub_octet + 1);
376func(sub_octet, sub_octet + 2);
379func(sub_octet + 1, sub_octet + 2);
382func(sub_octet, sub_octet + 1, sub_octet + 2);
388func(sub_octet, sub_octet + 3);
391func(sub_octet + 1, sub_octet + 3);
394func(sub_octet, sub_octet + 1, sub_octet + 3);
397func(sub_octet + 2, sub_octet + 3);
400func(sub_octet, sub_octet + 2, sub_octet + 3);
403func(sub_octet + 1, sub_octet + 2, sub_octet + 3);
406func(sub_octet, sub_octet + 1, sub_octet + 2, sub_octet + 3);
424 template<
typenameT,
typenameF>
428 for(
unsignedoctet = 0; w != 0; w >>= 8, octet += 8)
430 if(w & 1) func(octet + 0);
431 if(w & 2) func(octet + 1);
432 if(w & 4) func(octet + 2);
433 if(w & 8) func(octet + 3);
434 if(w & 16) func(octet + 4);
435 if(w & 32) func(octet + 5);
436 if(w & 64) func(octet + 6);
437 if(w & 128) func(octet + 7);
451 for(
unsignedsub_octet = 0; w; w >>= 4, sub_octet+=4)
458bits[
cnt++] = 0 + sub_octet;
461bits[
cnt++] = 1 + sub_octet;
464bits[
cnt] = 0 + sub_octet;
465bits[
cnt+1] = 1 + sub_octet;
469bits[
cnt++] = 2 + sub_octet;
472bits[
cnt+0] = 0 + sub_octet;
473bits[
cnt+1] = 2 + sub_octet;
477bits[
cnt+0] = 1 + sub_octet;
478bits[
cnt+1] = 2 + sub_octet;
482bits[
cnt+0] = 0 + sub_octet;
483bits[
cnt+1] = 1 + sub_octet;
484bits[
cnt+2] = 2 + sub_octet;
488bits[
cnt++] = 3 + sub_octet;
491bits[
cnt+0] = 0 + sub_octet;
492bits[
cnt+1] = 3 + sub_octet;
496bits[
cnt+0] = 1 + sub_octet;
497bits[
cnt+1] = 3 + sub_octet;
501bits[
cnt+0] = 0 + sub_octet;
502bits[
cnt+1] = 1 + sub_octet;
503bits[
cnt+2] = 3 + sub_octet;
507bits[
cnt+0] = 2 + sub_octet;
508bits[
cnt+1] = 3 + sub_octet;
512bits[
cnt+0] = 0 + sub_octet;
513bits[
cnt+1] = 2 + sub_octet;
514bits[
cnt+2] = 3 + sub_octet;
518bits[
cnt+0] = 1 + sub_octet;
519bits[
cnt+1] = 2 + sub_octet;
520bits[
cnt+2] = 3 + sub_octet;
524bits[
cnt+0] = 0 + sub_octet;
525bits[
cnt+1] = 1 + sub_octet;
526bits[
cnt+2] = 2 + sub_octet;
527bits[
cnt+3] = 3 + sub_octet;
537 #ifdef BM_NONSTANDARD_EXTENTIONS 545 unsignedbitscan_nibble_gcc(
unsignedw,
unsigned* bits)
BMNOEXCEPT 547 static void* d_table[] = { &&l0,
548&&l1, &&l3_1, &&l3, &&l7_1, &&l5, &&l7_0, &&l7, &&l15_1,
549&&l9, &&l11_0, &&l11, &&l15_0, &&l13, &&l14, &&l15 };
552 for(
unsignedsub_octet = 0; w; w >>= 4, sub_octet+=4)
554 goto*d_table[w & 15];
556bits[
cnt++] = sub_octet;
559bits[
cnt++] = sub_octet;
561bits[
cnt++] = 1 + sub_octet;
564bits[
cnt++] = sub_octet;
567bits[
cnt++] = sub_octet;
569bits[
cnt++] = 1 + sub_octet;
571bits[
cnt++] = 2 + sub_octet;
574bits[
cnt++] = sub_octet;
578bits[
cnt++] = sub_octet;
580bits[
cnt++] = 1 + sub_octet;
581bits[
cnt++] = 3 + sub_octet;
584bits[
cnt++] = sub_octet;
587bits[
cnt++] = 1 + sub_octet;
590bits[
cnt++] = 0 + sub_octet;
591bits[
cnt++] = 1 + sub_octet;
593bits[
cnt++] = 2 + sub_octet;
595bits[
cnt++] = 3 + sub_octet;
608 template<
typenameB>
622 bp_[0] = (
B)bit_idx0;
bp_[1] = (
B)bit_idx1;
630 bp_[0] = (
B)bit_idx0;
bp_[1] = (
B)bit_idx1;
bp_[2] = (
B)bit_idx2;
639 bp_[0] = (
B)bit_idx0;
bp_[1] = (
B)bit_idx1;
640 bp_[2] = (
B)bit_idx2;
bp_[3] = (
B)bit_idx3;
663dest[nword] |= unsigned(1u << nbit);
676dest[nword] &= ~(unsigned(1u << nbit));
690 return(block[nword] >> nbit) & 1u;
704 template<
typenameT,
typenameB>
709 return(
unsigned)(func.
ptr() - bits);
722 template<
typenameT,
typenameB>
727 return(
unsigned)(func.
ptr() - bits);
740 template<
typenameB>
751 return(
unsigned short)pos;
763 template<
typenameB>
773 return(
unsigned short)pos;
784 template<
typenameB>
787 unsigned shortpos = 0;
806 template<
typenameB>
809 unsigned shortpos = 0;
818 template<
typenameB,
typenameOT>
821 unsigned shortpos = 0;
839 template<
typenameB>
842 unsigned shortpos = 0;
860 template<
typenameB>
864 unsigned shortpos = 0;
878 template<
typenameV,
typenameB>
882 #if (defined(__arm__) || defined(__aarch64__)) 883 ifconstexpr (
sizeof(V) == 8)
888 ifconstexpr (
sizeof(V) == 8)
914 for(
unsigned count= 0; w; w >>=1ull, ++
count)
916rank -= unsigned(w & 1ull);
1006 unsigned t= w & -w;
1050 #if defined(BMI2_SELECT64) 1051 returnBMI2_SELECT64(w, rank);
1053 #if defined(BMI1_SELECT64) 1054 returnBMI2_SELECT64(w, rank);
1056 #if (defined(__arm__) || defined(__aarch64__)) 1077 #if defined(BMI2_SELECT64) 1078 returnBMI2_SELECT64(w, rank);
1080 #if defined(BMI1_SELECT64) 1081 returnBMI2_SELECT64(w, rank);
1083 #if (defined(__arm__) || defined(__aarch64__)) 1120 for(
unsigned i= from;
i<= to; ++
i)
1121m |= (1ull << (
i/ 1024));
1143((~0ull) >> (63 - (digest_to - digest_from))) << digest_from;
1165 unsignedbitpos_from,
unsignedbitpos_to)
BMNOEXCEPT 1168 return!(digest &
mask);
1185 boolcurr = digest &
mask;
1186 if(curr && curr !=
prev)
1204 for(
unsigned i= 0;
i< 64; ++
i)
1209 #if defined(VECT_BLOCK_SET_DIGEST) 1214block[off] = block[off+1] = block[off+2] = block[off+3] =
mask;
1235 for(
unsigned i= 0;
i< 64; ++
i)
1238 #if defined(VECT_IS_DIGEST_ZERO) 1245 bm::word_tw = block[off+j+0] | block[off+j+1] |
1246block[off+j+2] | block[off+j+3];
1249digest0 |= (
mask<<
i);
1285 #if defined(VECT_IS_DIGEST_ZERO) 1287digest &= all_zero ? ~(
mask<< wave) : digest;
1296src_u->w64[j+0] | src_u->w64[j+1] | src_u->w64[j+2] | src_u->w64[j+3];
1299digest &= w64 ? digest : ~(
mask<< wave);
1326 unsignedt_wave = 0;
1341 for(; sub_block < sub_block_end; t_sub_block+=4, sub_block+=4)
1343t_sub_block[0] = sub_block[0];
1344t_sub_block[1] = sub_block[1];
1345t_sub_block[2] = sub_block[2];
1346t_sub_block[3] = sub_block[3];
1363 for(; t_sub_block < t_sub_block_end; t_sub_block+=4)
1393 unsigneds_wave = 0;
1400 const bm::word_t* sub_block = block + s_off;
1407 for(; sub_block < sub_block_end; t_sub_block+=4, sub_block+=4)
1409t_sub_block[0] = sub_block[0];
1410t_sub_block[1] = sub_block[1];
1411t_sub_block[2] = sub_block[2];
1412t_sub_block[3] = sub_block[3];
1423 for(; t_sub_block < t_sub_block_end; t_sub_block+=4)
1425t_sub_block[0] = 0; t_sub_block[1] = 0;
1426t_sub_block[2] = 0; t_sub_block[3] = 0;
1442 return(
int(op) >=
int(
set_COUNT));
1475::memset(_p, 0xFF,
sizeof(_p));
1476 ifconstexpr (
sizeof(
void*) == 8)
1478 const unsigned long longmagic_mask = 0xFFFFfffeFFFFfffe;
1479::memcpy(&_p_fullp, &magic_mask,
sizeof(magic_mask));
1481_s[
i] =
reinterpret_cast<bm::word_t*
>(magic_mask);
1485 const unsignedmagic_mask = 0xFFFFfffe;
1486::memcpy(&_p_fullp, &magic_mask,
sizeof(magic_mask));
1488_s[
i] =
reinterpret_cast<bm::word_t*
>(magic_mask);
1499 ifconstexpr (
sizeof(
void*) == 8)
1501 bm::id64_tw =
reinterpret_cast<unsigned long long>(bp);
1508 unsignedw =
reinterpret_cast<unsigned long>(bp);
1536 template<
typenameN>
1545 const unsignedunroll_factor = 4;
1546 const unsigned len= (
size- start);
1547 const unsignedlen_unr =
len- (
len% unroll_factor);
1551 for(k = 0; k < len_unr; k+=unroll_factor)
1562*pos = k + start + 1;
1567*pos = k + start + 2;
1572*pos = k + start + 3;
1578 for(; k <
len; ++k)
1587 for(; start <
size; ++start)
1617 intres = (w1 & 1) - (w2 & 1);
1618 if(res != 0)
returnres;
1645 returndiff? ( (
a& diff & -diff)? 1 : -1 ) : 0;
1662 #if defined(VECT_IS_ZERO_BLOCK) 1669 if(blk[0] | blk[1] | blk[2] | blk[3])
1672}
while(blk < blk_end);
1727 template<
typenameT>
1731 returnglevel_len[(*
buf>> 1) & 3];
1743 template<
typenameT>
1747 returnglevel_len[(*
buf>> 1) & 3]-4;
1758 template<
typenameT>
1761 return T((*
buf>> 1) & 3u);
1775 template<
typenameT>
1781 Tis_set = (*buf) & 1u;
1782 Tend =
T((*
buf) >> 3u);
1786is_set ^=
T((end-1) & 1u);
1806 template<
typenameT>
1812 Tis_set = (*buf) & 1u;
1834 template<
typenameT>
1840 #if defined(VECT_GAP_BFIND) 1844 unsignedend = ((*buf) >> 3);
1846 unsigned size= end - start;
1847 for(;
size>= 64;
size= end - start)
1849 unsignedmid = (start + end) >> 1;
1850 if(
buf[mid] < pos)
1854 if(
buf[mid = (start + end) >> 1] < pos)
1858 if(
buf[mid = (start + end) >> 1] < pos)
1862 if(
buf[mid = (start + end) >> 1] < pos)
1868 for(;
size>= 16;
size= end - start)
1870 if(
unsignedmid = (start + end) >> 1;
buf[mid] < pos)
1874 if(
unsignedmid = (start + end) >> 1;
buf[mid] < pos)
1880 for(;
true; ++start)
1881 if(
buf[start] >= pos)
1884*is_set = ((*buf) & 1) ^ ((start-1) & 1);
1899 template<
typenameT>
1905 unsignedend = 1 + ((*buf) >> 3);
1906 if(end - start < 10)
1908 unsignedsv = *
buf& 1;
1909 unsignedsv1= sv ^ 1;
1910 if(
buf[1] >= pos)
returnsv;
1911 if(
buf[2] >= pos)
returnsv1;
1912 if(
buf[3] >= pos)
returnsv;
1913 if(
buf[4] >= pos)
returnsv1;
1914 if(
buf[5] >= pos)
returnsv;
1915 if(
buf[6] >= pos)
returnsv1;
1916 if(
buf[7] >= pos)
returnsv;
1917 if(
buf[8] >= pos)
returnsv1;
1926 if(
unsignedmid = (start + end) >> 1;
buf[mid] < pos)
1930}
while(start != end);
1932 return((*
buf) & 1) ^ ((--start) & 1);
1942 template<
typenameT>
1948 #if defined(VECT_GAP_TEST) 1960 template<
typenameT,
typenameN,
typenameF>
1965 if(nb_from > nb_to)
1972 if(i_from >= top_size)
1974 if(i_to >= top_size)
1976i_to = unsigned(top_size-1);
1980 for(
unsigned i= i_from;
i<= i_to; ++
i)
1982 T** blk_blk = root[
i];
1987 unsignedj = (
i== i_from) ? j_from : 0;
1988 if(!j && (
i!= i_to))
1995 if((
i== i_to) && (j == j_to))
2002 unsignedj = (
i== i_from) ? j_from : 0;
2007 if((
i== i_to) && (j == j_to))
2017 template<
classT,
classF>
2020 typedef typenameF::size_type size_type;
2021 for(
unsigned i= 0;
i< size1; ++
i)
2023 T** blk_blk = root[
i];
2026 f.on_empty_top(
i);
2029 f.on_non_empty_top(
i);
2041 unsignednon_empty_top = 0;
2046 #if defined(BM64_AVX2) || defined(BM64_AVX512) 2050 T* blk0 = blk_blk[j + 0];
2051 T* blk1 = blk_blk[j + 1];
2052 T* blk2 = blk_blk[j + 2];
2053 T* blk3 = blk_blk[j + 3];
2055size_type block_idx =
r+ j + 0;
2057 f(blk0, block_idx);
2059 f.on_empty_block(block_idx);
2062 f(blk1, block_idx + 1);
2064 f.on_empty_block(block_idx + 1);
2067 f(blk2, block_idx + 2);
2069 f.on_empty_block(block_idx + 2);
2072 f(blk3, block_idx + 3);
2074 f.on_empty_block(block_idx + 3);
2078 f.on_empty_block(
r+ j + 0);
f.on_empty_block(
r+ j + 1);
2079 f.on_empty_block(
r+ j + 2);
f.on_empty_block(
r+ j + 3);
2082 #elif defined(BM64_SSE4) 2086 T* blk0 = blk_blk[j + 0];
2087 T* blk1 = blk_blk[j + 1];
2089size_type block_idx =
r+ j + 0;
2091 f(blk0, block_idx);
2093 f.on_empty_block(block_idx);
2097 f(blk1, block_idx);
2099 f.on_empty_block(block_idx);
2103 f.on_empty_block(
r+ j + 0);
2104 f.on_empty_block(
r+ j + 1);
2110 f(blk_blk[j],
r+ j);
2114 f.on_empty_block(
r+ j);
2119 if(non_empty_top == 0)
2120 f.on_empty_top(
i);
2126 template<
classT,
classF>
2130 for(
unsigned i= 0;
i< size1; ++
i)
2133 if((blk_blk = root[
i])!=0)
2150 T* blk0 = blk_blk[j + 0];
2151 T* blk1 = blk_blk[j + 1];
2161 T* blk0 = blk_blk[j + 2];
2162 T* blk1 = blk_blk[j + 3];
2172 #elif defined(BM64_AVX2) || defined(BM64_AVX512) 2173 for(
unsigned i= 0;
i< size1; ++
i)
2176 if((blk_blk = root[
i]) != 0)
2189__m256i w0 = _mm256_loadu_si256((__m256i*)(blk_blk + j));
2190 if(!_mm256_testz_si256(w0, w0))
2194 T* blk0 = blk_blk[j + 0];
2195 T* blk1 = blk_blk[j + 1];
2196 T* blk2 = blk_blk[j + 2];
2197 T* blk3 = blk_blk[j + 3];
2213 for(
unsigned i= 0;
i< size1; ++
i)
2216 if((blk_blk = root[
i])!=0)
2248 template<
typenameT,
typenameBI,
typenameF>
2252 for(BI
i= 0;
i< size1; ++
i)
2254 T** blk_blk = root[
i];
2273 if(
f(blk_blk[j], block_idx))
2282 template<
classT,
classF,
typenameBLOCK_IDX>
2285BLOCK_IDX block_idx = start;
2286 for(
unsigned i= 0;
i< size1; ++
i)
2288 T** blk_blk = root[
i];
2301 f(blk_blk[j], block_idx);
2330 template<
typenameT>
2349 template<
typenameT>
2358 for(
unsigned i= 1;
i< arr_len; ++
i)
2388 template<
typenameT>
2395 if(arr_len <= wlen)
2397 unsignedmin_w_prev = ~0u;
2399 for(
unsigned i= 1;
i< wlen; ++
i)
2403min_w_prev =
delta;
2405min_w_prev -=
bool(min_w_prev);
2409 for(
unsigned i= wlen;
i< arr_len; ++wave,
i+=wlen)
2411 if(
i+ wlen > arr_len)
2413 unsigned r= arr_len % wlen;
2418 unsignedmin_w = ~0u;
2419 for(
unsignedj = 0; j < wlen; ++j)
2424 if(
delta<= min_w_prev)
2432 if(min_w_prev && (min_w > min0))
2439min_w_prev = (min_w > min0) ? min_w - 1 : min0;
2449 template<
typenameT>
2460 Tmin_w_prev =
T(~0u);
2462 for(
unsigned i= 1;
i< wlen; ++
i)
2467min_w_prev =
delta;
2471tarr[
i] =
arr[
i] - min0 - delta_acc;
2475min_w_prev -=
bool(min_w_prev);
2478 for(
unsignedwave = 1,
i=wlen;
i< arr_len;
i+=wlen, ++wave)
2480 if(
i+ wlen > arr_len)
2482 unsigned r= arr_len % wlen;
2488 for(
unsignedj = 0; j < wlen; ++j)
2497tarr[
i+j] =
arr[
i+j] - min_w_prev - delta_acc;
2498delta_acc += min_w_prev;
2502tarr[
i+j] =
arr[
i+j] - min0 - delta_acc;
2507min_w_prev = (min_w > min0) ? min_w - 1 : min0;
2516 template<
typenameT>
2526 unsignedmin_w_prev = ~0u;
2528 for(
unsigned i= 1;
i< wlen; ++
i)
2531 arr[
i] += min0 + delta_acc;
2537min_w_prev =
delta;
2541min_w_prev -=
bool(min_w_prev);
2545 for(
unsigned i= wlen;
i< arr_len; ++wave,
i+=wlen)
2547 if(
i+ wlen > arr_len)
2549 unsigned r= arr_len % wlen;
2554 unsignedmin_w = ~0u;
2555 for(
unsignedj = 0; j < wlen; ++j)
2559 arr[
i+j] += (
T)(min_w_prev + delta_acc);
2560delta_acc += (
T)min_w_prev;
2564 arr[
i+j] += min0 + delta_acc;
2571min_w_prev = (min_w > min0) ? min_w - 1 : min0;
2583 template<
typenameT>
2585 unsigned* hist,
unsignedhist_len)
BMNOEXCEPT 2588 for(
unsigned i= 1;
i< arr_len; ++
i)
2594 if(
delta< hist_len)
2604 template<
typenameT>
2606 T* arr_dst,
unsigned& dst_len,
2607 const T*
arr,
unsignedarr_len,
2612d1_len = dst_len = 0;
2613arr_dst[dst_len] =
arr[dst_len];
2616 for(
unsigned i= 1;
i< arr_len; ++
i)
2620 if(
delta<= ex_max_delta)
2621arr_d1[d1_len++] =
arr[
i];
2623arr_dst[dst_len++] =
arr[
i];
2631 template<
typenameT>
2634tarr[0] =
arr[0] - delta_acc;
2635 for(
unsigned i= 1;
i< arr_len; ++
i)
2637tarr[
i] =
arr[
i] - min0 - delta_acc;
2647 template<
typenameT>
2650 arr[0] =
arr[0] + delta_acc;
2651 for(
unsigned i= 1;
i< arr_len; ++
i)
2653 arr[
i] += min0 + delta_acc;
2665 template<
typenameT>
2668 const T* pcurr =
buf;
2669 autodsize = (*pcurr >> 3);
2671 const T* pend = pcurr + dsize;
2676 for(++pcurr; pcurr <= pend; pcurr++)
2678 T delta= *pcurr - *(pcurr-1);
2684 delta= *pcurr - *(pcurr-1);
2702 template<
typenameT>
2704 unsigned* hist0,
unsigned* hist1,
unsignedhist_len
2707 const T* pcurr =
buf;
2710 unsignedis_set = (*pcurr & 1u);
2712 const T* pend = pcurr + dsize;
2716 if(
delta< hist_len)
2721 for(++pcurr; pcurr <= pend; pcurr++, is_set ^= 1u)
2723 delta= *pcurr - *(pcurr-1);
2724 if(
delta< hist_len)
2728++pcurr; is_set ^= 1u;
2731 delta= *pcurr - *(pcurr-1);
2732 if(
delta< hist_len)
2741 template<
typenameT>
2790 template<
typenameT>
2793 const unsigned* hist0,
const unsigned* hist1,
2794 T* tbuf,
T* ex0_arr,
T* ex1_arr,
2795 unsigned& ex0_cnt,
unsigned& ex1_cnt)
BMNOEXCEPT 2797 boolex0_first =
true;
2798ex0_cnt = ex1_cnt = 0;
2799 unsigneddsize =
len;
2801::memcpy(tbuf,
buf, (1+dsize) *
sizeof(
T));
2804 for(
T i= 1;
i< h_limit; ++
i)
2806 unsignedex0_cnt_s {ex0_cnt}, ex1_cnt_s {ex1_cnt};
2808 boolh0_flag{0}, h1_flag{0};
2809 if(hist0[
i] < hist1[
i])
2819 if(hist0[
i] == 0)
2823 const T* pcurr = tbuf+1;
2824dsize = (*tbuf >> 3);
2825 const T* pend = pcurr + dsize;
2826 unsignedis_set = (*tbuf & 1u);
2829 if(
delta<
i&& !is_set)
2830 for(
unsignedj = 0; j <= *pcurr; ++j)
2831ex0_arr[ex0_cnt++] = (
T)j;
2832 for(++pcurr, is_set ^= 1u; pcurr <= pend; ++pcurr,is_set ^= 1u)
2834 delta= *pcurr - *(pcurr-1);
2835 if(
delta<=
i&& !is_set)
2836 for(
unsignedj = *(pcurr-1)+1; j <= *pcurr; ++j)
2837ex0_arr[ex0_cnt++] = (
T)j;
2839++pcurr; is_set ^= 1u;
2842 delta= *pcurr - *(pcurr-1);
2843 if(
delta<=
i&& !is_set)
2844 for(
unsignedj = *(pcurr-1)+1; j <= *pcurr; ++j)
2845ex0_arr[ex0_cnt++] = (
T)j;
2848 autonew_len = dsize;
2849 for(
unsignedk = ex0_cnt_s; k < ex0_cnt; ++k)
2867 if(hist1[
i] == 0)
2871 const T* pcurr = tbuf+1;
2873 const T* pend = pcurr + (*tbuf >> 3);
2874 unsignedis_set = (*tbuf & 1u);
2877 if(
delta<
i&& is_set)
2878 for(
unsignedj = 0; j <= *pcurr; ++j)
2879ex1_arr[ex1_cnt++] = (
T)j;
2881 for(++pcurr; pcurr <= pend; ++pcurr,is_set ^= 1u)
2883 delta= *pcurr - *(pcurr-1);
2884 if(
delta<=
i&& is_set)
2885 for(
unsignedj = *(pcurr-1)+1; j <= *pcurr; ++j)
2886ex1_arr[ex1_cnt++] = (
T)j;
2888++pcurr; is_set ^= 1u;
2891 delta= *pcurr - *(pcurr-1);
2892 if(
delta<=
i&& is_set)
2893 for(
unsignedj = *(pcurr-1)+1; j <= *pcurr; ++j)
2894ex1_arr[ex1_cnt++] = (
T)j;
2897 autonew_len = dsize;
2898 for(
unsignedk = ex1_cnt_s; k < ex1_cnt; ++k)
2904 BM_ASSERT(dsize >= new_len); (void) new_len;
2925 unsignedex_limit,
unsigned* ex_sum)
BMNOEXCEPT 2930 for(
i= 0; (
i< hist_len) && (*ex_sum < ex_limit); ++
i)
2932*ex_sum += hist0[
i] + hist1[
i];
2945 template<
typenameT>
2948 const T* pcurr =
buf;
2949 autodsize = (*pcurr >> 3);
2950 const T* pend = pcurr + dsize;
2957 T prev= *tcurr = (*pcurr - min0); (void)
prev;
2961 for(; pcurr <= pend; )
2972 prev= *tcurr = *pcurr - min1 - delta_acc;
2979 prev= *tcurr = *pcurr - min0 - delta_acc;
2999 template<
typenameT>
3003 autodsize = (*pcurr >> 3);
3004 const T* pend = pcurr + dsize;
3008*pcurr = (*pcurr + min0);
3011 for(++pcurr; pcurr <= pend; )
3019*pcurr = *pcurr + min1 + delta_acc;
3024*pcurr = *pcurr + min0 + delta_acc;
3042 template<
typenameT>
3045 const T* pcurr =
buf;
3047dsize = (*pcurr >> 3);
3048 const T* pend = pcurr + dsize;
3053 for(; pcurr <= pend; pcurr++)
3069 template<
typenameT>
3072 const T* pcurr =
buf;
3074dsize = (*pcurr >> 3);
3076 const T* pend = pcurr + dsize;
3078 unsignedbits_counter = 0;
3083bits_counter += *pcurr + 1;
3086 for(++pcurr; pcurr <= pend; pcurr += 2)
3087bits_counter += *pcurr - *(pcurr-1);
3088 returnbits_counter;
3097 template<
typenameT>
3100 const T* pcurr =
buf;
3101 unsigneddsize = (*pcurr >> 3);
3105 Tfirst_one = *
buf& 1;
3113 #if defined(BMAVX2OPT) || defined(BMAVX512OPT) 3116 const unsignedunr_factor = 32;
3117 unsignedwaves = (dsize-2) / unr_factor;
3120 #elif defined(BMSSE42OPT) || defined(BMSSE2OPT) 3123 const unsignedunr_factor = 16;
3124 unsignedwaves = (dsize - 2) / unr_factor;
3130 const unsignedunr_factor = 8;
3131 unsignedwaves = (dsize - 2) / unr_factor;
3132 for(
unsigned i= 0;
i< waves;
i+= unr_factor)
3134 cnt+= pcurr[0] - pcurr[0 - 1];
3135 cnt+= pcurr[2] - pcurr[2 - 1];
3136 cnt+= pcurr[4] - pcurr[4 - 1];
3137 cnt+= pcurr[6] - pcurr[6 - 1];
3139pcurr += unr_factor;
3144 const T* pend =
buf+ dsize;
3145 for( ; pcurr <= pend ; pcurr+=2)
3146 cnt+= *pcurr - *(pcurr - 1);
3163 template<
typenameT,
boolRIGHT_END = false>
3170 unsignedis_set, bits_counter, prev_gap;
3172is_set = ~(is_set - 1u);
3174 const T* pcurr =
buf+ start_pos;
3175 if(right <= *pcurr)
3176bits_counter = unsigned(right - left + 1u) & is_set;
3179bits_counter = unsigned(*pcurr - left + 1u) & is_set;
3180 ifconstexpr (RIGHT_END)
3183 for(prev_gap = *pcurr++ ;
true; prev_gap = *pcurr++)
3185bits_counter += (is_set ^= ~0u) & (*pcurr - prev_gap);
3192 for(prev_gap = *pcurr++; right > *pcurr; prev_gap = *pcurr++)
3193bits_counter += (is_set ^= ~0u) & (*pcurr - prev_gap);
3194bits_counter += unsigned(right - prev_gap) & (is_set ^ ~0u);
3197 returnbits_counter;
3206 template<
typenameT>
3208 const unsignedstart_pos,
3211 unsignedis_set_c, pos;
3213 bool r= (pos == (start_pos) &&
bool(is_set) ==
bool(is_set_c));
3214 BM_ASSERT(
bool(is_set) ==
bool(is_set_c));
3230 template<
typenameT>
3232 unsignedleft,
unsignedright,
unsignedhint)
BMNOEXCEPT 3237 unsignedis_set, bits_counter, prev_gap;
3241is_set = ~(is_set - 1u);
3242 unsignedstart_pos = hint >> 1;
3254 const T* pcurr =
buf+ start_pos;
3255 if(right <= *pcurr)
3256bits_counter = unsigned(right - left + 1u) & is_set;
3259bits_counter = unsigned(*pcurr - left + 1u) & is_set;
3260 for(prev_gap = *pcurr++; right > *pcurr; prev_gap = *pcurr++)
3261bits_counter += (is_set ^= ~0u) & (*pcurr - prev_gap);
3262bits_counter += unsigned(right - prev_gap) & (is_set ^ ~0u);
3264 returnbits_counter;
3276 template<
typenameT>
3287 const T*
constpcurr =
buf+ start_pos;
3288 return(right <= *pcurr);
3299 template<
typenameT>
3308 const T*
constpcurr =
buf+ start_pos;
3312 if(right <= *pcurr)
3328 template<
typenameT>
3339 const T* pcurr =
buf+ start_pos;
3340 if(!is_set || (right != *pcurr) || (start_pos <= 1))
3343 if(*pcurr != left-1)
3357 template<
typenameT>
3368*pos =
buf[start_pos];
3382 template<
typenameT>
3397*pos =
buf[start_pos]+1;
3410 template<
typenameT>
3428*pos =
buf[start_pos];
3447 template<
typenameT,
typenameSIZE_TYPE>
3456 const T* pcurr = block;
3457 const T* pend = pcurr + (*pcurr >> 3);
3459 unsignedbits_counter = 0;
3461 unsignedstart_pos =
bm::gap_bfind(block, nbit_from, &is_set);
3462is_set = ~(is_set - 1u);
3464pcurr = block + start_pos;
3465bits_counter += unsigned(*pcurr - nbit_from + 1u) & is_set;
3466 if(bits_counter >= rank)
3468nbit_pos = nbit_from + unsigned(rank) - 1u;
3471rank -= bits_counter;
3472 unsignedprev_gap = *pcurr++;
3473 for(is_set ^= ~0u; pcurr <= pend; is_set ^= ~0u)
3475bits_counter = (*pcurr - prev_gap) & is_set;
3476 if(bits_counter >= rank)
3478nbit_pos = prev_gap + unsigned(rank);
3481rank -= bits_counter;
3482prev_gap = *pcurr++;
3489 template<
typenameT,
boolTCORRECT=false>
3494 unsignedbits_counter, prev_gap;
3496 unsignedis_set = ~((unsigned(*
buf) & 1u) - 1u);
3497 const T* pcurr =
buf+ 1;
3498 if(right <= *pcurr)
3500bits_counter = (right + 1u) & is_set;
3504bits_counter = (*pcurr + 1u) & is_set;
3505prev_gap = *pcurr++;
3506 for(is_set ^= ~0u; right > *pcurr; is_set ^= ~0u, prev_gap = *pcurr++)
3508bits_counter += (*pcurr - prev_gap) & is_set;
3512bits_counter += (right - prev_gap) & is_set;
3516 ifconstexpr (TCORRECT)
3517bits_counter -= (is_set & unsigned(TCORRECT));
3518 returnbits_counter;
3532 template<
classT,
classFunc>
3535 const T* pcurr = gap_buf;
3536 const T* pend = pcurr + (*pcurr >> 3);
3540func((
T)(
prev+ 1));
3544func((
T)(*pcurr -
prev));
3546}
while(++pcurr < pend);
3573 template<
typenameT>
3579*dgap_buf++ = *gap_buf;
3583for_each_dgap<T, d_copy_func<T> >(gap_buf, copy_func);
3599 template<
typenameT>
3603 const T* pcurr = dgap_buf;
3608*gap_buf++ = *pcurr++;
3612 len= gap_header >> 3;
3613*gap_buf++ = gap_header;
3616 const T* pend = pcurr +
len;
3618*gap_buf = *pcurr++;
3622*gap_buf =
T(*gap_buf - 1);
3624 for(++gap_buf; pcurr < pend; ++pcurr)
3626 T prev= *(gap_buf-1);
3627*gap_buf++ =
T(*pcurr +
prev);
3641 template<
typenameT>
3644 const T* pcurr1 = buf1;
3645 const T* pend1 = pcurr1 + (*pcurr1 >> 3);
3646 unsignedbitval1 = *buf1 & 1;
3649 const T* pcurr2 = buf2;
3650 unsignedbitval2 = *buf2 & 1;
3653 while(pcurr1 <= pend1)
3655 if(*pcurr1 == *pcurr2)
3657 if(bitval1 != bitval2)
3659 return(bitval1) ? 1 : -1;
3664 if(bitval1 == bitval2)
3668 return(*pcurr1 < *pcurr2) ? -1 : 1;
3672 return(*pcurr1 < *pcurr2) ? 1 : -1;
3677 return(bitval1) ? 1 : -1;
3697 template<
typenameT>
3704 const T* pcurr1 = buf1;
3705 const T* pend1 = pcurr1 + (*pcurr1 >> 3);
3706 const T* pcurr2 = buf2;
3707 for(++pcurr1, ++pcurr2; pcurr1 <= pend1; ++pcurr1, ++pcurr2)
3709 if(*pcurr1 != *pcurr2)
3711*pos = 1 + ((*pcurr1 < *pcurr2) ? *pcurr1 : *pcurr2);
3737 template<
typenameT,
classF>
3740 unsignedvect1_mask,
3742 unsignedvect2_mask,
3745 const T* cur1 = vect1;
3746 const T* cur2 = vect2;
3748 Tbitval1 = (
T)((*cur1++ & 1) ^ vect1_mask);
3749 Tbitval2 = (
T)((*cur2++ & 1) ^ vect2_mask);
3751 Tbitval = (
T) F::op(bitval1, bitval2);
3752 Tbitval_prev = bitval;
3758 Tc1 = *cur1;
Tc2 = *cur2;
3761bitval = (
T) F::op(bitval1, bitval2);
3766res += (bitval != bitval_prev);
3767bitval_prev = bitval;
3787bitval1 ^= 1; bitval2 ^= 1;
3793dlen = (unsigned)(res - dest);
3794*dest = (
T)((*dest & 7) + (dlen << 3));
3812 template<
typenameT,
classF>
3814 unsignedvect1_mask,
3818 const T* cur1 = vect1;
3819 const T* cur2 = vect2;
3821 unsignedbitval1 = (*cur1++ & 1) ^ vect1_mask;
3822 unsignedbitval2 = (*cur2++ & 1) ^ vect2_mask;
3824 unsignedbitval = F::op(bitval1, bitval2);
3827 unsignedbitval_prev = bitval;
3831bitval = F::op(bitval1, bitval2);
3835 if(bitval != bitval_prev)
3836bitval_prev = bitval;
3856bitval1 ^= 1; bitval2 ^= 1;
3877 template<
typenameT,
classF>
3881 const T* cur1 = vect1;
3882 const T* cur2 = vect2;
3884 unsignedbitval1 = (*cur1++ & 1);
3885 unsignedbitval2 = (*cur2++ & 1);
3886 unsignedbitval =
count= F::op(bitval1, bitval2);
3887 unsignedbitval_prev = bitval;
3894bitval = F::op(bitval1, bitval2);
3897 if(bitval != bitval_prev)
3899bitval_prev = bitval;
3908 count+= res - res_prev;
3911++cur1; bitval1 ^= 1;
3918 count+= res - res_prev;
3931bitval1 ^= 1; bitval2 ^= 1;
3943 #pragma GCC diagnostic push 3944 #pragma GCC diagnostic ignored "-Wconversion" 3961 template<
typenameT>
3968 Tend = (
T)(*
buf>> 3);
3969 if(*is_set ==
val)
3976 T* pcurr =
buf+ curr;
3977 T* pprev = pcurr - 1;
3978 T* pend =
buf+ end;
3993pprev =
buf+ 1; pcurr = pprev + 1;
3998 if(curr > 1 && ((
unsigned)(*pprev))+1 == pos)
4001 if(*pprev == *pcurr)
4009 do{ *pprev++ = *pcurr++; }
while(pcurr < pend);
4017end += (pcurr == pend);
4022 ::memmove(pcurr+2, pcurr, (end - curr + 1)*(
sizeof(
T)));
4024pcurr[0] = (
T)(pos-1);
4025pcurr[1] = (
T)pos;
4029*
buf= (
T)((*
buf& 7) + (end << 3));
4047 template<
typenameT>
4074 template<
typenameT>
4082 Tend = (
T) (*
buf>> 3);
4086 T* pcurr =
buf+ curr;
4087 T* pprev = pcurr - 1;
4088 T* pend =
buf+ end;
4103pprev =
buf+ 1; pcurr = pprev + 1;
4108 if(curr > 1 && ((
unsigned)(*pprev))+1 == pos)
4111 if(*pprev == *pcurr)
4119 do{ *pprev++ = *pcurr++; }
while(pcurr < pend);
4127end += (pcurr == pend);
4132 ::memmove(pcurr+2, pcurr, (end - curr + 1)*(
sizeof(
T)));
4134pcurr[0] = (
T)(pos-1);
4135pcurr[1] = (
T)pos;
4139*
buf= (
T)((*
buf& 7) + (end << 3));
4152 template<
typenameT>
4157 Tend = (
T)(*
buf>> 3);
4159 T* pcurr =
buf+ end;
4161 T* pprev = pcurr - 1;
4176pprev =
buf+ 1; pcurr = pprev + 1;
4178 do{ *pprev++ = *pcurr++; }
while(pcurr < pend);
4181 else if(((
unsigned)(*pprev))+1 == pos && (curr > 1) )
4184 if(*pprev == *pcurr)
4190 else if(*pcurr == pos)
4193end += (pcurr == pend);
4197pcurr[0] = (
T)(pos-1);
4198pcurr[1] = (
T)pos;
4203*
buf= (
T)((*
buf& 7) + (end << 3));
4209 #pragma GCC diagnostic pop 4222 template<
typenameT>
4229 boolco, gap_set_flag;
4230 unsigned len= (*
buf>> 3);
4233 unsignedbitval = *
buf& 1;
4234gap_set_flag = (bitval != co_flag);
4240 for(;
i<
len; ++
i)
4275 template<
typenameT>
4282 boolco, gap_set_flag;
4287gap_set_flag = (
val!= is_set);
4288 unsigned len= (*
buf>> 3);
4298 for(;
i<
len; ++
i)
4331 template<
typenameT>
4342 unsignedbitval = *
buf& 1;
4364 unsigned len= (*
buf>> 3);
4366 for(;
i<
len; ++
i)
4392 template<
typenameT>
4395*
buf= (
T)((*
buf& 6u) + (1u << 3));
4397 T* pcurr =
buf+ 1;
4403*pcurr = (
T)(curr - 1);
4413 for(
i= 1;
i<
len; ++
i)
4416 if(curr ==
prev+ 1)
4425*pcurr++ = (
T)(curr-1);
4436 unsignedgap_len = unsigned(pcurr -
buf);
4437 BM_ASSERT(gap_len == ((gap_len << 3) >> 3));
4439*
buf= (
T)((*
buf& 7) + (gap_len << 3));
4453 template<
typenameT>
4456 unsignedgap_count = 1;
4460 for(
unsigned i= 1;
i<
len; ++
i)
4463 if(curr !=
prev+ 1)
4485 template<
typenameT>
4500 unsigned val=
buf[gap_idx] + 1;
4520 const unsignedmaskFF = ~0u;
4527*dest |= (1u << bitpos);
4532 unsignedmask_r = maskFF << bitpos;
4533 if(
unsignedright_margin = bitpos + bitcount; right_margin < 32)
4535*dest |= (maskFF >> (32 - right_margin)) & mask_r;
4539bitcount -= 32 - bitpos;
4541 for( ;bitcount >= 64; bitcount-=64, dest+=2)
4542dest[0] = dest[1] = maskFF;
4544{ *dest++ = maskFF; bitcount -= 32; }
4546*dest |= (maskFF >> (32 - bitcount));
4567*dest &= ~(bitcount << bitpos);
4570 const unsignedmaskFF = ~0u;
4573 unsignedmask_r = maskFF << bitpos;
4574 if(
unsignedright_margin = bitpos + bitcount; right_margin < 32)
4576*dest &= ~((maskFF >> (32 - right_margin)) & mask_r);
4580bitcount -= 32 - bitpos;
4582 for( ;bitcount >= 64; bitcount-=64, dest+=2)
4583dest[0] = dest[1] = 0u;
4586*dest++ = 0u; bitcount -= 32;
4589*dest &= ~(maskFF >> (32 - bitcount));
4614*word ^= unsigned(1 << nbit);
4620 unsignedright_margin = nbit + bitcount;
4625 if(right_margin < 32)
4629 unsigned mask= mask_r & mask_l;
4634bitcount -= 32 - nbit;
4637 for( ;bitcount >= 64; bitcount-=64, word+=2)
4639word[0] ^= ~0u; word[1] ^= ~0u;
4643*word++ ^= ~0u; bitcount -= 32;
4659 template<
typenameT>
4665 const T* pend = pcurr + (*pcurr >> 3);
4671 for(pcurr += 2; pcurr <= pend; pcurr += 2)
4690 template<
typenameT>
4697 const unsigned len= (*pcurr >> 3);
4716 unsignedfound_pos =
bm::gap_bfind(pbuf, start_pos, &is_set);
4719found_pos += !is_set;
4720pcurr = pbuf + found_pos;
4722 BM_ASSERT(pcurr > pend || *pcurr >= start_pos);
4726 for(; pcurr <= pend; pcurr += 2)
4727 if(*pcurr >= start_pos)
4735 for(
T prev; pcurr <= pend; pcurr += 2)
4739 unsignedpos = 1u +
prev;
4758 template<
typenameT>
4764 const T* pend = pcurr + (*pcurr >> 3);
4770 for(pcurr += 2; pcurr <= pend; pcurr += 2)
4786 template<
typenameT>
4792 const T* pend = pcurr +
len;
4803 for(; pcurr <= pend; )
4806pos = 1u + pcurr[-1];
4807bc = *pcurr - pcurr[-1];
4821 template<
typenameT>
4825 unsigned len= (*pcurr >> 3);
4837 template<
typenameT>
4843 const T* pend = pcurr + (*pcurr >> 3);
4853 for(; pcurr <= pend; )
4856pos = 1u + pcurr[-1];
4857bc = *pcurr - pcurr[-1];
4874 template<
typenameT>
4882 const unsigned len= (*pcurr >> 3);
4901 unsignedfound_pos =
bm::gap_bfind(pbuf, start_pos, &is_set);
4904found_pos += is_set;
4905pcurr = pbuf + found_pos;
4907 BM_ASSERT(pcurr > pend || *pcurr >= start_pos);
4911 for(; pcurr <= pend; pcurr += 2)
4912 if(*pcurr >= start_pos)
4921 for(
T prev; pcurr <= pend; pcurr += 2)
4925 unsignedpos = 1u +
prev;
4945 template<
typenameT>
4950 const T* pend = pcurr + (*pcurr >> 3);
4957 for(pcurr +=2 ;pcurr <= pend; pcurr += 2)
4973 template<
typenameT>
4979 const T* pend = pcurr + (*pcurr >> 3);
4986 for(pcurr +=2 ;!
count&& pcurr <= pend; pcurr += 2)
5003 template<
typenameT>
5009 const T* pcurr =
buf;
5010 const T* pend = pcurr + (*pcurr >> 3);
5022 for(;pcurr <= pend; pcurr+=2)
5038 template<
typenameT>
5044 const T* pcurr =
buf;
5045 const T* pend = pcurr + (*pcurr >> 3);
5059 for(; !
count&& pcurr <= pend; pcurr+=2)
5076 template<
typenameT>
5082 const T* pcurr =
buf;
5083 const T* pend = pcurr + (*pcurr >> 3);
5086 unsignedbitval = *
buf& 1;
5094 for(bitval^=1, ++pcurr; pcurr <= pend; bitval^=1, ++pcurr)
5096 T prev= (
T)(*(pcurr-1)+1);
5100c = (*pcurr -
prev+ 1) - c;
5114 template<
typenameT>
5120 const T* pcurr =
buf;
5121 const T* pend = pcurr + (*pcurr >> 3);
5124 unsignedbitval = *
buf& 1;
5130 for(bitval^=1, ++pcurr; !
count&& pcurr <= pend; bitval^=1, ++pcurr)
5132 T prev= (
T)(*(pcurr-1)+1);
5136c = (*pcurr -
prev+ 1) - c;
5152 template<
typenameT>
5157 const T* pcurr =
buf;
5158 const T* pend = pcurr + (*pcurr >> 3);
5161 unsignedbitval = *
buf& 1;
5165 for(bitval^=1, ++pcurr; pcurr <= pend; bitval^=1, ++pcurr)
5167 T prev= (
T)(*(pcurr-1)+1);
5169bitval ? (*pcurr -
prev+ 1)
5184 template<
typenameT>
5222 template<
typenameT>
5247 template<
typenameT>
5252 if(
buf[1] == set_max - 1)
5268 template<
typenameT>
5271 unsignedend = *
buf>> 3;
5273 const T* pcurr =
buf;
5274 const T* pend = pcurr + (*pcurr >> 3);
5282 while(pcurr <= pend)
5304*(++
buf) = (
T)(set_max - 1);
5329 if(to == set_max - 1)
5337 buf[2] = (
T)(set_max - 1);
5338 buf[0] = (
T)((*
buf& 6u) + (gap_len << 3) +
value);
5345 if(to == set_max - 1)
5348 buf[1] = (
T)(from - 1);
5349 buf[2] = (
T)(set_max - 1);
5354 buf[1] = (
T) (from - 1);
5356 buf[3] = (
T)(set_max - 1);
5358 buf[0] = (
T)((*
buf& 6u) + (gap_len << 3) +
value);
5375 #pragma GCC diagnostic push 5376 #pragma GCC diagnostic ignored "-Wconversion" 5386 template<
typenameT>
5392*
buf= (
T)(((level & 3) << 1) | (*
buf& 1) | (*
buf& ~7));
5395 #pragma GCC diagnostic pop 5408 template<
typenameT>
5411 if(
len<=
unsigned(glevel_len[0]-4))
return0;
5412 if(
len<=
unsigned(glevel_len[1]-4))
return1;
5413 if(
len<=
unsigned(glevel_len[2]-4))
return2;
5414 if(
len<=
unsigned(glevel_len[3]-4))
return3;
5429 template<
typenameT>
5435 returncapacity -
len;
5447 template<
typenameT>
5451 const T* pend1 = buf1 +
len;
5458 return(w1 & diff & -diff) ? 1 : -1;
5459}
while(buf1 < pend1);
5478 #ifdef VECT_BIT_FIND_DIFF 5498*pos = unsigned(idx + (
i* 8u *
unsigned(
sizeof(
bm::wordop_t))));
5510*pos = unsigned(idx + (
i* 8u *
sizeof(
bm::word_t)));
5541 unsignedbitval = (*block) & 1u;
5544 unsignedbit_idx = 0;
5548 unsigned val= *block;
5549 while(!
val||
val== ~0u)
5551 if(bitval !=
unsigned(
bool(
val)))
5555 BM_ASSERT((pcurr-1) == (dest+1) || *(pcurr-1) > *(pcurr-2));
5558bit_idx += unsigned(
sizeof(*block) * 8);
5559 if(++block >= block_end)
5566 unsignedbits_consumed = 0;
5570 if(bitval != (
val& 1u))
5574 BM_ASSERT((pcurr-1) == (dest+1) || *(pcurr-1) > *(pcurr-2));
5584bits_consumed += tz;
5590 if(bits_consumed < 32u)
5594bit_idx += 32u - bits_consumed;
5595 BM_ASSERT((pcurr-1) == (dest+1) || *(pcurr-1) > *(pcurr-2));
5602}
while(++block < block_end);
5606 unsigned len= (unsigned)(pcurr - dest);
5622 #if defined(VECT_BIT_TO_GAP) 5634 template<
classT,
classF>
5637 const T* pcurr =
buf;
5638 const T* pend = pcurr + (*pcurr >> 3);
5648 unsignedto = *pcurr;
5649 for(
unsigned i= 0;
i<= to; ++
i)
5662 while(pcurr <= pend)
5664 unsignedfrom = *(pcurr-1)+1;
5665 unsignedto = *pcurr;
5668func(from -
prev+ first_inc);
5676 for(
unsigned i= from+1;
i<= to; ++
i)
5689 template<
typenameD,
typenameT>
5696 const T* pend = pcurr + (*pcurr >> 3);
5701 intbitval = (*buf) & 1;
5707 if(
unsigned(*pcurr + 1) >= dest_len)
5711 for(
T i= 0; ;++
i)
5714 if(
i== to)
break;
5720 while(pcurr <= pend)
5722 unsignedpending = *pcurr - *(pcurr-1);
5723 if(pending >= dest_len)
5725dest_len -= pending;
5726 Tfrom = (
T)(*(pcurr-1)+1);
5728 for(
T i= from; ;++
i)
5731 if(
i== to)
break;
5735 return(
D) (dest_curr - dest);
5757 #if defined(BM_USE_GCC_BUILD) 5758 count+= unsigned(__builtin_popcountll(x) + __builtin_popcountll(y)
5759+ __builtin_popcountll(u) + __builtin_popcountll(v));
5771}
while(block < block_end);
5782}
while(block < block_end);
5821 #ifdef VECT_BIT_COUNT_DIGEST 5844 #if defined(BM_USE_GCC_BUILD) 5845 count+= unsigned(__builtin_popcountll(x) + __builtin_popcountll(y)
5846+ __builtin_popcountll(u) + __builtin_popcountll(v));
5871}
while(blk < blk_end);
5899 count-= (w >> ((
sizeof(w) * 8) - 1));
5912 unsignedgap_count = 1;
5917 const intw_shift =
int(
sizeof(w) * 8 - 1);
5920gap_count -= (w_prev = (w0 >> w_shift));
5923 for(++block; block < block_end; ++block)
5929gap_count -= !w_prev;
5937gap_count -= (w0 >> w_shift);
5938gap_count -= !(w_prev ^ w_l);
5940w_prev = (w0 >> w_shift);
5954 unsignedgap_count = 1;
5960 const intw_shift =
int(
sizeof(w) * 8 - 1);
5963gap_count -= unsigned(w_prev = (w0 >> w_shift));
5966 for(++block; block < block_end; ++block)
5972gap_count -= !w_prev;
5980gap_count -= unsigned(w0 >> w_shift);
5981gap_count -= !(w_prev ^ w_l);
5982w_prev = (w0 >> w_shift);
6006 #ifdef VECT_BLOCK_CHANGE_BC 6033 #if defined(VECT_BLOCK_CHANGE) 6056 unsignednbit, bitcount, temp;
6061 return(*word >> nbit) & 1u;
6065 unsignedright_margin = nbit + right - left;
6066 if(right_margin < 32)
6070 unsigned mask= mask_r & mask_l;
6075temp = *word & mask_r;
6078bitcount = (right - left + 1u) - (32 - nbit);
6083bitcount = right - left + 1u;
6090 #if defined(BM64OPT) || defined(BM64_SSE4) || defined(BMAVX2OPT) || defined(BMAVX512OPT) 6092 for( ;bitcount >= 128; bitcount-=128, word+=4)
6096 if((w64_0 ^ maskFF64) | (w64_1 ^ maskFF64))
6100 for( ;bitcount >= 128; bitcount-=128, word+=4)
6102 bm::word_tm = (word[0] != maskFF) || (word[1] != maskFF) |
6103(word[2] != maskFF) || (word[3] != maskFF);
6109 for( ;bitcount >= 32; bitcount-=32, ++word)
6111 if(*word != maskFF)
6118temp = *word & mask_l;
6137 template<
boolLWA,
boolRWA>
6145 unsignednword, nbit, bitcount,
count, right_margin;
6149 return(*block >> nbit) & 1u;
6151bitcount = 1u + (right_margin = (right - left));
6160right_margin += nbit;
6162 if(right_margin < 32)
6168bitcount -= 32 - nbit;
6175 #if defined(BM64_SSE4) || defined(BM64_AVX2) || defined(BM64_AVX512) 6176 for( ;bitcount >= 128; bitcount-=128)
6185 for( ;bitcount >= 64; bitcount-=64)
6197 for( ;bitcount >= 32; bitcount-=32)
6232 unsignedbitcount = right + 1;
6235 #if defined(BMAVX2OPT) || defined(BMAVX512OPT) 6238__m256i
cnt= _mm256_setzero_si256();
6241 for( ;bitcount >= 256; bitcount -= 256)
6243 const__m256i* src = (__m256i*)block;
6244__m256i xmm256 = _mm256_load_si256(src);
6246 cnt= _mm256_add_epi64(
cnt, bc);
6251 count+= (unsigned)(cnt64[0] + cnt64[1] + cnt64[2] + cnt64[3]);
6254 for( ;bitcount >= 64; bitcount -= 64)
6286block[
i] = (block[
i] << 1) | (block[
i+ 1] >> 31);
6300 const unsignedunroll_factor = 4;
6306w0 = block[
i+ 1] >> 31;
6307w1 = block[
i+ 2] >> 31;
6308w2 = block[
i+ 3] >> 31;
6309w3 = block[
i+ 4] >> 31;
6311block[0 +
i] = (block[0 +
i] << 1) | w0;
6312block[1 +
i] = (block[1 +
i] << 1) | w1;
6313block[2 +
i] = (block[2 +
i] << 1) | w2;
6314block[3 +
i] = (block[3 +
i] << 1) | w3;
6316block[
i] = (block[
i] << 1) | (block[
i+ 1] >> 31);
6317block[
i+ 1] = (block[
i+ 1] << 1) | (block[
i+ 2] >> 31);
6318block[
i+ 2] = (block[
i+ 2] << 1) | (block[
i+ 3] >> 31);
6351block[nword] = w | (unsigned(
value) << nbit) | wl;
6363w = (w << 1u) | co_flag;
6394acc |= w = (w << 1u) | co_flag;
6418 #if defined(BM64OPT) 6430acc0 |= w = (w << 1u) | co_flag;
6431b_u->w64[
i++] = w;
6436acc1 |= w = (w << 1u) | co_flag;
6441*empty_acc =
bool(acc0 | acc1);
6465 #if defined(VECT_SHIFT_R1) 6495acc |= w = (w >> 1u) | (co_flag << 31u);
6523w0 = block[
i]; w1 = block[
i-1];
6525acc |= w0 = (w0 >> 1u) | (co_flag << 31u);
6529acc |= w1 = (w1 >> 1u) | (co_flag << 31u);
6534w0 = block[
i]; w1 = block[
i-1];
6536acc |= w0 = (w0 >> 1u) | (co_flag << 31u);
6540acc |= w1 = (w1 >> 1u) | (co_flag << 31u);
6565 #if defined(VECT_SHIFT_L1) 6605w = (w >> 1u) | (co_flag << 31u);
6617w |= wl | (co_flag << 31u);
6622block[nword] = (block[nword] >> 1u) | (co_flag << 31u);
6657 for(; di < 64; ++di)
6670w = (w << 1u) | co_flag;
6671acc |= block[
i] = w & mask_block[
i];
6687block[d_base] = co_flag & mask_block[d_base];
6719 #if defined(VECT_SHIFT_R1_AND) 6741 unsignednbit = left;
6749 return(*word >> nbit) & 1;
6752 unsignedbitcount = right - left + 1;
6756 unsignedright_margin = nbit + (right - left);
6757 if(right_margin < 32)
6761 unsigned mask= mask_r & mask_l;
6762 return*word &
mask;
6767acc = *word & mask_r;
6770bitcount -= 32 - nbit;
6778 for( ;bitcount >= 128; bitcount-=128, word+=4)
6780acc = word[0] | word[1] | word[2] | word[3];
6786 for( ;bitcount >= 32; bitcount -= 32)
6794acc |= (*word) & mask_l;
6804 template<
typenameT>
6814start[0] = ~start[0];
6815start[1] = ~start[1];
6816start[2] = ~start[2];
6817start[3] = ~start[3];
6819}
while(start < end);
6831 #if defined(VECT_IS_ONE_BLOCK) 6839start[0] & start[1] & start[2] & start[3];
6843}
while(start < end);
6884 boolis_left, is_right, all_one;
6897 if(is_left ==
false)
6901 if(is_right ==
false)
6934w &= (1u << bit_pos);
6949w = (~block[nword]) >> bit_pos;
6954*pos = unsigned(bit_pos + (nword * 8u *
unsigned(
sizeof(
bm::word_t)))-1);
6964*pos = unsigned(bit_pos + (nword * 8u *
unsigned(
sizeof(
bm::word_t)))-1);
7030w &= (1u << bit_pos);
7046w = (~block[nword]) & mask_l;
7050*pos = unsigned(bit_pos + (nword * 8u *
unsigned(
sizeof(
bm::word_t)))+1);
7056 for(--nword;
true; --nword)
7062*pos = unsigned(bit_pos + (nword * 8u *
unsigned(
sizeof(
bm::word_t)))+1);
7094w &= (1u << bit_pos);
7097*pos = unsigned(bit_pos + (nword * 8u *
unsigned(
sizeof(
bm::word_t))));
7109w = block[nword] & mask_l;
7113*pos = unsigned(bit_pos + (nword * 8u *
unsigned(
sizeof(
bm::word_t))));
7119 for(--nword;
true; --nword)
7126unsigned(bit_pos + (nword * 8u *
unsigned(
sizeof(
bm::word_t))));
7155 if(
b&& *found_nbit == 0)
7166 if(
b&& *found_nbit == 0)
7194*found_nbit = nbit_from;
7271bm::gap_buff_op<bm::gap_word_t, bm::and_func>(
7272tmp_buf, vect1, 0, vect2, 0, dsize);
7294 returngap_buff_any_op<bm::gap_word_t, bm::and_func>(vect1, 0, vect2, 0);
7311 returnbm::gap_buff_count_op<bm::gap_word_t, bm::and_func>(vect1, vect2);
7338bm::gap_buff_op<bm::gap_word_t, bm::xor_func>(
7339tmp_buf, vect1, 0, vect2, 0, dsize);
7376 returngap_buff_any_op<bm::gap_word_t, bm::xor_func>(vect1, 0, vect2, 0);
7392 returnbm::gap_buff_count_op<bm::gap_word_t, bm::xor_func>(vect1, vect2);
7419bm::gap_buff_op<bm::gap_word_t, bm::and_func>(tmp_buf, vect1, 1, vect2, 1, dsize);
7437 returngap_buff_count_op<bm::gap_word_t, bm::or_func>(vect1, vect2);
7465bm::gap_buff_op<bm::gap_word_t, bm::and_func>(
7466tmp_buf, vect1, 0, vect2, 1, dsize);
7490bm::gap_buff_any_op<bm::gap_word_t, bm::and_func>(
7491vect1, 0, vect2, 1);
7508 returnbm::gap_buff_count_op<bm::gap_word_t, bm::sub_func>(vect1, vect2);
7546 #ifdef VECT_COPY_BLOCK_UNALIGN 7567 #ifdef VECT_STREAM_BLOCK 7585 #ifdef VECT_STREAM_BLOCK_UNALIGN 7620 for(
unsigned i= 0;
i< arr_sz;
i+=4)
7622acc |= (dst_u->w64[
i] &= src_u->w64[
i]) |
7623(dst_u->w64[
i+1] &= src_u->w64[
i+1]) |
7624(dst_u->w64[
i+2] &= src_u->w64[
i+2]) |
7625(dst_u->w64[
i+3] &= src_u->w64[
i+3]);
7661 #if defined(VECT_AND_DIGEST) 7664digest &= ~(
mask<< wave);
7673acc |= dst_u->w64[j+0] &= src_u->w64[j+0];
7674acc |= dst_u->w64[j+1] &= src_u->w64[j+1];
7675acc |= dst_u->w64[j+2] &= src_u->w64[j+2];
7676acc |= dst_u->w64[j+3] &= src_u->w64[j+3];
7681digest &= ~(
mask<< wave);
7705 BM_ASSERT(src0 && src1 && src2 && src3);
7716 #if defined(VECT_AND_DIGEST_5WAY) 7717 boolall_zero =
VECT_AND_DIGEST_5WAY(&dst[off], &src0[off], &src1[off], &src2[off], &src3[off]);
7719digest &= ~(
mask<< wave);
7731acc |= dst_u->w64[j + 0] &= src_u0->w64[j + 0] & src_u1->w64[j + 0] & src_u2->w64[j + 0] & src_u3->w64[j + 0];
7732acc |= dst_u->w64[j + 1] &= src_u0->w64[j + 1] & src_u1->w64[j + 1] & src_u2->w64[j + 1] & src_u3->w64[j + 1];
7733acc |= dst_u->w64[j + 2] &= src_u0->w64[j + 2] & src_u1->w64[j + 2] & src_u2->w64[j + 2] & src_u3->w64[j + 2];
7734acc |= dst_u->w64[j + 3] &= src_u0->w64[j + 3] & src_u1->w64[j + 3] & src_u2->w64[j + 3] & src_u3->w64[j + 3];
7738digest &= ~(
mask<< wave);
7778 #if defined(VECT_AND_DIGEST_3WAY) 7781digest &= ~(
mask<< wave);
7792acc |= dst_u->w64[j] &= src_u1->w64[j] & src_u2->w64[j];
7793acc |= dst_u->w64[j+1] &= src_u1->w64[j+1] & src_u2->w64[j+1];
7794acc |= dst_u->w64[j+2] &= src_u1->w64[j+2] & src_u2->w64[j+2];
7795acc |= dst_u->w64[j+3] &= src_u1->w64[j+3] & src_u2->w64[j+3];
7800digest &= ~(
mask<< wave);
7843 #if defined(VECT_AND_DIGEST_2WAY) 7846digest &= ~(
mask<< wave);
7857acc |= dst_u->w64[j] = src_u1->w64[j] & src_u2->w64[j];
7858acc |= dst_u->w64[j+1] = src_u1->w64[j+1] & src_u2->w64[j+1];
7859acc |= dst_u->w64[j+2] = src_u1->w64[j+2] & src_u2->w64[j+2];
7860acc |= dst_u->w64[j+3] = src_u1->w64[j+3] & src_u2->w64[j+3];
7865digest &= ~(
mask<< wave);
7895 for(
unsigned i= 0;
i< 64; ++
i)
7900 #if defined(VECT_AND_DIGEST_2WAY) 7915acc |= dst_u->w64[j] = src_u1->w64[j] & src_u2->w64[j];
7916acc |= dst_u->w64[j+1] = src_u1->w64[j+1] & src_u2->w64[j+1];
7917acc |= dst_u->w64[j+2] = src_u1->w64[j+2] & src_u2->w64[j+2];
7918acc |= dst_u->w64[j+3] = src_u1->w64[j+3] & src_u2->w64[j+3];
7929 #if defined(VECT_BLOCK_SET_DIGEST) 7934dst[off] = dst[off+1] = dst[off+2] = dst[off+3] = 0u;
7976 #if defined(VECT_AND_OR_DIGEST_2WAY) 7980digest &= ~(
mask<< wave);
7993acc |= dst_u->w64[j+0] |= src_u1->w64[j+0] & src_u2->w64[j+0];
7994acc |= dst_u->w64[j+1] |= src_u1->w64[j+1] & src_u2->w64[j+1];
7995acc |= dst_u->w64[j+2] |= src_u1->w64[j+2] & src_u2->w64[j+2];
7996acc |= dst_u->w64[j+3] |= src_u1->w64[j+3] & src_u2->w64[j+3];
8001digest &= ~(
mask<< wave);
8042}
while(b1 < b1_end);
8052}
while(src1 < src1_end);
8076 count= (src1[0] & src2[0]) |
8077(src1[1] & src2[1]) |
8078(src1[2] & src2[2]) |
8079(src1[3] & src2[3]);
8081}
while((src1 < src1_end) && !
count);
8119}
while(b1 < b1_end);
8129}
while(src1 < src1_end);
8153 count= (src1[0] ^ src2[0]) |
8154(src1[1] ^ src2[1]) |
8155(src1[2] ^ src2[2]) |
8156(src1[3] ^ src2[3]);
8158}
while(!
count&& (src1 < src1_end));
8192}
while(b1 < b1_end);
8202}
while(src1 < src1_end);
8226 count= (src1[0] & ~src2[0]) |
8227(src1[1] & ~src2[1]) |
8228(src1[2] & ~src2[2]) |
8229(src1[3] & ~src2[3]);
8231}
while((src1 < src1_end) && (
count== 0));
8267}
while(b1 < b1_end);
8277}
while(src1 < src1_end);
8300 count= (src1[0] | src2[0]) |
8301(src1[1] | src2[1]) |
8302(src1[2] | src2[2]) |
8303(src1[3] | src2[3]);
8306}
while(!
count&& (src1 < src1_end));
8598acc &= (dst_ptr[0] |= wrd_ptr[0]);
8599acc &= (dst_ptr[1] |= wrd_ptr[1]);
8600acc &= (dst_ptr[2] |= wrd_ptr[2]);
8601acc &= (dst_ptr[3] |= wrd_ptr[3]);
8603dst_ptr+=4;wrd_ptr+=4;
8605}
while(wrd_ptr < wrd_end);
8606 returnacc == not_acc;
8636acc &= (dst_ptr[0] = wrd_ptr1[0] | wrd_ptr2[0]);
8637acc &= (dst_ptr[1] = wrd_ptr1[1] | wrd_ptr2[1]);
8638acc &= (dst_ptr[2] = wrd_ptr1[2] | wrd_ptr2[2]);
8639acc &= (dst_ptr[3] = wrd_ptr1[3] | wrd_ptr2[3]);
8641dst_ptr+=4; wrd_ptr1+=4; wrd_ptr2+=4;
8643}
while(wrd_ptr1 < wrd_end1);
8644 returnacc == not_acc;
8674acc |= (dst_ptr[0] = wrd_ptr1[0] ^ wrd_ptr2[0]);
8675acc |= (dst_ptr[1] = wrd_ptr1[1] ^ wrd_ptr2[1]);
8676acc |= (dst_ptr[2] = wrd_ptr1[2] ^ wrd_ptr2[2]);
8677acc |= (dst_ptr[3] = wrd_ptr1[3] ^ wrd_ptr2[3]);
8679dst_ptr+=4; wrd_ptr1+=4; wrd_ptr2+=4;
8681}
while(wrd_ptr1 < wrd_end1);
8716acc &= (dst_ptr[0] |= wrd_ptr1[0] | wrd_ptr2[0]);
8717acc &= (dst_ptr[1] |= wrd_ptr1[1] | wrd_ptr2[1]);
8718acc &= (dst_ptr[2] |= wrd_ptr1[2] | wrd_ptr2[2]);
8719acc &= (dst_ptr[3] |= wrd_ptr1[3] | wrd_ptr2[3]);
8721dst_ptr+=4; wrd_ptr1+=4;wrd_ptr2+=4;
8723}
while(wrd_ptr1 < wrd_end1);
8724 returnacc == not_acc;
8764acc &= (dst_ptr[0] |= wrd_ptr1[0] | wrd_ptr2[0] | wrd_ptr3[0] | wrd_ptr4[0]);
8765acc &= (dst_ptr[1] |= wrd_ptr1[1] | wrd_ptr2[1] | wrd_ptr3[1] | wrd_ptr4[1]);
8766acc &= (dst_ptr[2] |= wrd_ptr1[2] | wrd_ptr2[2] | wrd_ptr3[2] | wrd_ptr4[2]);
8767acc &= (dst_ptr[3] |= wrd_ptr1[3] | wrd_ptr2[3] | wrd_ptr3[3] | wrd_ptr4[3]);
8770wrd_ptr1+=4;wrd_ptr2+=4;wrd_ptr3+=4;wrd_ptr4+=4;
8772}
while(wrd_ptr1 < wrd_end1);
8773 returnacc == not_acc;
8866 for(
unsigned i= 0;
i< arr_sz;
i+=4)
8868acc |= (dst_u->w64[
i] &= ~src_u->w64[
i]) |
8869(dst_u->w64[
i+1] &= ~src_u->w64[
i+1]) |
8870(dst_u->w64[
i+2] &= ~src_u->w64[
i+2]) |
8871(dst_u->w64[
i+3] &= ~src_u->w64[
i+3]);
8908 #if defined(VECT_SUB_DIGEST) 8911digest &= ~(
mask<< wave);
8920acc |= dst_u->w64[j+0] &= ~src_u->w64[j+0];
8921acc |= dst_u->w64[j+1] &= ~src_u->w64[j+1];
8922acc |= dst_u->w64[j+2] &= ~src_u->w64[j+2];
8923acc |= dst_u->w64[j+3] &= ~src_u->w64[j+3];
8928digest &= ~(
mask<< wave);
8969 #if defined(VECT_SUB_DIGEST_2WAY) 8972digest &= ~(
mask<< wave);
8985acc |= dst_u->w64[j+0] = src_u1->w64[j+0] & ~src_u2->w64[j+0];
8986acc |= dst_u->w64[j+1] = src_u1->w64[j+1] & ~src_u2->w64[j+1];
8987acc |= dst_u->w64[j+2] = src_u1->w64[j+2] & ~src_u2->w64[j+2];
8988acc |= dst_u->w64[j+3] = src_u1->w64[j+3] & ~src_u2->w64[j+3];
8993digest &= ~(
mask<< wave);
9015 BM_ASSERT(src0 && src1 && src2 && src3);
9027 #if defined(VECT_SUB_DIGEST_5WAY) 9028 boolall_zero =
VECT_SUB_DIGEST_5WAY(&dst[off], &src0[off], &src1[off], &src2[off], &src3[off]);
9030digest &= ~(
mask<< wave);
9042acc |= dst_u->w64[j + 0] &= ~src_u0->w64[j + 0] & ~src_u1->w64[j + 0] & ~src_u2->w64[j + 0] & ~src_u3->w64[j + 0];
9043acc |= dst_u->w64[j + 1] &= ~src_u0->w64[j + 1] & ~src_u1->w64[j + 1] & ~src_u2->w64[j + 1] & ~src_u3->w64[j + 1];
9044acc |= dst_u->w64[j + 2] &= ~src_u0->w64[j + 2] & ~src_u1->w64[j + 2] & ~src_u2->w64[j + 2] & ~src_u3->w64[j + 2];
9045acc |= dst_u->w64[j + 3] &= ~src_u0->w64[j + 3] & ~src_u1->w64[j + 3] & ~src_u2->w64[j + 3] & ~src_u3->w64[j + 3];
9050digest &= ~(
mask<< wave);
9082 #if defined(VECT_SUB_DIGEST_3WAY) 9085digest &= ~(
mask<< wave);
9095acc |= dst_u->w64[j + 0] &= ~src_u0->w64[j + 0] & ~src_u1->w64[j + 0];
9096acc |= dst_u->w64[j + 1] &= ~src_u0->w64[j + 1] & ~src_u1->w64[j + 1];
9097acc |= dst_u->w64[j + 2] &= ~src_u0->w64[j + 2] & ~src_u1->w64[j + 2];
9098acc |= dst_u->w64[j + 3] &= ~src_u0->w64[j + 3] & ~src_u1->w64[j + 3];
9103digest &= ~(
mask<< wave);
9198 for(
unsigned i= 0;
i< arr_sz;
i+=4)
9200acc |= dst_u->w64[
i] ^= src_u->w64[
i];
9201acc |= dst_u->w64[
i+1] ^= src_u->w64[
i+1];
9202acc |= dst_u->w64[
i+2] ^= src_u->w64[
i+2];
9203acc |= dst_u->w64[
i+3] ^= src_u->w64[
i+3];
9235dst_ptr+=4; wrd_ptr+=4;
9236}
while(wrd_ptr < wrd_end);
9257 if(src == dst)
return0;
9263 if(!src)
returndst;
9269 if(!src)
returndst;
9353 const T* blk_end = blk + data_size - 2;
9358 const T* blk_j = blk + 1;
9359 for(; blk_j < blk_end; ++blk_j)
9369 const T* blk_j = blk + 1;
9370 for( ; blk_j < blk_end; ++blk_j)
9374 if(blk_j[1] | blk_j[2])
9384 count+= unsigned(blk_j - blk) * unsigned(
sizeof(
T));
9389 while(blk < blk_end);
9390 return count+ unsigned(2 *
sizeof(
T));
9415w &= (1u << bit_pos);
9421w = block[nword] >> bit_pos;
9426*pos = unsigned(bit_pos + (nword * 8u *
unsigned(
sizeof(
bm::word_t))));
9436*pos = unsigned(bit_pos + (
i* 8u *
unsigned(
sizeof(
bm::word_t))));
9470*
last= unsigned(idx + (
i* 8u *
unsigned(
sizeof(
bm::word_t))));
9496 #ifdef VECT_BIT_FIND_FIRST 9505*pos = unsigned(idx + (
i* 8u *
unsigned(
sizeof(
bm::word_t))));
9537 #ifdef VECT_BIT_FIND_FIRST 9545 unsignedbase =
i* 8u * unsigned(
sizeof(
bm::word_t));
9555w64 = block[
i] | block[
i+1];
9558 unsignedbase =
i* 8u * unsigned(
sizeof(
bm::word_t));
9598 #if defined(BMSSE42OPT) || defined(BMAVX2OPT) || defined(BMAVX512OPT) 9604 const unsigned cnt=
i+ 4;
9613 for(++
i;
i<
cnt; ++
i)
9620}
while(++
i<
cnt);
9633 if(
autow = block[
i])
9663 template<
typenameSIZE_TYPE>
9675 unsignedpos = nbit_from;
9685rank -= bc; pos += unsigned(32u - nbit);
9691nbit_pos = pos + idx;
9696 #if defined(BM64OPT) || defined(BM64_SSE4) || defined(BMAVX2OPT) || defined(BMAVX512OPT) 9706nbit_pos = pos + idx;
9721rank -= bc; pos += 32u;
9725nbit_pos = pos + idx;
9744 template<
typenameSIZE_TYPE>
9770 unsignedtotal_possible_bitcount,
9778 if((gap_size < block_size) && (gap_size < arr_size) && (gap_size < inv_arr_size))
9783 if(arr_size < inv_arr_size)
9785 if((arr_size < block_size) && (arr_size < gap_size))
9792 if((inv_arr_size < block_size) && (inv_arr_size < gap_size))
9811 template<
typenameT>
9816 const bm::id64_timask64 = inverted ? ~0ull : 0;
9819src+=2, bit_idx += unsigned(
sizeof(*src) * 8 * 2))
9830 return(
unsigned)(pcurr - dest);
9834 template<
typenameT>
9838 for(
unsigned i= 1;
i< sz; ++
i)
9841 unsignedd =
arr[
i] -
arr[
i-1];
9855 template<
typenameT>
9864 unsignedbitpos = 0;
9865 unsignedw = block[nword];
9872 b= (~w) & (1 << 1);
9875arr_ex0[ex0_cnt] = 0; ++ex0_cnt;
9880 for(;
i<= 65534; ++
i)
9885 b= w & (1 << bitpos);
9893 boolb_prev = w & (1 << bitpos);
9900 boolb_next = w & (1 << bitpos);
9909w &= ~(1 << bitpos);
9911arr_ex0[ex0_cnt] = (
T)
i; ++ex0_cnt;
9925arr_ex0[ex0_cnt] = 0; ++ex0_cnt;
9931 for(;
i<= 65534; ++
i)
9936 b= w & (1 << bitpos);
9944 boolb_prev = w & (1 << bitpos);
9951 boolb_next = w & (1 << bitpos);
9962arr_ex0[ex0_cnt] = (
T)
i; ++ex0_cnt;
9975 template<
typenameT>
9981 for(
unsignedk = 0; k < ex0_cnt; ++k)
10007 template<
typenameT>
10016 const bm::id64_timask64 = inverted ? ~0ull : 0;
10024src+=2, bit_idx += unsigned(
sizeof(*src) * 8 * 2))
10032 if(idx !=
prev+1)
10036*pcurr_r++ =
T(
prev- rl);
10040*pcurr_s++ =
T(idx);
10044 if(!rl && (pcurr_s != dst_s))
10055*pcurr_r++ =
T(
prev- rl);
10059s_cnt = (unsigned)(pcurr_s - dst_s);
10060r_cnt = (unsigned)(pcurr_r - dst_r);
10068 template<
typenameT>
10076 for(
unsigned i= 0;
i< s_cnt; ++
i)
10080 for(
unsigned i= 0;
i< r_cnt; ++
i)
10098 if(!blk)
return true;
10122 if(blk == 0)
return false;
10142 template<
typenameT>
10144 const T* length_end,
10147 BM_ASSERT(length && length_end && glevel_len);
10149 unsignedoverhead = 0;
10150 for(;length < length_end; ++length)
10152 unsigned len= *length;
10155 unsignedcapacity = glevel_len[level];
10157overhead += capacity -
len;
10169 template<
typenameT>
10171 const T* length_end,
10174 BM_ASSERT(length && length_end && glevel_len);
10176 size_tlsize = size_t(length_end - length);
10182 for(
i= 0;
i< lsize; ++
i)
10184 if(length[
i] > max_len)
10185max_len = length[
i];
10189glevel_len[0] =
T(max_len + 4);
10199 unsignedmin_overhead =
gap_overhead(length, length_end, glevel_len);
10200 boolis_improved =
false;
10208 boolimp_flag =
false;
10210 for(j = 0; j < lsize; ++j)
10212glevel_len[
i] =
T(length[j] + 4);
10213 unsignedov =
gap_overhead(length, length_end, glevel_len);
10214 if(ov <= min_overhead)
10224is_improved =
true;
10228glevel_len[
i] = gap_saved_value;
10236 T val= *glevel_len;
10237 T* gp = glevel_len;
10238 T* res = glevel_len;
10255 returnis_improved;
10275 if(!blk || !arg_blk)
10307 if(arg_gap != gap)
10418 if(cnt_ < from_ || cnt_ >
to_)
10420++
cnt_;
return0;
10438 template<
classIt1,
classIt2,
classBinaryOp,
classEncoder>
10444 for(
unsigned i= 0;
i< block_size; ++
i)
10449enc.push_back( w );
10583&gap_and_to_bitset<bm::gap_word_t>,
10584&gap_add_to_bitset<bm::gap_word_t>,
10585&gap_sub_to_bitset<bm::gap_word_t>,
10586&gap_xor_to_bitset<bm::gap_word_t>,
10641w0 = w_ptr[0]; w1 = w_ptr[1];
10643 #if defined(BMAVX512OPT) || defined(BMAVX2OPT) || defined(BM64OPT) || defined(BM64_SSE4) 10648w0 = w_ptr[2]; w1 = w_ptr[3];
10652 #if (defined(__arm__) || defined(__aarch64__)) 10656w0 = w_ptr[2]; w1 = w_ptr[3];
10658cnt0 +=
bm::bitscan_bsf(w1, bits + cnt0, (
unsigned short)(64+32));
10664w0 = w_ptr[2]; w1 = w_ptr[3];
10669 return static_cast<unsigned short>(cnt0);
10672 #if defined (BM64_SSE4) || defined(BM64_AVX2) || defined(BM64_AVX512) 10682 unsigned size,
unsignedstart,
10685 typedef unsignedTRGW;
10686 typedef unsigned IDX;
10687 #if defined(BM64_SSE4) 10690 ifconstexpr (
sizeof(TRGW)==4 &&
sizeof(
IDX)==4)
10695 #elif defined(BM64_AVX2) || defined(BM64_AVX512) 10696 ifconstexpr (
sizeof(TRGW)==4 &&
sizeof(
IDX)==4)
10712 template<
typenameTRGW,
typenameIDX,
typenameSZ>
10721 constSZ
len= (
size- start);
10722 constSZ len_unr =
len- (
len% 2);
10724 for(; k < len_unr; k+=2)
10726 constSZ base = start + k;
10734 for(; k <
len; ++k)
10762 for(;(start <
size) &&
10787 #if defined(VECT_ARR_BLOCK_LOOKUP) 10790 for(;(start <
size) &&
10825block[nword] |= (1u << nbit);
10849 #if defined(VECT_SET_BLOCK_BITS) 10854 unsigned n= idx[start++];
10858block[nword] |= (1u << nbit);
10859}
while(start < stop);
10873 unsigned& left,
unsigned& right)
BMNOEXCEPT 10911 #if defined(VECT_LOWER_BOUND_SCAN_U32) 10914 for(; from <= to; ++from)
10916 if(
arr[from] >= target)
10929 unsigned long longtarget,
10936 for(; from <= to; ++from)
10938 if(
arr[from] >= target)
10958 const unsignedlinear_cutoff = 32;
10960 unsigned l= from;
unsigned r= to;
10961 unsigneddist =
r-
l;
10962 if(dist < linear_cutoff)
10969 unsignedmid = (
r-
l)/2+
l;
10970 if(
arr[mid] < target)
10975 if(dist < linear_cutoff)
10989 unsigned long longtarget,
10994 const unsignedlinear_cutoff = 32;
10996 unsigned l= from;
unsigned r= to;
10997 unsigneddist =
r-
l;
10998 if(dist < linear_cutoff)
11005 unsignedmid = (
r-
l) / 2 +
l;
11006 if(
arr[mid] < target)
11011 if(dist < linear_cutoff)
11025 bool find_ptr(
const void*
const* p_arr,
size_tarr_size,
11029 for(
size_t i= 0;
i< arr_size; ++
i)
11030 if(ptr == p_arr[
i])
11032*idx =
i;
return true;
11050 returnblock_idx + base_idx;
11059 returnblock_idx + base_idx;
11073 unsignedmd =
arr[1] -
arr[0];
11074 for(
size_t i= 1;
i< arr_size; ++
i)
11077 unsignedcurr =
arr[
i];
11102 for(
size_t i= 1;
i< arr_size; ++
i)
11113 template<
typenameVT,
typenameSZ>
11116 boolfound =
false;
11118 for(SZ
i= 0;
i< arr_size; ++
i)
11123max_v = v; *found_idx =
i;
11134 template<
typenameVT,
typenameSZ>
11137 for(SZ
i= 0;
i< arr_size; ++
i)
11153 template<
typenameVT,
typenameSZ>
11157 for(SZ
i= 0;
i< arr_size; ++
i)
11194 floatbie_bits_per_int,
11202 if(bc == max_bits)
11208 unsignedibc = max_bits - bc;
11214 floatcost_in_bits = float(gc) * bie_bits_per_int;
11215 if(cost_in_bits >=
float(max_bits))
11225 floatcost_in_bits = float(bc) * bie_bits_per_int;
11226 if(cost_in_bits >=
float(max_bits))
11231*best_metric = ibc;
11232 floatcost_in_bits = float(ibc) * bie_bits_per_int;
11233 if(cost_in_bits >=
float(max_bits))
11239 template<
typenameT>
11242 unsigned& win_size,
float& best_save)
11244 booluse_wdr =
false;
11247 for(
unsignedw_size = 20; w_size <= 78; w_size += 2)
11258 unsignedtotal_windows = (sz + w_size - 1) / w_size;
11259 floatbits_extra = float(total_windows + 1 + 8 + 8);
11260 floatsave_per_window = 0.15f * w_size;
11261 floattotal_save = save_per_window * wcnt;
11262total_save -= bits_extra;
11263 if(total_save > 0.0f)
11267use_wdr =
true; win_size = w_size; best_save = total_save;
11270 if(total_save >= best_save)
11272win_size = w_size; best_save = total_save;
11300 template<
typenameT>
11303 Ttemp = *
a; *
a= *
b; *
b= temp;
11309 template<
typenameT>
11322 while(
arr[j] >
arr[pivot])
11353 unsignedarr_idx = idx >> 1;
11356 unsigned charold_val =
arr[arr_idx];
11358 arr[arr_idx] = (
unsignedchar)(old_val | (v << 4));
11362 unsigned charold_val =
arr[arr_idx];
11364 arr[arr_idx] = (
unsignedchar)(old_val | (v & 0xF));
11380 unsigned charv =
arr[idx >> 1];
11381v >>= (idx & 1) * 4;
11411 return(ptr.i16[1] == 0);
11413 bm::id64_t r= (ptr.i16[1] == v) | (ptr.i16[2] == v) | (ptr.i16[3] == v);
ncbi::TMaskedQueryRegions mask
#define VECT_STREAM_BLOCK_UNALIGN(dst, src)
#define VECT_COPY_BLOCK_UNALIGN(dst, src)
#define VECT_SET_BLOCK(dst, value)
#define VECT_BITCOUNT_OR(first, last, mask)
#define VECT_BIT_FIND_DIFF(src1, src2, pos)
#define VECT_AND_DIGEST_5WAY(dst, src1, src2, src3, src4)
#define VECT_OR_BLOCK_5WAY(dst, src1, src2, src3, src4)
#define VECT_BIT_FIND_FIRST(src1, off, pos)
#define VECT_COPY_BLOCK(dst, src)
#define VECT_SUB_DIGEST_5WAY(dst, src1, src2, src3, src4)
#define BM_AVX2_POPCNT_PROLOG
#define VECT_BITCOUNT_AND(first, last, mask)
#define VECT_SHIFT_R1(b, acc, co)
#define VECT_XOR_BLOCK_2WAY(dst, src1, src2)
#define VECT_IS_ONE_BLOCK(dst)
#define VECT_STREAM_BLOCK(dst, src)
#define VECT_OR_BLOCK(dst, src)
#define VECT_SHIFT_R1_AND(b, co, m, digest)
#define VECT_SUB_BLOCK(dst, src)
#define VECT_GAP_TEST(buf, pos)
#define VECT_IS_ZERO_BLOCK(dst)
#define VECT_BIT_TO_GAP(dest, src, dest_len)
#define VECT_SUB_DIGEST_2WAY(dst, src1, src2)
#define VECT_XOR_BLOCK(dst, src)
#define VECT_IS_DIGEST_ZERO(start)
#define VECT_ANDNOT_ARR_2_MASK(dst, src, src_end, mask)
#define VECT_BLOCK_CHANGE_BC(block, gc, bc)
#define VECT_BIT_COUNT_DIGEST(blk, d)
#define VECT_SHIFT_L1(b, acc, co)
#define VECT_LOWER_BOUND_SCAN_U32(arr, target, from, to)
#define VECT_SET_BLOCK_BITS(block, idx, start, stop)
#define VECT_BITCOUNT_SUB(first, last, mask)
#define VECT_BITCOUNT_XOR(first, last, mask)
#define VECT_AND_DIGEST(dst, src)
#define VECT_GAP_BFIND(buf, pos, is_set)
#define VECT_INVERT_BLOCK(first)
#define VECT_BLOCK_CHANGE(block, size)
#define VECT_SUB_DIGEST_3WAY(dst, src1, src2)
#define VECT_AND_DIGEST_2WAY(dst, src1, src2)
#define VECT_AND_OR_DIGEST_2WAY(dst, src1, src2)
#define VECT_BLOCK_SET_DIGEST(dst, val)
#define VECT_AND_DIGEST_3WAY(dst, src1, src2)
#define BM_AVX2_BIT_COUNT(ret, v)
#define VECT_ARR_BLOCK_LOOKUP(idx, size, nb, start)
#define VECT_BITCOUNT(first, last)
#define VECT_SUB_DIGEST(dst, src)
#define VECT_OR_BLOCK_3WAY(dst, src1, src2)
#define VECT_OR_BLOCK_2WAY(dst, src1, src2)
#define VECT_AND_BLOCK(dst, src)
#define IS_FULL_BLOCK(addr)
#define IS_VALID_ADDR(addr)
#define FULL_BLOCK_FAKE_ADDR
#define IS_EMPTY_BLOCK(addr)
#define BM_VECT_ALIGN_ATTR
#define FULL_BLOCK_REAL_ADDR
Bit manipulation primitives (internal)
Bit-block get adapter, takes bitblock and represents it as a get_32() accessor function.
bitblock_get_adapter(const bm::word_t *bit_block)
bm::word_t get_32() noexcept
Bit-block store adapter, takes bitblock and saves results into it.
bitblock_store_adapter(bm::word_t *bit_block)
void push_back(bm::word_t w)
Bit-block sum adapter, takes values and sums it /internal.
bm::word_t sum() const noexcept
Get accumulated sum.
void push_back(bm::word_t w) noexcept
Adaptor to copy 1 bits to array.
copy_to_array_functor(B *bits)
copy_to_array_functor(const copy_to_array_functor &)
void operator()(unsigned bit_idx0, unsigned bit_idx1) noexcept
void operator()(unsigned bit_idx0, unsigned bit_idx1, unsigned bit_idx2, unsigned bit_idx3) noexcept
void operator()(unsigned bit_idx) noexcept
void operator()(unsigned bit_idx0, unsigned bit_idx1, unsigned bit_idx2) noexcept
copy_to_array_functor & operator=(const copy_to_array_functor &)
Adapter to get words from a range stream (see range serialized bit-block)
bm::word_t get_32() noexcept
decoder_range_adapter(DEC &dec, unsigned from_idx, unsigned to_idx)
static vector< string > arr
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
bool avx2_test_all_zero_wave(const void *ptr)
check if wave of pointers is all NULL
bool sse42_test_all_zero_wave(const void *ptr) noexcept
check if wave of pointers is all NULL
NCBI_NS_STD::string::size_type SIZE_TYPE
bm::id_t bit_block_count(const bm::word_t *block) noexcept
Bitcount for bit block.
unsigned bit_find_last(const bm::word_t *block, unsigned *last) noexcept
BIT block find the last set bit (backward search)
unsigned short bitscan_bsf64(bm::id64_t w, B *bits) noexcept
Unpacks word into list of ON bits (BSF/__builtin_ctz)
bool bit_find_first(const bm::word_t *block, unsigned *pos) noexcept
BIT block find the first set bit.
void bit_block_copy_unalign(bm::word_t *dst, const bm::word_t *src) noexcept
Bitblock copy operation (unaligned src)
unsigned word_select32(unsigned w, unsigned rank) noexcept
word find index of the rank-th bit set by bit-testing
bm::id64_t bit_block_and_3way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2, bm::id64_t digest) noexcept
digest based bit-block AND
void or_bit_block(unsigned *dest, unsigned bitpos, unsigned bitcount) noexcept
Sets bits to 1 in the bitblock.
bool bit_block_shift_r1(bm::word_t *block, bm::word_t *empty_acc, bm::word_t co_flag) noexcept
Right bit-shift bitblock by 1 bit (reference)
void bit_block_gather_scatter(TRGW *arr, const bm::word_t *blk, const IDX *idx, SZ size, SZ start, unsigned bit_idx) noexcept
bit index to word gather-scatter algorithm
int wordcmp0(T w1, T w2) noexcept
Lexicographical comparison of two words as bit strings (reference) Auxiliary implementation for testi...
void block_compact_by_digest(bm::word_t *t_block, const bm::word_t *block, bm::id64_t digest, bool zero_tail) noexcept
Compact sub-blocks by digest (rank compaction)
bm::id64_t digest_mask(unsigned from, unsigned to) noexcept
Compute digest mask for [from..to] positions.
unsigned bit_count_nonzero_size(const T *blk, unsigned data_size) noexcept
Inspects block for full zero words.
void xor_bit_block(unsigned *dest, unsigned bitpos, unsigned bitcount) noexcept
XOR bit interval to 1 in the bitblock.
bm::word_t * bit_operation_sub(bm::word_t *dst, const bm::word_t *src) noexcept
bitblock SUB operation.
unsigned word_bitcount64(bm::id64_t x) noexcept
bm::id_t bit_operation_sub_count(const bm::word_t *src1, const bm::word_t *src2) noexcept
Performs bitblock SUB operation and calculates bitcount of the result.
bm::id64_t bit_block_xor(bm::word_t *dst, const bm::word_t *src) noexcept
Plain bitblock XOR operation. Function does not analyse availability of source and destination blocks...
unsigned word_select64_bitscan_tz(bm::id64_t w, unsigned rank) noexcept
word find index of the rank-th bit set by bit-testing
bool bit_block_shift_r1_and(bm::word_t *block, bm::word_t co_flag, const bm::word_t *mask_block, bm::id64_t *digest) noexcept
Right bit-shift of bit-block by 1 bit (reference) + AND.
bool bit_find_first_diff(const bm::word_t *blk1, const bm::word_t *blk2, unsigned *pos) noexcept
Find first bit which is different between two bit-blocks.
bool bit_block_find_interval_start(const bm::word_t *block, unsigned nbit, unsigned *pos) noexcept
Searches for the first 1 bit in the 111 interval of a BIT block.
unsigned bit_block_and_any(const bm::word_t *src1, const bm::word_t *src2) noexcept
Function ANDs two bitblocks and tests for any bit. Function does not analyse availability of source b...
unsigned short bitscan_popcnt64(bm::id64_t w, B *bits) noexcept
Unpacks 64-bit word into list of ON bit indexes using popcnt method.
bm::id_t word_bitcount(bm::id_t w) noexcept
void bit_invert(T *start) noexcept
bool bit_block_or(bm::word_t *dst, const bm::word_t *src) noexcept
Plain bitblock OR operation. Function does not analyse availability of source and destination blocks.
unsigned short bitscan_bsf(unsigned w, B *bits) noexcept
Unpacks word into list of ON bits (BSF/__builtin_ctz)
bm::id64_t bit_block_and(bm::word_t *dst, const bm::word_t *src) noexcept
Plain bitblock AND operation. Function does not analyse availability of source and destination blocks...
void bit_block_stream_unalign(bm::word_t *dst, const bm::word_t *src) noexcept
Bitblock copy/stream operation (unaligned src)
unsigned bit_block_convert_to_arr(T *dest, const unsigned *src, bool inverted) noexcept
Convert bit block into an array of ints corresponding to 1 bits.
bool bit_block_shift_l1(bm::word_t *block, bm::word_t *empty_acc, bm::word_t co_flag) noexcept
Left bit-shift bitblock by 1 bit (reference)
bm::id64_t update_block_digest0(const bm::word_t *const block, bm::id64_t digest) noexcept
Compute digest for 64 non-zero areas based on existing digest (function revalidates zero areas)
void bit_andnot_arr_ffmask(bm::word_t *dst, const bm::word_t *src) noexcept
bitblock AND NOT with constant ~0 mask operation.
bool bit_block_shift_l1_unr_min(bm::word_t *block, bm::word_t *empty_acc, unsigned co_flag) noexcept
Left bit-shift bitblock by 1 bit (minimum unroll)
void bit_block_stream(bm::word_t *dst, const bm::word_t *src) noexcept
Bitblock copy/stream operation.
void bit_block_rle_split(T *dst_s, T *dst_r, T *rlen, unsigned &s_cnt, unsigned &r_cnt, const unsigned *src, bool inverted) noexcept
Convert bit block into two arrays of ints( corresponding to 1 bits)
void block_init_digest0(bm::word_t *const block, bm::id64_t digest) noexcept
Init block with 000111000 pattren based on digest.
bool bit_block_or_3way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2) noexcept
3 way (target | source1 | source2) bitblock OR operation. Function does not analyse availability of s...
bool bit_block_find_interval_end(const bm::word_t *block, unsigned nbit, unsigned *pos) noexcept
Searches for the last 1 bit in the 111 interval of a BIT block.
bool bit_block_or_2way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2) noexcept
2 way (target := source1 | source2) bitblock OR operation.
unsigned bit_block_find(const bm::word_t *block, unsigned nbit, unsigned *pos) noexcept
Searches for the next 1 bit in the BIT block.
bool is_bits_one(const bm::wordop_t *start) noexcept
Returns "true" if all bits in the block are 1.
bm::id_t bit_block_calc_count_range(const bm::word_t *block, bm::word_t left, bm::word_t right) noexcept
bool bit_block_shift_r1_unr_min(bm::word_t *block, bm::word_t *empty_acc, bm::id64_t co_flag) noexcept
Right bit-shift bitblock by 1 bit (minimum unroll)
unsigned short bitscan(V w, B *bits) noexcept
Templated Bitscan with dynamic dispatch for best type.
unsigned short bitscan_wave(const bm::word_t *w_ptr, unsigned char *bits) noexcept
Unpacks word wave (Nx 32-bit words)
bm::id_t bit_operation_xor_any(const bm::word_t *src1, const bm::word_t *src2) noexcept
Performs bitblock XOR operation test.
SIZE_TYPE bit_find_rank(const bm::word_t *const block, SIZE_TYPE rank, unsigned nbit_from, unsigned &nbit_pos) noexcept
BIT block find position for the rank.
bm::id_t bit_count_change(bm::word_t w) noexcept
unsigned bitcount64_4way(bm::id64_t x, bm::id64_t y, bm::id64_t u, bm::id64_t v) noexcept
bm::id64_t bit_block_and_or_2way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2, bm::id64_t digest) noexcept
digest based bit-block AND - OR
bool bit_is_all_zero(const bm::word_t *start) noexcept
Returns "true" if all bits in the block are 0.
bool bit_block_shift_r1_unr(bm::word_t *block, bm::word_t *empty_acc, bm::word_t co_flag) noexcept
Right bit-shift of bit-block by 1 bit (loop unrolled)
void bit_for_each_4(T w, F &func)
Templated algorithm to unpacks octet based word into list of ON bit indexes.
unsigned bit_block_sub_count(const bm::word_t *src1, const bm::word_t *src2) noexcept
Function SUBs two bitblocks and computes the bitcount. Function does not analyse availability of sour...
unsigned word_select64(bm::id64_t w, unsigned rank) noexcept
word find index of the rank-th bit set by bit-testing
unsigned bit_block_xor_any(const bm::word_t *src1, const bm::word_t *src2) noexcept
Function XORs two bitblocks and and tests for any bit. Function does not analyse availability of sour...
void bit_block_set(bm::word_t *dst, bm::word_t value) noexcept
Bitblock memset operation.
unsigned test_bit(const unsigned *block, unsigned bitpos) noexcept
Test 1 bit in a block.
void bit_block_rotate_left_1_unr(bm::word_t *block) noexcept
Unrolled cyclic rotation of bit-block left by 1 bit.
bm::id_t bit_operation_or_any(const bm::word_t *src1, const bm::word_t *src2) noexcept
Performs bitblock OR operation test.
unsigned bit_list_4(T w, B *bits) noexcept
Unpacks word into list of ON bit indexes (quad-bit based)
bool bit_block_or_5way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2, const bm::word_t *src3, const bm::word_t *src4) noexcept
5 way (target, source1, source2) bitblock OR operation. Function does not analyse availability of sou...
bm::id_t bit_block_calc_count_to(const bm::word_t *block, bm::word_t right) noexcept
void bit_for_each(T w, F &func)
Templated algorithm to unpacks word into list of ON bit indexes.
void bit_block_copy(bm::word_t *dst, const bm::word_t *src) noexcept
Bitblock copy operation.
unsigned bit_block_sub_any(const bm::word_t *src1, const bm::word_t *src2) noexcept
Function SUBs two bitblocks and and tests for any bit. Function does not analyse availability of sour...
unsigned bit_scan_reverse(T value) noexcept
bm::id_t bit_block_any_range(const bm::word_t *block, bm::word_t left, bm::word_t right) noexcept
bm::id64_t bit_block_and_2way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2, bm::id64_t digest) noexcept
digest based bit-block AND
bool bit_block_shift_l1_unr(bm::word_t *block, bm::word_t *empty_acc, bm::word_t co_flag) noexcept
Left bit-shift of bit-block by 1 bit (loop unrolled)
bm::set_representation best_representation(unsigned bit_count, unsigned total_possible_bitcount, unsigned gap_count, unsigned block_size) noexcept
Choose best representation for a bit-block.
unsigned word_select64_linear(bm::id64_t w, unsigned rank) noexcept
word find index of the rank-th bit set by bit-testing
unsigned word_select32_bitscan_tz(unsigned w, unsigned rank) noexcept
word find index of the rank-th bit set by bit-testing
bm::id_t bit_operation_and_any(const bm::word_t *src1, const bm::word_t *src2) noexcept
Performs bitblock AND operation test.
bool bit_block_shift_r1_and_unr(bm::word_t *block, bm::word_t co_flag, const bm::word_t *mask_block, bm::id64_t *digest) noexcept
Right bit-shift bitblock by 1 bit (reference) + AND.
bm::id64_t bit_block_sub_3way(bm::word_t *dst, const bm::word_t *src0, const bm::word_t *src1, bm::id64_t digest) noexcept
digest based bit-block SUB 3-way
unsigned word_select32_bitscan_popcnt(unsigned w, unsigned rank) noexcept
word find index of the rank-th bit set by bit-testing
void sub_bit_block(unsigned *dest, unsigned bitpos, unsigned bitcount) noexcept
SUB (AND NOT) bit interval to 1 in the bitblock.
unsigned word_select64_bitscan_popcnt(bm::id64_t w, unsigned rank) noexcept
word find index of the rank-th bit set by bit-testing
bm::word_t bit_block_insert(bm::word_t *block, unsigned bitpos, bool value) noexcept
insert bit into position and shift the rest right with carryover
bm::word_t * bit_operation_xor(bm::word_t *dst, const bm::word_t *src) noexcept
bitblock XOR operation.
void clear_bit(unsigned *dest, unsigned bitpos) noexcept
Set 1 bit in a block.
void bit_block_erase(bm::word_t *block, unsigned bitpos, bool carry_over) noexcept
erase bit from position and shift the rest right with carryover
void set_bit(unsigned *dest, unsigned bitpos) noexcept
Set 1 bit in a block.
bm::id64_t widx_to_digest_mask(unsigned w_idx) noexcept
Compute digest mask for word address in block.
bm::word_t * bit_operation_and(bm::word_t *dst, const bm::word_t *src) noexcept
bitblock AND operation.
unsigned bit_block_or_any(const bm::word_t *src1, const bm::word_t *src2) noexcept
Function ORs two bitblocks and and tests for any bit. Function does not analyse availability of sourc...
bm::id_t bit_operation_xor_count(const bm::word_t *src1, const bm::word_t *src2) noexcept
Performs bitblock XOR operation and calculates bitcount of the result.
unsigned bit_list(T w, B *bits) noexcept
Unpacks word into list of ON bit indexes.
void bit_block_rle_set(unsigned *blk, const T *s, const T *r, const T *rlen, unsigned s_cnt, unsigned r_cnt) noexcept
Set bits using rle split scheme (reverse of bit_block_rle_split)
int bitcmp(const T *buf1, const T *buf2, unsigned len) noexcept
Lexicographical comparison of BIT buffers.
bm::id_t bit_operation_sub_count_inv(const bm::word_t *src1, const bm::word_t *src2) noexcept
Performs inverted bitblock SUB operation and calculates bitcount of the result.
unsigned bit_block_and_count(const bm::word_t *src1, const bm::word_t *src2) noexcept
Function ANDs two bitblocks and computes the bitcount. Function does not analyse availability of sour...
bool bit_find_first_if_1(const bm::word_t *block, unsigned *first, bm::id64_t digest) noexcept
BIT block find the first set bit if only 1 bit is set.
int wordcmp(T a, T b) noexcept
Lexicographical comparison of two words as bit strings. Auxiliary implementation for testing and refe...
bm::id_t bit_operation_sub_any(const bm::word_t *src1, const bm::word_t *src2) noexcept
Performs bitblock test of SUB operation.
bm::id64_t bit_block_sub_2way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2, bm::id64_t digest) noexcept
digest based bitblock SUB (AND NOT) operation (3 operand)
bm::id64_t bit_block_sub_5way(bm::word_t *dst, const bm::word_t *src0, const bm::word_t *src1, const bm::word_t *src2, const bm::word_t *src3, bm::id64_t digest) noexcept
digest based bit-block SUB 5-way
bm::word_t * bit_operation_or(bm::word_t *dst, const bm::word_t *src) noexcept
Block OR operation. Makes analysis if block is 0 or FULL.
void block_expand_by_digest(bm::word_t *t_block, const bm::word_t *block, bm::id64_t digest, bool zero_subs) noexcept
expand sub-blocks by digest (rank expansion)
bm::id64_t bit_block_init_and_2way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2, bm::id64_t digest) noexcept
digest based bit-block AND (0 elements of digest will be zeroed)
bool bit_block_find_prev(const bm::word_t *block, unsigned nbit, unsigned *pos) noexcept
Reverse search for the previous 1 bit.
unsigned bit_block_xor_count(const bm::word_t *src1, const bm::word_t *src2) noexcept
Function XORs two bitblocks and computes the bitcount. Function does not analyse availability of sour...
bool bit_block_is_all_one_range(const bm::word_t *const block, bm::word_t left, bm::word_t right) noexcept
bm::id_t bit_operation_or_count(const bm::word_t *src1, const bm::word_t *src2) noexcept
Performs bitblock OR operation and calculates bitcount of the result.
unsigned bit_block_calc_change(const bm::word_t *block) noexcept
bm::id64_t calc_block_digest0(const bm::word_t *const block) noexcept
Compute digest for 64 non-zero areas.
void bit_block_rotate_left_1(bm::word_t *block) noexcept
unsigned bit_count_min_unroll(const bm::word_t *block, const bm::word_t *block_end) noexcept
Bitcount for bit block without agressive unrolling.
unsigned bit_block_or_count(const bm::word_t *src1, const bm::word_t *src2) noexcept
Function ORs two bitblocks and computes the bitcount. Function does not analyse availability of sourc...
bool check_zero_digest(bm::id64_t digest, unsigned bitpos_from, unsigned bitpos_to) noexcept
check if all digest bits for the range [from..to] are 0
bm::id64_t bit_block_and_5way(bm::word_t *dst, const bm::word_t *src0, const bm::word_t *src1, const bm::word_t *src2, const bm::word_t *src3, bm::id64_t digest) noexcept
digest based bit-block AND 5-way
bm::id64_t bit_block_xor_2way(bm::word_t *dst, const bm::word_t *src1, const bm::word_t *src2) noexcept
2 way (target := source1 ^ source2) bitblock XOR operation.
bm::id_t bit_operation_and_count(const bm::word_t *src1, const bm::word_t *src2) noexcept
Performs bitblock AND operation and calculates bitcount of the result.
bm::id64_t bit_block_sub(bm::word_t *dst, const bm::word_t *src) noexcept
Plain bitblock SUB (AND NOT) operation. Function does not analyse availability of source and destinat...
unsigned short bitscan_popcnt(bm::id_t w, B *bits, unsigned short offs) noexcept
Unpacks word into list of ON bit indexes using popcnt method.
operation
Bit operations.
set_operation
Codes of set operations.
bm::id_t gap_bitset_sub_any(const unsigned *block, const T *buf) noexcept
Compute bitcount test of bit block SUB masked by GAP block.
unsigned gap_operation_any_xor(const gap_word_t *vect1, const gap_word_t *vect2) noexcept
GAP XOR operation test.
bool gap_any_range(const T *const buf, unsigned left, unsigned right) noexcept
Test if any bits are 1 in GAP buffer in the [left, right] range.
unsigned gap_bit_count_range(const T *const buf, unsigned left, unsigned right) noexcept
Counts 1 bits in GAP buffer in the closed [left, right] range.
unsigned gap_limit(const T *buf, const T *glevel_len) noexcept
Returs GAP block capacity limit.
unsigned gap_overhead(const T *length, const T *length_end, const T *glevel_len) noexcept
Calculates memory overhead for number of gap blocks sharing the same memory allocation table (level l...
bool gap_is_all_one(const bm::gap_word_t *buf) noexcept
Checks if GAP block is all-one.
gap_word_t * gap_operation_xor(const gap_word_t *vect1, const gap_word_t *vect2, gap_word_t *tmp_buf, unsigned &dsize) noexcept
GAP XOR operation.
unsigned gap_count_or(const gap_word_t *vect1, const gap_word_t *vect2) noexcept
GAP bitcount OR operation test.
unsigned gap_free_elements(const T *buf, const T *glevel_len) noexcept
Returns number of free elements in GAP block array. Difference between GAP block capacity on this lev...
bool gap_shift_r1(T *buf, unsigned co_flag, unsigned *new_len) noexcept
Right shift GAP block by 1 bit.
bool gap_find_first_diff(const T *buf1, const T *buf2, unsigned *pos) noexcept
Find first bit which is different between two GAP-blocks.
void gap_invert(T *buf) noexcept
Inverts all bits in the GAP buffer.
bm::id_t gap_bitset_xor_count(const unsigned *block, const T *buf) noexcept
Compute bitcount of bit block XOR masked by GAP block.
void gap_add_to_bitset(unsigned *dest, const T *pcurr, unsigned len) noexcept
Adds(OR) GAP block to bitblock.
void set_gap_level(T *buf, int level) noexcept
Sets GAP block capacity level.
void gap_init_range_block(T *buf, T from, T to, T value) noexcept
Init gap block so it has block in it (can be whole block)
unsigned gap_set_array(T *buf, const T *arr, unsigned len) noexcept
Convert array to GAP buffer.
gap_word_t * gap_operation_or(const gap_word_t *vect1, const gap_word_t *vect2, gap_word_t *tmp_buf, unsigned &dsize) noexcept
GAP OR operation.
unsigned gap_test(const T *buf, unsigned pos) noexcept
Tests if bit = pos is true.
bm::id_t gap_bitset_sub_count(const unsigned *block, const T *buf) noexcept
Compute bitcount of bit block SUB masked by GAP block.
void gap_validate(const T *buf, unsigned dsize=0) noexcept
Validates GAP block.
unsigned gap_count_xor(const gap_word_t *vect1, const gap_word_t *vect2) noexcept
GAP bitcount XOR operation test.
bool improve_gap_levels(const T *length, const T *length_end, T *glevel_len) noexcept
Finds optimal gap blocks lengths.
unsigned gap_bit_count(const T *buf, unsigned dsize=0) noexcept
Calculates number of bits ON in GAP buffer.
unsigned gap_control_sum(const T *buf) noexcept
Calculates sum of all words in GAP block. (For debugging purposes)
unsigned gap_test_unr(const T *buf, const unsigned pos) noexcept
Tests if bit = pos is true. Analog of bm::gap_test with SIMD unrolling.
bool gap_is_all_zero(const bm::gap_word_t *buf) noexcept
Checks if GAP block is all-zero.
void gap_convert_to_bitset(unsigned *dest, const T *buf, unsigned len=0) noexcept
GAP block to bitblock conversion.
gap_word_t * gap_operation_sub(const gap_word_t *vect1, const gap_word_t *vect2, gap_word_t *tmp_buf, unsigned &dsize) noexcept
GAP SUB (AND NOT) operation.
unsigned gap_buff_any_op(const T *vect1, unsigned vect1_mask, const T *vect2, unsigned vect2_mask)
Abstract distance test operation for GAP buffers. Receives functor F as a template argument.
void for_each_gap_dbit(const T *buf, F &func)
Iterate gap block as delta-bits with a functor.
unsigned gap_count_sub(const gap_word_t *vect1, const gap_word_t *vect2) noexcept
GAP bitcount SUB (AND NOT) operation test.
void gap_xor_to_bitset(unsigned *dest, const T *pcurr) noexcept
XOR GAP block to bitblock.
bool gap_find_prev(const T *const buf, unsigned nbit, unsigned *pos) noexcept
reverse search for the first 1 bit of a GAP block
unsigned gap_set_value_cpos(unsigned val, T *buf, unsigned pos, unsigned *is_set, unsigned curr) noexcept
Sets or clears bit in the GAP buffer.
gap_word_t * gap_operation_and(const gap_word_t *vect1, const gap_word_t *vect2, gap_word_t *tmp_buf, unsigned &dsize) noexcept
GAP AND operation.
bm::id_t gap_bitset_xor_any(const unsigned *block, const T *buf) noexcept
Compute bitcount test of bit block XOR masked by GAP block.
SIZE_TYPE gap_find_rank(const T *const block, SIZE_TYPE rank, unsigned nbit_from, unsigned &nbit_pos) noexcept
GAP block find position for the rank.
unsigned gap_bit_count_unr(const T *buf) noexcept
Calculates number of bits ON in GAP buffer. Loop unrolled version.
unsigned arr_calc_delta_min_w(const T *arr, unsigned arr_len, unsigned wlen, unsigned min0, unsigned *wflags) noexcept
calculate minimal delta between monotonic growing numbers with windows
unsigned gap_operation_any_and(const gap_word_t *vect1, const gap_word_t *vect2) noexcept
GAP AND operation test.
unsigned gap_set_value(unsigned val, T *buf, unsigned pos) noexcept
Sets or clears bit in the GAP buffer.
bm::id_t gap_bitset_or_count(const unsigned *block, const T *buf) noexcept
Compute bitcount of bit block OR masked by GAP block.
unsigned gap_find_first(const T *buf, unsigned *first) noexcept
GAP block find the first set bit.
bm::id_t gap_bitset_and_count(const unsigned *block, const T *pcurr) noexcept
Compute bitcount of bit block AND masked by GAP block.
unsigned gap_find_last(const T *buf, unsigned *last) noexcept
GAP block find the last set bit.
bool gap_split(const T *buf, unsigned len, unsigned h_limit, const unsigned *hist0, const unsigned *hist1, T *tbuf, T *ex0_arr, T *ex1_arr, unsigned &ex0_cnt, unsigned &ex1_cnt) noexcept
split GAP block into pure GAPs and exceptions
unsigned gap_capacity(const T *buf, const T *glevel_len) noexcept
Returs GAP block capacity.
T gap_level(const T *buf) noexcept
Returs GAP blocks capacity level.
unsigned gap_block_find(const T *buf, unsigned nbit, bm::id_t *prev) noexcept
Searches for the next 1 bit in the GAP block.
int gap_calc_level(unsigned len, const T *glevel_len) noexcept
Calculates GAP block capacity level.
unsigned gap_count_and(const gap_word_t *vect1, const gap_word_t *vect2) noexcept
GAP bitcount AND operation test.
unsigned bit_block_to_gap(gap_word_t *dest, const unsigned *block, unsigned dest_len) noexcept
Converts bit block to GAP.
bool gap_is_all_one_range(const T *const buf, unsigned left, unsigned right) noexcept
Test if all bits are 1 in GAP buffer in the [left, right] range.
bool arr_calc_delta_min(const T *arr, unsigned arr_len, T &min0) noexcept
calculate minimal delta between monotonic growing numbers
bm::id_t gap_bitset_and_any(const unsigned *block, const T *pcurr) noexcept
Bitcount test of bit block AND masked by GAP block.
bool gap_find_interval_end(const T *const buf, unsigned nbit, unsigned *pos) noexcept
Searches for the last 1 bit in the 111 interval of a GAP block.
unsigned gap_operation_any_sub(const gap_word_t *vect1, const gap_word_t *vect2) noexcept
GAP SUB operation test.
bm::id_t gap_bitset_or_any(const unsigned *block, const T *buf) noexcept
Compute bitcount test of bit block OR masked by GAP block.
bool gap_shift_l1(T *buf, unsigned co_flag, unsigned *new_len) noexcept
Left shift GAP block by 1 bit.
void gap_calc_mins(const T *buf, T &min0, T &min1) noexcept
minimal delta sizes
void gap_calc_hist(const T *buf, unsigned len, unsigned *hist0, unsigned *hist1, unsigned hist_len) noexcept
compute histogram of exceptions on GAP block
void gap_and_to_bitset(unsigned *dest, const T *pcurr) noexcept
ANDs GAP block to bitblock.
void gap_restore_mins(T *buf, T min0, T min1) noexcept
Restore GAP block using two minimal GAP lens.
bool gap_find_interval_start(const T *const buf, unsigned nbit, unsigned *pos) noexcept
Searches for the first 1 bit in the 111 interval of a GAP block.
int gapcmp(const T *buf1, const T *buf2) noexcept
Lexicographical comparison of GAP buffers.
T gap_recalc_mins(T *tbuf, const T *buf, T min0, T min1) noexcept
Recalculate GAP block using two minimal GAP lens.
unsigned gap_bit_count_range_hint(const T *const buf, unsigned left, unsigned right, unsigned hint) noexcept
Counts 1 bits in GAP buffer in the closed [left, right] range using position hint to avoid bfind.
bm::gap_word_t gap_length(const bm::gap_word_t *buf) noexcept
Returs GAP block length.
void gap_set_all(T *buf, unsigned set_max, unsigned value) noexcept
Sets all bits to 0 or 1 (GAP)
void gap_sub_to_bitset(unsigned *dest, const T *pcurr) noexcept
SUB (AND NOT) GAP block to bitblock.
bool gap_is_interval(const T *const buf, unsigned left, unsigned right) noexcept
Test if any bits are 1 in GAP buffer in the [left, right] range and flanked with 0s.
unsigned * gap_convert_to_bitset_smart(unsigned *dest, const T *buf, id_t set_max) noexcept
Smart GAP block to bitblock conversion.
unsigned bit_array_compute_gaps(const T *arr, unsigned len) noexcept
Compute number of GAPs in bit-array.
unsigned gap_buff_count_op(const T *vect1, const T *vect2)
Abstract distance(similarity) operation for GAP buffers. Receives functor F as a template argument.
D gap_convert_to_arr(D *dest, const T *buf, unsigned dest_len, bool invert=false) noexcept
Convert gap block into array of ints corresponding to 1 bits.
unsigned gap_add_value(T *buf, unsigned pos) noexcept
Add new value to the end of GAP buffer.
void arr_delta1_split(T *arr_d1, unsigned &d1_len, T *arr_dst, unsigned &dst_len, const T *arr, unsigned arr_len, unsigned ex_max_delta) noexcept
split array based on delta exceptions
bool gap_insert(T *buf, unsigned pos, unsigned val, unsigned *new_len) noexcept
isnert bit into GAP compressed block
unsigned int
A callback function used to compare two keys in a database.
const unsigned set_array_mask
bool block_ptr_array_range(bm::word_t **arr, unsigned &left, unsigned &right) noexcept
array range detector
const unsigned set_block_digest_wave_size
void for_each_nzblock(T ***root, unsigned size1, F &f)
SIZE_TYPE block_find_rank(const bm::word_t *const block, SIZE_TYPE rank, unsigned nbit_from, unsigned &nbit_pos) noexcept
Find rank in block (GAP or BIT)
bm::id_t(* bit_operation_count_func_type)(const bm::word_t *, const bm::word_t *)
void arr_restore_min_w(T *arr, unsigned arr_len, unsigned wlen, T min0, const unsigned *wflags) noexcept
Restore array using two minimal delta for better BIC compression.
SZ count_nz(const VT *arr, SZ arr_size) noexcept
Find count of non-zero elements in the array.
void bit_recomb(It1 &it1, It2 &it2, BinaryOp &op, Encoder &enc, unsigned block_size=bm::set_block_size) noexcept
bool block_find_reverse(const bm::word_t *block, unsigned nbit_from, unsigned *found_nbit) noexcept
Reverse find 1.
const unsigned set_block_mask
const bm::gap_word_t * avx2_gap_sum_arr(const bm::gap_word_t *pbuf, unsigned avx_vect_waves, unsigned *sum)
bm::id64_t dm_control(unsigned from, unsigned to) noexcept
digest mask control generation (for debug and test only)
bool find_not_null_ptr(const bm::word_t *const *const *arr, N start, N size, N *pos) noexcept
unsigned lower_bound_linear_u64(const unsigned long long *arr, unsigned long long target, unsigned from, unsigned to) noexcept
Linear lower bound search in unsigned LONG array.
unsigned gap_bit_count_to(const T *const buf, T right) noexcept
void gap_buff_op(T *dest, const T *vect1, unsigned vect1_mask, const T *vect2, unsigned vect2_mask, unsigned &dlen)
Abstract operation for GAP buffers. Receives functor F as a template argument.
bool block_any(const bm::word_t *const block) noexcept
Returns "true" if one bit is set in the block Function check for block varieties.
T arr_recalc_min(T *tarr, const T *arr, unsigned arr_len, T min0, T delta_acc=0) noexcept
Recalculate array using minimal delta for better BIC compression.
const unsigned set_sub_array_size
bm::id64_t sum_arr(const T *first, const T *last) noexcept
void get_block_coord(BI_TYPE nb, unsigned &i, unsigned &j) noexcept
Recalc linear bvector block index into 2D matrix coordinates.
unsigned bit_block_change64(const bm::word_t *in_block, unsigned size) noexcept
bool check_block_zero(const bm::word_t *blk, bool deep_scan) noexcept
Checks all conditions and returns true if block consists of only 0 bits.
bm::id_t block_to_global_index(unsigned i, unsigned j, unsigned block_idx) noexcept
calculate bvector<> global bit-index from block-local coords
void for_each_dgap(const T *gap_buf, Func &func)
bool find_first_nz(const VT *arr, SZ arr_size, SZ *found_idx) noexcept
Find max non-zero value in an array.
bm::id64_t idx_arr_block_lookup_u64(const bm::id64_t *idx, bm::id64_t size, bm::id64_t nb, bm::id64_t start) noexcept
block boundaries look ahead U32
bool is_const_set_operation(bm::set_operation op) noexcept
Returns true if set operation is constant (bitcount)
unsigned count_trailing_zeros_u64(bm::id64_t w) noexcept
64-bit bit-scan fwd
void for_each_nzblock_range(T ***root, N top_size, N nb_from, N nb_to, F &f) noexcept
RTYPE get_super_block_start(unsigned i) noexcept
Compute bit address of the first bit in a superblock.
unsigned bit_block_change32(const bm::word_t *block, unsigned size) noexcept
set_representation
set representation variants
@ set_gap
GAP-RLE compression.
@ set_bitset
Simple bitset.
@ set_array1
array of set 1 values
@ set_array0
array of 0 values
bool block_is_all_one_range(const bm::word_t *const block, unsigned left, unsigned right) noexcept
Returns "true" if all bits are 1 in the block [left, right] Function check for block varieties.
void simple_swap(T *a, T *b) noexcept
swap function for simple types
unsigned long long bmi_bslr_u64(unsigned long long w) noexcept
void bit_block_ex0_split(unsigned *block, T *arr_ex0, unsigned &ex0_cnt, bool inverted) noexcept
Extract standalone 0s out of bit-block.
unsigned block_find_interval_start(const bm::word_t *block, unsigned nbit_from, unsigned *found_nbit) noexcept
Find start of the current 111 interval.
bool check_block_one(const bm::word_t *blk, bool deep_scan) noexcept
Checks if block has only 1 bits.
bool bit_block_ex0_split_check(const unsigned *, const unsigned *tb, const T *ex0_arr, unsigned ex0_cnt) noexcept
validate split results (for DEBUGGING)
bm::id64_t ptrp_test(ptr_payload_t ptr, bm::gap_word_t v) noexcept
bool find_max_nz(const VT *arr, SZ arr_size, SZ *found_idx) noexcept
Find max non-zero value in an array.
bool find_ptr(const void *const *p_arr, size_t arr_size, const void *ptr, size_t *idx) noexcept
Scan search for pointer value in unordered array.
void bit_block_change_bc(const bm::word_t *block, unsigned *gc, unsigned *bc) noexcept
unsigned idx_arr_block_lookup_u32(const unsigned *idx, unsigned size, unsigned nb, unsigned start) noexcept
block boundaries look ahead U32
const unsigned gap_levels
gap_word_t *(* gap_operation_func_type)(const gap_word_t *, const gap_word_t *, gap_word_t *, unsigned &)
void for_each_nzblock2(T ***root, unsigned size1, F &f)
F bmfor_each(T first, T last, F f)
bool compute_wdr_params(const T *arr, unsigned sz, bm::word_t *tb_wflags, unsigned min0, unsigned &win_size, float &best_save)
unsigned bitscan_nibble(unsigned w, unsigned *bits) noexcept
portable, switch based bitscan
void set_nibble(unsigned char *arr, unsigned idx, unsigned char v) noexcept
set nibble in the array
const unsigned set_word_shift
unsigned char get_nibble(const unsigned char *arr, unsigned idx) noexcept
get nibble from the array
unsigned arr_cnt_zero_splits(T *arr, unsigned sz) noexcept
const unsigned set_sub_total_bits
const unsigned set_block_digest_pos_shift
bool for_each_nzblock_if(T ***root, BI size1, F &f) noexcept
const unsigned set_block_size
unsigned bit_to_gap(gap_word_t *dest, const unsigned *block, unsigned dest_len) noexcept
Convert bit block to GAP representation.
unsigned long long int id64_t
const unsigned block_waves
bool block_is_interval(const bm::word_t *const block, unsigned left, unsigned right) noexcept
Returns "true" if all bits are 1 in the block [left, right] and border bits are 0.
unsigned gap_bfind(const T *buf, unsigned pos, unsigned *is_set) noexcept
void arr_restore_min(T *arr, unsigned arr_len, T min0, T delta_acc=0) noexcept
Restore array using two minimal delta for better BIC compression.
bool block_find_first_diff(const bm::word_t *blk, const bm::word_t *arg_blk, unsigned *pos) noexcept
Find first bit which is different between two blocks (GAP or bit)
const unsigned gap_max_buff_len
unsigned mask_r_u32(unsigned nbit) noexcept
bm::operation setop2op(bm::set_operation op) noexcept
Convert set operation to operation.
bit_representation
Possible representations for bit sets.
@ e_bit_bit
uncompressed bit-block
@ e_bit_0
all 0s (empty block)
@ e_bit_IINT
Inverted int list.
unsigned bit_scan_forward32(unsigned w) noexcept
bool is_digest_one_range(bm::id64_t digest) noexcept
Is one range of 1s ( 0000110000 - one range, 000011000010 - more than one)
unsigned lower_bound_u32(const unsigned *arr, unsigned target, unsigned from, unsigned to) noexcept
Hybrid, binary-linear lower bound search in unsigned array.
int parallel_popcnt_32(unsigned int n) noexcept
32-bit paralle, bitcount
void dgap_2_gap(const T *dgap_buf, T *gap_buf, T gap_header=0) noexcept
Convert D-GAP buffer into GAP buffer.
void sse4_bit_block_gather_scatter(unsigned *arr, const unsigned *blk, const unsigned *idx, unsigned size, unsigned start, unsigned bit_idx) noexcept
unsigned lower_bound_linear_u32(const unsigned *arr, unsigned target, unsigned from, unsigned to) noexcept
Linear lower bound search in unsigned array.
const unsigned short set_bitscan_wave_size
Size of bit decode wave in words.
const unsigned set_array_shift
unsigned min_delta_u32(const unsigned *arr, size_t arr_size)
Calculate minimal delta between elements of sorted array.
unsigned short gap_word_t
bool debug_check_count_range(const T *const buf, const unsigned left, const unsigned start_pos, const unsigned is_set) noexcept
Debug function for verification in DEBUG mode.
void(* gap_operation_to_bitset_func_type)(unsigned *, const gap_word_t *)
T arr_recalc_min_w(T *tarr, const T *arr, unsigned arr_len, unsigned wlen, T min0, const unsigned *wflags) noexcept
Recalculate array using two minimal delta for better BIC compression.
unsigned block_find_interval_end(const bm::word_t *block, unsigned nbit_from, unsigned *found_nbit) noexcept
Find end of the current 111 interval.
void avx2_bit_block_gather_scatter(unsigned *arr, const unsigned *blk, const unsigned *idx, unsigned size, unsigned start, unsigned bit_idx)
const unsigned gap_max_bits
void set_block_bits_u64(bm::word_t *block, const bm::id64_t *idx, bm::id64_t start, bm::id64_t stop) noexcept
set bits in a bit-block using global index
void for_each_block(T ***root, unsigned size1, F &f, BLOCK_IDX start)
const word_t all_bits_mask
const unsigned set_block_shift
void set_block_bits_u32(bm::word_t *block, const unsigned *idx, unsigned start, unsigned stop) noexcept
set bits in a bit-block using global index
T * gap_2_dgap(const T *gap_buf, T *dgap_buf, bool copy_head=true) noexcept
Convert GAP buffer into D-GAP buffer.
const unsigned set_word_mask
unsigned count_leading_zeros_u64(bm::id64_t w) noexcept
64-bit bit-scan reverse
unsigned count_trailing_zeros_u32(unsigned w) noexcept
32-bit bit-scan fwd
void quick_sort2(T *arr, int first, int last) noexcept
simple recursive quick-sort for short integer arrays
unsigned calc_hist_limit(const unsigned *hist0, const unsigned *hist1, unsigned hist_len, unsigned ex_limit, unsigned *ex_sum) noexcept
claculate the effective exceptions limit using two histograms
void min_delta_apply(unsigned *arr, size_t arr_size, unsigned delta) noexcept
Recalculate the array to decrement delta as arr[i] = arr[i] - delta + 1 so that array remains monoton...
const unsigned bits_in_block
bool block_any_range(const bm::word_t *const block, unsigned left, unsigned right) noexcept
Returns "true" if one bit is set in the block [left, right] Function check for block varieties.
const bm::gap_word_t * sse2_gap_sum_arr(const bm::gap_word_t *BMRESTRICT pbuf, unsigned sse_vect_waves, unsigned *sum) BMNOEXCEPT
Gap block population count (array sum) utility.
unsigned long long bmi_blsi_u64(unsigned long long w)
unsigned bit_scan_reverse32(unsigned w) noexcept
RTYPE get_block_start(unsigned i, unsigned j) noexcept
Compute bit address of the first bit in a block.
unsigned mask_l_u32(unsigned nbit) noexcept
unsigned lower_bound_u64(const unsigned long long *arr, unsigned long long target, unsigned from, unsigned to) noexcept
Hybrid, binary-linear lower bound search in unsigned LONG array.
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
#define F(x)
Make a parametrized function appear to have only one variable.
Int4 delta(size_t dimension_, const Int4 *score_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static SLJIT_INLINE sljit_ins st(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
static int _mm_test_all_zeros(__m128i a, __m128i mask)
static __m128i _mm_loadu_si128(const __m128i *p)
static __m128i _mm_load_si128(const __m128i *p)
static int _mm_testz_si128(__m128i a, __m128i b)
static int64_t _mm_popcnt_u64(uint64_t a)
bm::word_t _p[bm::set_block_size]
Structure carries pointer on bit block with all bits 1.
static bool is_valid_block_addr(const bm::word_t *bp) noexcept
static bool is_full_block(const bm::word_t *bp) noexcept
static bm::id64_t block_type(const bm::word_t *bp) noexcept
static all_set_block _block
W operator()(W w1, W w2) noexcept
W operator()(W, W w2) noexcept
W operator()(W w1, W w2) noexcept
W operator()(W w1, W) noexcept
W operator()(W, W w2) noexcept
W operator()(W w1, W w2) noexcept
Bit COUNT SUB AB functor.
W operator()(W w1, W w2) noexcept
W operator()(W w1, W w2) noexcept
W operator()(W w1, W w2) noexcept
W operator()(W w1, W w2) noexcept
W operator()(W w1, W w2) noexcept
W operator()(W w1, W w2) noexcept
W operator()(W w1, W w2) noexcept
bit-block array wrapped into union for correct interpretation of 32-bit vs 64-bit access vs SIMD
bit-decode cache structure
Structure with statistical information about memory allocation for arena based vectors.
size_t bit_blocks_sz
Total size of bit blocks.
size_t gap_blocks_sz
Total size of gap blocks.
size_t ptr_sub_blocks_sz
Total size of sub-blocks ptrs.
size_t get_alloc_size() const noexcept
Get allocation size in bytes.
unsigned top_block_size
size of top descriptor
void reset() noexcept
Reset statisctics.
Structure with statistical information about memory allocation footprint, serialization projection,...
size_t gap_cap_overhead
gap memory overhead between length and capacity
void add_gap_block(unsigned capacity, unsigned length, unsigned level) noexcept
count gap block
size_t ptr_sub_blocks
Number of sub-blocks.
unsigned long long gaps_by_level[bm::gap_levels]
number of GAP blocks at each level
size_t gap_blocks
Number of GAP blocks.
size_t bit_blocks
Number of bit blocks.
void add(const bv_statistics &st) noexcept
Sum data from another sttructure.
size_t bv_count
Number of bit-vectors.
void add_scorrection() noexcept
add serialization correction (sandbox for override)
void add_bit_block() noexcept
cound bit block
void reset() noexcept
Reset statisctics.
gap_word_t gap_levels[bm::gap_levels]
GAP block lengths in the bvect.
size_t max_serialize_mem
estimated maximum memory for serialization
size_t memory_used
memory usage for all blocks and service tables
Basic stats on second level group of blocks.
bm::gap_word_t bit_blocks
Number of bit blocks.
size_t gap_len_sum
total length of all GAPs
unsigned avg_gap_len() const noexcept
average length of GAP blocks
bm::gap_word_t empty_blocks
how many empty
void init(void *bv, unsigned i) noexcept
unsigned bc_arr[bm::set_sub_array_size]
unsigned gc_arr[bm::set_sub_array_size]
const bm::word_t * blocks[bm::set_sub_array_size]
void * bv_ptr
pointer to bit-vector
bm::gap_word_t gap_blocks
Number of GAP blocks.
unsigned top_level_idx
index of the sub-block of blocks
bool is_only_gaps() const noexcept
true if sub contains multiple gap blocks and nothing else
bm::gap_word_t full_blocks
how many FULL blocks
Alternative GAP lengths table. Good for for memory saver mode and very sparse bitsets.
static bit_operation_count_func_type bit_operation_count(unsigned i)
static gap_operation_to_bitset_func_type gap_op_to_bit(unsigned i)
static bit_operation_count_func_type bit_op_count_table_[bm::set_END]
static gap_operation_func_type gap_operation(unsigned i)
static gap_operation_func_type gapop_table_[bm::set_END]
static gap_operation_to_bitset_func_type gap2bit_table_[bm::set_END]
helper union to interpret pointer as integers
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4