14 m = *(INTEGER(AS_INTEGER(np)));
16 PROTECT(perm = NEW_INTEGER(m));
17 PROTECT(weights = AS_NUMERIC(weights));
30 for (j = 1; j < nw; j++) w[j] += w[j-1];
33 err(
"in 'systematic_resampling': non-positive sum of weights");
35 du = w[nw-1] / ((double) np);
38 for (i = 0, j = 0; j < np; j++) {
42 while ((u > w[i]) && (i < nw-1)) i++;
46 for (j = 0; j < np; j++) p[j] += offset;