Arithmetic coding/As a generalized change of radix: Difference between revisions
Arithmetic coding/As a generalized change of radix (view source)
Revision as of 07:30, 1 February 2016
, 8 years agoJ: rearrange code slightly for minor efficiency gain and cohesive presentation
m (→{{header|J}}) |
m (J: rearrange code slightly for minor efficiency gain and cohesive presentation) |
||
Line 194:
<lang J>aek=:3 :0
b=. x:#y NB. numeric base
i=. u i.y NB. character indices into uniques
n=. #/.~y NB. frequencies of uniques
o=. /:
f=. i{n NB. frequencies of characters▼
c=. i{(+/\0,}:o{n)/:o NB. cumulative frequencies of characters
▲ f=. i{n NB. frequencies of characters
L=. b #. c**/\1,}:f NB. lower bound
p=. */f NB. product of frequencies of characters
|