michael@0: #!/usr/bin/perl michael@0: michael@0: # michael@0: # make-logtab michael@0: # michael@0: # Generate a table of logarithms of 2 in various bases, for use in michael@0: # estimating the output sizes of various bases. michael@0: michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: $ARRAYNAME = $ENV{'ARRAYNAME'} || "s_logv_2"; michael@0: $ARRAYTYPE = $ENV{'ARRAYTYPE'} || "float"; michael@0: michael@0: printf("const %s %s[] = {\n %0.9ff, %0.9ff, ", michael@0: $ARRAYTYPE, $ARRAYNAME, 0, 0); michael@0: $brk = 2; michael@0: for($ix = 2; $ix < 64; $ix++) { michael@0: printf("%0.9ff, ", (log(2)/log($ix))); michael@0: $brk = ($brk + 1) & 3; michael@0: if(!$brk) { michael@0: printf(" /* %2d %2d %2d %2d */\n ", michael@0: $ix - 3, $ix - 2, $ix - 1, $ix); michael@0: } michael@0: } michael@0: printf("%0.9ff\n};\n\n", (log(2)/log($ix))); michael@0: michael@0: exit 0;