Group code for 1-bit cells

This commit is contained in:
Marshall Lochbaum 2022-11-09 19:56:52 -05:00
parent 6eb504118e
commit a3da018055

View File

@ -13,8 +13,8 @@
// If ∧´1↓»⊸<𝕨, that is, ∧⊸≡𝕨, each result array is a slice of 𝕩 // If ∧´1↓»⊸<𝕨, that is, ∧⊸≡𝕨, each result array is a slice of 𝕩
// COULD use slice types; seems dangerous--when will they be freed? // COULD use slice types; seems dangerous--when will they be freed?
// Remaining cases copy cells from 𝕩 individually // Remaining cases copy cells from 𝕩 individually
// CPU-sized cells handled quickly // Converts 𝕨 to i32, COULD handle smaller types
// SHOULD use bit ops for 1-bit cells // CPU-sized cells handled quickly, 1-bit with bitp_get/set
// SHOULD use memcpy and bit_cpy for other sizes // SHOULD use memcpy and bit_cpy for other sizes
#include "../core.h" #include "../core.h"
@ -158,7 +158,7 @@ static B group_simple(B w, B x, ur xr, usz wia, usz xia, usz* xsh, u8 we) {
} }
// Many ¯1s: filter out, then continue // Many ¯1s: filter out, then continue
if (xia>32 && neg>xia/4+xia/8) { if (xia>32 && neg>(bits?0:xia/4)+xia/8) {
if (wia>xia) w = take_c2(m_f64(0), m_f64(xia), w); if (wia>xia) w = take_c2(m_f64(0), m_f64(xia), w);
B m = ne_c2(m_f64(0), m_f64(-1), inc(w)); B m = ne_c2(m_f64(0), m_f64(-1), inc(w));
w = slash_c2(m_f64(0), inc(m), w); w = slash_c2(m_f64(0), inc(m), w);
@ -200,6 +200,13 @@ static B group_simple(B w, B x, ur xr, usz wia, usz xia, usz* xsh, u8 we) {
case 2: for (usz i = 0; i < xia; i++) { i32 n = wp[i]; if (n>=0) ((u32*)tyarr_ptr(rp[n]))[pos[n]++] = ((u32*)xp)[i]; } break; case 2: for (usz i = 0; i < xia; i++) { i32 n = wp[i]; if (n>=0) ((u32*)tyarr_ptr(rp[n]))[pos[n]++] = ((u32*)xp)[i]; } break;
case 3: for (usz i = 0; i < xia; i++) { i32 n = wp[i]; if (n>=0) ((u64*)tyarr_ptr(rp[n]))[pos[n]++] = ((u64*)xp)[i]; } break; case 3: for (usz i = 0; i < xia; i++) { i32 n = wp[i]; if (n>=0) ((u64*)tyarr_ptr(rp[n]))[pos[n]++] = ((u64*)xp)[i]; } break;
} }
} else if (xl == 0) { // 1-bit cells
u64* xp = bitarr_ptr(x);
allocBitGroups(rp, ria, z, xr, xsh, len, width);
for (usz i = 0; i < xia; i++) {
bool b = bitp_get(xp,i); i32 n = wp[i];
if (n>=0) bitp_set(bitarr_ptr(rp[n]), pos[n]++, b);
}
} else { // Generic case } else { // Generic case
for (usz i = 0; i < ria; i++) { for (usz i = 0; i < ria; i++) {
usz l = len[i]; usz l = len[i];