63 __host__ __device__
void Gen(Cw cws[],
const int4 s0s[2], In a) {
65 int4 beta = {0, 0, 0, 0};
66 dpf.
Gen(cws, s0s, a, beta);
95 constexpr size_t N = 1ULL << in_bits;
98 ExpandTree(pt.b, s0, cws, pt.p + (N - 1));
101 for (
size_t j = N - 2; j < N - 1; --j) {
102 pt.p[j] = pt.p[2 * j + 1] ^ pt.p[2 * j + 2];
117 constexpr size_t N = 1ULL << in_bits;
118 In e =
static_cast<In
>(x) + 1;
121 if (e == 0 || e == N)
return pt.p[0];
125 for (
int i = 0; i < in_bits; ++i) {
126 bool e_bit = (e >> (in_bits - 1 - i)) & 1;
128 pi ^= pt.p[2 * cur + 1];
151 void EvalAll(
bool b, int4 s0,
const Cw cws[],
bool ys[]) {
152 constexpr size_t N = 1ULL << in_bits;
155 ExpandTree(b, s0, cws, ys);
160 for (
size_t x = 1; x < N; ++x) {
161 ys[x] = ys[x] ^ ys[x - 1];
174 void ExpandTree(
bool b, int4 s0,
const Cw cws[],
bool t[]) {
176 st = util::SetLsb(st, b);
178 assert(in_bits <
sizeof(
size_t) * 8);
180 size_t r = 1ULL << in_bits;
183 int par_depth_ = util::ResolveParDepth(par_depth);
187 ExpandTreeRec(st, cws, t, l, r, i, par_depth_);
190 void ExpandTreeRec(int4 st,
const Cw cws[],
bool t[],
size_t l,
size_t r,
int i,
int par_depth_) {
191 bool tc = util::GetLsb(st);
193 s = util::SetLsb(s,
false);
203 bool tl_cw = util::GetLsb(s_cw);
204 s_cw = util::SetLsb(s_cw,
false);
207 auto [sl, sr] = prg.Gen(s);
209 bool tl = util::GetLsb(sl);
210 sl = util::SetLsb(sl,
false);
211 bool tr = util::GetLsb(sr);
212 sr = util::SetLsb(sr,
false);
215 sl = util::Xor(sl, s_cw);
216 sr = util::Xor(sr, s_cw);
222 stl = util::SetLsb(stl, tl);
224 str = util::SetLsb(str, tr);
226 size_t mid = (l + r) / 2;
228 if (i < par_depth_) {
230 ExpandTreeRec(stl, cws, t, l, mid, i + 1, par_depth_);
232 ExpandTreeRec(str, cws, t, mid, r, i + 1, par_depth_);
235 ExpandTreeRec(stl, cws, t, l, mid, i + 1, par_depth_);
236 ExpandTreeRec(str, cws, t, mid, r, i + 1, par_depth_);
static bool Eval(const ParityTree &pt, In x)
Prefix-parity query on the parity segment tree.
Definition grotto_dcf.cuh:116
void Preprocess(ParityTree &pt, int4 s0, const Cw cws[])
Preprocess: expand DPF tree and build parity segment tree.
Definition grotto_dcf.cuh:94
void EvalAll(bool b, int4 s0, const Cw cws[], bool ys[])
Full domain evaluation.
Definition grotto_dcf.cuh:151