arcmak.cpp
来自「This document is intended to serve as an」· C++ 代码 · 共 20 行
CPP
20 行
/* From NR book: 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 lowsignificance
digits are added. minint must be large enough to provide resolution of
all the input characters. That is, we must have pi
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?