#!/usr/local/bin/perl -w # fibonacci.p # # writes latex files containing capacity counts # usage (in directory itp/noiseless) # ~/bin/fibonacci.p a=1 b=1 # ~/bin/fibonacci.p a=0 b=1 $N=400; $ffile="tex/ffile.tex" ; # trellis section file $a = 1 ; $b = 1 ; $skipafter = 12 ; $period = 100 ; eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $Nsections = $N ; open ( O , "> $ffile " ) ; print STDERR '\input{',$ffile,"\}\n"; # write the matrix print O "\% written by fibonacci.p\n" ; print O "\\begin{tabular}{*{4}{r}c} \\hline\n" ; print O '\multicolumn{1}{r}{$n$} &' ;print O "\n "; print O '\multicolumn{1}{r}{$M_n$} &' ;print O "\n "; print O '\multicolumn{1}{c}{$M_n/M_{n-1}$} &' ;print O "\n "; print O '\multicolumn{1}{l}{$\log_2 M_n$} &' ;print O "\n "; print O '\multicolumn{1}{c}{$\frac{1}{n} \log_2 M_n$} \\\\[0.051in] \hline' ; # I don't see # why I needed \\\\ here print O "\n"; $times='\!\times\!' ; $times = '\!\cdot\!' ; for ( $s = 1 ; $s <= $Nsections ; $s ++ ) { $c = $a + $b ; if ( (!($skipafter)) || # i.e. print every time ( $s <= $skipafter ) || ( !($s%$period) ) ) { $l = log($c) / log(2.0) ; if ( $c < 99999 ) { $M = $c ; } else { $M = sprintf ( "%4.1g" , $c ) ; $M =~ s/([-1234567890\.]+)e(-*)[\+0]*([1234567890]+)/\$$1$times 10^\{$2$3\}\$/ ; } $L = sprintf ( "%10.1f" , $l ) ; $C = sprintf ( "%10.2f" , $l / $s ) ; $ratio = sprintf ( "%6.3f" , $c / $b ) ; print O "$s\t" ; print O "&" ; print O " $M\t" ; print O "&" ; if ( $s > 1 ) { print O " $ratio\t" ; } else { print O " \t" ; } print O "&" ; print O " $L\t" ; print O "&" ; print O "$C " ; print O "\\\\ \n" ; } $a = $b ; $b = $c ; } print O "\\hline\n" ; print O "\\end{tabular}\n" ; close (O) ; # end exit(0);