uint * new_seq = new uint[len];
sigma = 0;
for(uint i=0;i<n;i++){
- new_seq[i] = sequence[i];
+ new_seq[i] = sequence[i]+1;
sigma = max(sigma,new_seq[i]);
}
sigma++;
uint static_sequence_gmr::rank(uint c, uint j) {
-// c++;
+ c++;
uint i = j/chunk_length;
uint bp = (c)*(len/chunk_length);
uint rank_pos = B->select0(bp);
uint prev = rank_pos-bp+1;
uint sum = B->rank1(B->select0(bp+i)) - prev;
uint cr = chunk[i]->rank(c,j-i*chunk_length);
+ /*if(c==0) {
+ cout << "c=" << c << " j=" << j << endl;
+ cout << "i=" << i << endl;
+ cout << "bp=" << bp << endl;
+ cout << "rank_pos=" << rank_pos << endl;
+ cout << "prev=" << prev << endl;
+ cout << "sum=" << sum << endl;
+ cout << "cr=" << cr << endl;
+ }*/
return sum + cr;
}
uint static_sequence_gmr::select(uint c, uint j) {
-// c++;
+ c++;
uint rank_pos = B->select0(c*(len/chunk_length));
uint prev = B->rank1(rank_pos);
uint sel = prev+j;
uint desp = B->rank1(B->select0((i)))-prev;
if (desp+1==0) desp=0;
uint rchunk = i%(len/chunk_length);
+ /*if(j==90) {
+ cout << "------------------------------" << endl;
+ cout << "c=" << c << " j=" << j << endl;
+ cout << "chunk_length=" << chunk_length << endl;
+ cout << "rank_pos=" << rank_pos << endl;
+ cout << "prev=" << prev << endl;
+ cout << "sel=" << sel << endl;
+ cout << "block=" << block << endl;
+ cout << "i=" << i << endl;
+ cout << "desp=" << desp << endl;
+ cout << "rchunk=" << rchunk << endl;
+ cout << "j-desp=" << j-desp << endl;
+ }*/
return (rchunk*chunk_length)+chunk[rchunk]->select(c, j-desp);
}
uint static_sequence_gmr::access(uint j) {
- return chunk[j/chunk_length]->access(j%chunk_length);
+ return chunk[j/chunk_length]->access(j%chunk_length)-1;
}