Sieve of Pritchard: Difference between revisions

m
Line 229:
}
 
void Compress(uint32_t w[], uint32_t length, uint32_t N, bool d[], uint32_t imaxto, uint32_t &w_end) {
/* Removes deleted values in w[0..imaxto], and if length < Nto=w_end, updates w_end, otherwise pads with zeros on right */
uint32_t i, j;
j = 0;
for (i=1; i <= imaxto; i++) {
if (!d[w[i]]) w[++j] = w[i];{
w[++j] = w[i];
}
}
if (lengthto <== Nw_end) {
w_end = j;
} else {
for (uint32_t k=j+1; k <= imaxto; k++) w[k] = 0;
}
}
Line 272 ⟶ 274:
}
Delete(w, length, p, d, imaxf);
Compress(w, length, N, d, (length < N ? w_end : imaxf), w_end);
/* p = next(W, 1): */
p = w[1];
7

edits