X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=XS.xs;fp=XS.xs;h=182c51458164d6297b5df83887f5a9b83d697211;hb=926e086550c525ae9cd07f7521e9c524ca9db607;hp=940807b509e110ac8e6f9bdf7b32aeccf36d908e;hpb=34876640088dd67fcc2c05119cab34cc9fa9a777;p=algorithm-bit-xs.git diff --git a/XS.xs b/XS.xs index 940807b..182c514 100644 --- a/XS.xs +++ b/XS.xs @@ -89,7 +89,7 @@ IV bit2d_query(bit2d *b, IV i1, IV i2) { while(i1) { i2 = i2c; while(i2) - ret += b->t[i1 * b->n + i2], i2 -= i2 & -i2; + ret += b->t[i1 * b->m + i2], i2 -= i2 & -i2; i1 -= i1 & -i1; } return ret; @@ -108,7 +108,7 @@ void bit2d_update(bit2d *b, IV i1, IV i2, IV value) { while(i1 < b->n) { i2 = i2c; while(i2 < b->m) - b->t[i1 * b->n + i2] += value, i2 += i2 & -i2; + b->t[i1 * b->m + i2] += value, i2 += i2 & -i2; i1 += i1 & -i1; } }