@@ -82,7 +82,8 @@ $\operatorname{SPLIT}_C \in V_8 \rightarrow V_v$
82
82
- $W \in U_ {32}$, the window size
83
83
- $T \in U_ {32}$, the threshold
84
84
85
- The configuration must satisfy $S_ {\text{max}} \ge S_ {\text{min}} \ge W > 0$.
85
+ The configuration must satisfy $S_ {\text{max}} \ge S_ {\text{min}} > 0$ and $W >
86
+ 0$.
86
87
87
88
## Definitions
88
89
@@ -230,7 +231,7 @@ package `go4.org/rollsum`.
230
231
#### Rolling
231
232
232
233
` rrs ` is a family of _ rolling_ hashes. We can compute hashes in a
233
- rolling fashion by taking advantage of the fact that:
234
+ rolling fashion by taking advantage of the fact that, for $l \geq k \geq 0$ :
234
235
235
236
$a(k + 1, l + 1) = (a(k, l) - (X_k + c) + (X_ {l+1} + c)) \mod M$
236
237
@@ -246,6 +247,16 @@ So, a typical implementation will work like this:
246
247
$a(k + 1, l + 1)$ and $b(k + 1, l + 1)$. Then use those values to
247
248
compute $s(k + 1, l + 1)$ and also store them for future use.
248
249
250
+ In all cases the ring buffer should initially contain all zero bytes.
251
+
252
+ In some cases it's helpful to use the function $S(l) = s(l - W + 1, l)$, where
253
+ $W$ is the window size (see [ "Splitting"] ( #splitting ) above). This function can
254
+ be defined for all $l \geq 0$ by applying the previous formulas for $a(k, l)$
255
+ and $b(k, l)$ and putting $X_i = 0$ for all $i < 0$. The resulting values for
256
+ $S$ will be the same as when $a$ and $b$ are computed using the rolling
257
+ implementation just described, provided that the ring buffer is initially zeroed
258
+ as specified.
259
+
249
260
#### Choice of M
250
261
251
262
Choosing $M = 2^{16}$ has the advantages of simplicity and efficiency,
0 commit comments