fix GroupLen properly
This commit is contained in:
parent
55f7baf894
commit
c1157f89a6
@ -150,22 +150,21 @@ B fill_c2(B t, B w, B x) { // TODO not set fill for typed arrays
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
B grLen_both(i64 ria, B x) {
|
B grLen_both(i64 ria, B x) { // assumes integer x
|
||||||
|
B r;
|
||||||
usz ia = IA(x);
|
usz ia = IA(x);
|
||||||
if (ia==0) return taga(arr_shVec(allZeroes(ria<=0? 0 : ria)));
|
if (ia==0) {
|
||||||
|
r = taga(arr_shVec(allZeroes(ria<=0? 0 : ria)));
|
||||||
|
goto r_r;
|
||||||
|
}
|
||||||
SGetU(x)
|
SGetU(x)
|
||||||
f64 xmaxf = -1;
|
f64 xmaxf = -1;
|
||||||
for (usz i = 0; i < ia; i++) {
|
for (usz i = 0; i < ia; i++) {
|
||||||
f64 c = o2fG(GetU(x, i));
|
f64 c = o2fG(GetU(x, i));
|
||||||
if (c>xmaxf) xmaxf = c;
|
if (c>xmaxf) xmaxf = c;
|
||||||
}
|
}
|
||||||
if (xmaxf >= USZ_MAX) thrOOM();
|
if (xmaxf >= USZ_MAX-1) thrOOM();
|
||||||
if ((i64)xmaxf > ria) {
|
if ((i64)xmaxf > ria-1) ria = 1 + (i64)xmaxf;
|
||||||
ria = (i64)xmaxf;
|
|
||||||
if (ria >= (i64)USZ_MAX) thrOOM();
|
|
||||||
}
|
|
||||||
ria++;
|
|
||||||
B r;
|
|
||||||
{
|
{
|
||||||
u64* rp; r = m_bitarrv(&rp, ria);
|
u64* rp; r = m_bitarrv(&rp, ria);
|
||||||
for (usz i = 0; i < BIT_N(ria); i++) rp[i] = 0;
|
for (usz i = 0; i < BIT_N(ria); i++) rp[i] = 0;
|
||||||
@ -187,8 +186,8 @@ B grLen_both(i64 ria, B x) {
|
|||||||
}
|
}
|
||||||
r_r: decG(x); return r;
|
r_r: decG(x); return r;
|
||||||
}
|
}
|
||||||
B grLen_c1(B t, B x) { return grLen_both( -1, x); } // assumes valid arguments
|
B grLen_c1(B t, B x) { return grLen_both( 0, x); }
|
||||||
B grLen_c2(B t, B w, B x) { return grLen_both(o2i64G(w)-1, x); } // assumes valid arguments
|
B grLen_c2(B t, B w, B x) { return grLen_both(o2i64G(w), x); }
|
||||||
|
|
||||||
B grOrd_c2(B t, B w, B x) { // assumes valid arguments
|
B grOrd_c2(B t, B w, B x) { // assumes valid arguments
|
||||||
usz wia = IA(w);
|
usz wia = IA(w);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user