You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
freqs[argmax] can be decremented below zero, causing encoding to fail. Here's one way to fix that:
// A symbol must have freq at least 1
for (int i = 0; i < num_symbols; i++) {
if (freqs[i] == 0) {
freqs[i] = 1;
freqs[argmax]--;
assert(freqs[argmax] >= 1);
argmax = (int)std::distance(freqs.begin(), std::max_element(freqs.begin(), freqs.end()));
}
}
The text was updated successfully, but these errors were encountered:
Hi,
freqs[argmax] can be decremented below zero, causing encoding to fail. Here's one way to fix that:
The text was updated successfully, but these errors were encountered: