在《小王子》这本书中,the little prince反复出现,设想应该可以把它做为新的符号,从而起到压缩的效果。
霍夫曼编码依赖现有的符号边界,而本文要研究的,是寻找更好的符号边界。
市场上并不缺少压缩算法,研究小王子压缩算法,是为了设计CPU最优指令集。
原文是:
the little prince goes here the little prince goes where the little prince said i am the little prince
压缩为:
the little prince goes here (28,23)w(29,5)(29,18)said i am(28,18)
字典里:
the little prince goes
here
the little prince
内迭代:
the little prince
goes
here
至此,找到了3个新的“符号”!用A,B,C表示。
压缩后的正文:
A B C A B wC A said i am A
有些时候字典过大,需要舍弃概率低的。
搜集代码库,运行小王子压缩算法,留在字典里的,正是指令集需要的。这么一来,就求出了最优指令集。