Anonymous user
Arithmetic coding/As a generalized change of radix: Difference between revisions
Arithmetic coding/As a generalized change of radix (view source)
Revision as of 10:04, 30 January 2016
, 8 years agosimplified the encoding loop a little bit
(added python) |
(simplified the encoding loop a little bit) |
||
Line 62:
// frequencies of all previously occurring symbols
bigBase := big.NewInt(int64(base))
bigLim := big.NewInt(int64(base - 1))▼
for
L.Mul(L, bigBase)
L.Add(L, x.Mul(x, pf))
pf.Mul(pf, big.NewInt(freq[
}
Line 256 ⟶ 246:
my %cf = cumulative_freq(\%freq);
#
my $
# Lower bound
Line 268 ⟶ 257:
# Each term is multiplied by the product of the
# frequencies of all previously occurring symbols
my $x = $cf{$
$L->
$pf->bmul($freq{$
}
Line 376 ⟶ 365:
my %cf = cumulative_freq(%freq);
#
my $
# Lower bound
Line 388 ⟶ 376:
# Each term is multiplied by the product of the
# frequencies of all previously occurring symbols
for
my $x = %cf{
$L
$pf *= %freq{
}
Line 498 ⟶ 486:
cf = cumulative_freq(freq)
#
# Lower bound
Line 510 ⟶ 497:
# Each term is multiplied by the product of the
# frequencies of all previously occurring symbols
for
x = cf[
lower
pf *= freq[
# Upper bound
Line 610 ⟶ 597:
cf = cumulative_freq(freq)
#
# Lower bound
Line 622 ⟶ 608:
# Each term is multiplied by the product of the
# frequencies of all previously occurring symbols
x = cf[
lower
pf *= freq[
end
Line 732 ⟶ 718:
var cf = cumulative_freq(freq)
#
var
# Lower bound
Line 744 ⟶ 729:
# Each term is multiplied by the product of the
# frequencies of all previously occurring symbols
var x =
L
pf *= freq{
}
|