Arithmetic coding/As a generalized change of radix: Difference between revisions
Arithmetic coding/As a generalized change of radix (view source)
Revision as of 12:44, 30 January 2016
, 8 years agoMinor simplifications
m (→{{header|Sidef}}: fix precedence issue) |
m (Minor simplifications) |
||
Line 258:
# frequencies of all previously occurring symbols
foreach my $c (@chars) {
$pf->bmul($freq{$c});
}
Line 278 ⟶ 277:
$enc *= $radix**$pow;
# Base
my $base = Math::BigInt->new(0);
$base += $_ for values %{$freq};
Line 312:
my $cv = $cf{$c};
my $rem = ($enc - $pow
$enc = $rem;
Line 377:
# frequencies of all previously occurring symbols
for @chars -> $c {
$pf *= %freq{$c};
}
Line 401 ⟶ 400:
my $enc = $encoding * $radix**$pow;
my $base
# Create the cumulative frequency table
Line 498 ⟶ 497:
# frequencies of all previously occurring symbols
for b in bytes:
pf *= freq[b]
Line 519 ⟶ 517:
enc *= radix**pow;
# Base
base = sum(freq.values())
Line 607 ⟶ 606:
# frequencies of all previously occurring symbols
bytes.each do |b|
pf *= freq[b]
end
Line 631 ⟶ 629:
enc *= radix**pow;
base = freq.values.reduce(:+)
# Create the cumulative frequency table
Line 728 ⟶ 726:
# frequencies of all previously occurring symbols
bytes.each { |b|
pf *= freq{b}
}
Line 747 ⟶ 744:
enc *= radix**pow;
# Create the cumulative frequency table
|