/* * inclusive partial sum (i.e. up to element i included) */ uint64_t psum(uint64_t i) const { assert(i<size_); i++; uint64_t s = 0; uint64_t pos = 0; // optimization for bitvectors for(uint64_t j = 0;j<(i/64)*(width_==1);++j){ s += __builtin_popcountll(words[j]); pos += 64; } s += width_>1 or i%64==0 ? 0 : __builtin_popcountll( words[i/64] & ((ulint(1) << (i%64))-1) ); // end optimization for bitvectors for(uint64_t j=pos;j<i*(width_>1);++j){ s += at(j); } return s; }
/* * return alphabet, INCLUDED BWT terminator */ set<char_type> get_alphabet(){ set<char_type> A(alphabet); A.insert(ulint(TERMINATOR)); return A; }