|
1 #!/usr/bin/perl |
|
2 |
|
3 # |
|
4 # make-logtab |
|
5 # |
|
6 # Generate a table of logarithms of 2 in various bases, for use in |
|
7 # estimating the output sizes of various bases. |
|
8 |
|
9 # This Source Code Form is subject to the terms of the Mozilla Public |
|
10 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
11 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
12 |
|
13 $ARRAYNAME = $ENV{'ARRAYNAME'} || "s_logv_2"; |
|
14 $ARRAYTYPE = $ENV{'ARRAYTYPE'} || "float"; |
|
15 |
|
16 printf("const %s %s[] = {\n %0.9ff, %0.9ff, ", |
|
17 $ARRAYTYPE, $ARRAYNAME, 0, 0); |
|
18 $brk = 2; |
|
19 for($ix = 2; $ix < 64; $ix++) { |
|
20 printf("%0.9ff, ", (log(2)/log($ix))); |
|
21 $brk = ($brk + 1) & 3; |
|
22 if(!$brk) { |
|
23 printf(" /* %2d %2d %2d %2d */\n ", |
|
24 $ix - 3, $ix - 2, $ix - 1, $ix); |
|
25 } |
|
26 } |
|
27 printf("%0.9ff\n};\n\n", (log(2)/log($ix))); |
|
28 |
|
29 exit 0; |