正在加载图片...
20.5 Arithmetic Coding 911 1.0 0.46 0.4033 0.37819 A A A A 0.9 0.45 0.3780 0.400 0.8 0.3778 0.44 0.7 E E 0.395 E 0.3776 E 0.43 http://www.nr.com or call 1-800-872- Permission is readable files 0.6 0.3774 0.42 0.5 0.390 0.3772 (including this one) granted fori 0.41 0.4 0.3770 internet 0.40 0.385 0.3 0.3768 from NUMERICAL RECIPES IN C: 0.39 0 0 0 0.2 0.3766 0.380 州pWer:s to -7423(North America t users to make one paper 0.1 0.38 0.3764 1988-1992 by Cambridge University Press.Programs U U U 0.0 0.37 0.3763 0.37630 send Figure 20.5.1. Arithmetic coding of the message "IOU."in the fictitious language Vowellish. Successive characters give successively finer subdivisions of the initial interval between 0 and 1.The final value can be output as the digits of a fraction in any desired radix.Note how the subinterval allocated to dir Copyright (C) to a character is proportional to its probability of occurrence. The routine arcmak constructs the cumulative frequency distribution table used ectcustser to partition the interval at each stage.In the principal routine arcode.when an THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521 interval of size jdif is to be partitioned in the proportions of some n to some ntot, say,then we must compute (n*jdif)/ntot.With integer arithmetic,the numerator v@cam is likely to overflow,and,unfortunately,an expression like jdif/(ntot/n)is not equivalent.In the implementation below,we resort to double precision floating .Further reproduction, 1988-1992 by Numerical Recipes arithmetic for this calculation.Not only is this inefficient,but different roundoff -43108-5 errors can(albeit very rarely)make different machines encode differently,though any one type of machine will decode exactly what it encoded,since identical roundoff (outside errors occur in the two processes.For serious use,one needs to replace this floating North Software. calculation with an integer computation in a double register(not available to the C programmer). The internally set variable minint,which is the minimum allowed number visit website of discrete steps between the upper and lower bounds,determines when new low- machine significance digits are added.minint must be large enough to provide resolution of all the input characters.That is,we must have pi x minint 1 for all i.A value of 100Nch,or 1.1/minpi,whichever is larger,is generally adequate.However,for safety,the routine below takes minint to be as large as possible,with the product minint*nradd just smaller than overflow.This results in some time inefficiency, and in a few unnecessary characters being output at the end of a message.You can20.5 Arithmetic Coding 911 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machine￾readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). 1.0 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.0 A E I O U A E I O U A E I O U A E I O U 0.46 0.42 0.41 0.37 0.385 0.380 0.4033 0.3763 0.37819 0.37630 0.3780 0.3764 0.44 0.43 0.390 0.395 0.400 0.3766 0.3768 0.3772 0.3774 0.3778 0.3776 0.45 0.40 0.39 0.38 0.3770 Figure 20.5.1. Arithmetic coding of the message “IOU...” in the fictitious language Vowellish. Successive characters give successively finer subdivisions of the initial interval between 0 and 1. The final value can be output as the digits of a fraction in any desired radix. Note how the subinterval allocated to a character is proportional to its probability of occurrence. The routine arcmak constructs the cumulative frequency distribution table used to partition the interval at each stage. In the principal routine arcode, when an interval of size jdif is to be partitioned in the proportions of some n to some ntot, say, then we must compute (n*jdif)/ntot. With integer arithmetic, the numerator is likely to overflow; and, unfortunately, an expression like jdif/(ntot/n) is not equivalent. In the implementation below, we resort to double precision floating arithmetic for this calculation. Not only is this inefficient, but different roundoff errors can (albeit very rarely) make different machines encode differently, though any one type of machine will decode exactly what it encoded, since identical roundoff errors occur in the two processes. For serious use, one needs to replace this floating calculation with an integer computation in a double register (not available to the C programmer). The internally set variable minint, which is the minimum allowed number of discrete steps between the upper and lower bounds, determines when new low￾significance digits are added. minint must be large enough to provide resolution of all the input characters. That is, we must have pi × minint > 1 for all i. A value of 100Nch, or 1.1/ min pi, whichever is larger, is generally adequate. However, for safety, the routine below takes minint to be as large as possible, with the product minint*nradd just smaller than overflow. This results in some time inefficiency, and in a few unnecessary characters being output at the end of a message. You can
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有