chiark / gitweb /
fancier
authorian <ian>
Sun, 23 May 2004 15:08:38 +0000 (15:08 +0000)
committerian <ian>
Sun, 23 May 2004 15:08:38 +0000 (15:08 +0000)
misc/divider-table.pl
pcb/Makefile
pic.make
spice/Makefile

index 6b5a6ab0350fc1e4bd2a3aadbd6231db2b4fe292..fbd6c6a33dcdd0ba18720c5f7fceb95e7d3e8672 100755 (executable)
@@ -10,7 +10,7 @@ our ($tlin,$tlog,@byrat);
 
 sub thead ($$) {
     my ($t,$h) = @_;
-    $$t = sprintf "%-10s |", $h;
+    $$t = sprintf "%-12s |", $h;
 }
 sub chead ($$) {
     my ($t,$h) = @_;
@@ -18,30 +18,42 @@ sub chead ($$) {
 }
 sub theadend ($) {
     my ($t) = @_;
-    $$t .= "\n".('-'x(10+1)).'+'.('-'x(24*6))."\n";
+    $$t .= "\n".('-'x(12+1)).'+'.('-'x(24*6))."\n";
 }
 sub rhead ($$) {
     my ($t,$h) = @_;
-    $$t .= sprintf "%10s |", $h;
+    $$t .= sprintf "%12s |", $h;
 }
 sub cell ($$) {
     my ($t,$v) = @_;
-    $$t .= sprintf " %5.3f", $v;
+    $$t .= sprintf " %5s", $v;
 }
 sub rend ($$) {
     my ($t,$n) = @_;
     $$t .= "\n";
-    $$t .= "\n" if ($n % 4) == 3;
+    $$t .= "\n" if (($n+1) % 6) == 0;
 }
 sub tend ($) {
     my ($t) = @_;
 }
 
+sub mul10fit ($$) {
+    my ($v,$len) = @_;
+    while (length(sprintf "%d", $v) < $len) { $v *= 10.0; }
+    return sprintf "%d", $v;
+}
+sub fracfit ($$) {
+    my ($v,$len) = @_;
+    $v= sprintf "%".($len+2).".${len}f", $v;
+    $v =~ s/^\d\.//;
+    return $v;
+}
+
 sub scan () {
     my ($row,$col,$lin,$log,$rownum);
     @byrat = ();
-    thead(\$tlin,'Row/Col');
-    thead(\$tlog,'L(R/C)+1');
+    thead(\$tlin,'X/Y [*10^k]');
+    thead(\$tlog,'frac(L(X/Y))');
     for $col (@e24) {
        chead(\$tlin,$col);
        chead(\$tlog,$col);
@@ -55,8 +67,10 @@ sub scan () {
        for $col (@e24) {
            $lin= $col*1.0 / $row;
            $log= log($lin)/log(10) + 1.0;
-           cell(\$tlin,$lin);
-           cell(\$tlog,$log);
+
+           cell(\$tlin, mul10fit($lin,5));
+           cell(\$tlog, fracfit($log,5));
+
            if ($col < $row) { $lin *= 10; }
            next if $row==$col;
            push @byrat, { Num => $col,
@@ -90,24 +104,24 @@ sub sortbyrat () {
 sub byratcol ($$$) {
     my ($or,$cwr,$colnum) = @_;
     $$or .= '  ' if $colnum;
-    $$cwr = ($colnum<4 ? 7 : 6);
+    $$cwr = ($colnum<6 ? 6 : 5);
 }
 
 sub printbyrat () {
     use integer;
-    my ($brcols) = 7;
+    my ($brcols) = 8;
     my ($brrows) = (@byrat+$brcols-1) / $brcols;
     my ($byrat,$o,$colnum,$rownum,$cw);
     $o= ''; 
     for ($colnum=0; $colnum<$brcols; $colnum++) {
        byratcol(\$o,\$cw,$colnum);
-       $o .= sprintf(" N/D  %${cw}s %7s",
-                     'Q[*10]','Lg(Q)+1');
+       $o .= sprintf("N/D %".($cw+1)."s %s",
+                     'Q*10^k','fc(Lg)');
     }
     $o .= "\n";
     for ($colnum=0; $colnum<$brcols; $colnum++) {
        byratcol(\$o,\$cw,$colnum);
-       $o .= '-' x (5+1+$cw+1+7);
+       $o .= '-' x (5+1+$cw+1+5);
     }
     $o .= "\n";
     for ($rownum=0; $rownum<$brrows; $rownum++) { 
@@ -115,15 +129,17 @@ sub printbyrat () {
            $byrat= $byrat[$colnum*$brrows + $rownum];
            next unless defined $byrat;
            byratcol(\$o,\$cw,$colnum);
-           $o .= sprintf("%2s/%-2s %${cw}.".($cw-2)."f %7.5f",
+           $o .= sprintf("%2s/%-2s %${cw}s %s",
                          $byrat->{Num}, $byrat->{Den},
-                         $byrat->{Lin}, $byrat->{Log});
+                         mul10fit($byrat->{Lin}, $cw),
+                         fracfit($byrat->{Log}, 5));
        }
        $o .= "\n";
     }
     print $o or die $!;
 }
 
+print "\n" or die $!;
 scan();
 ptable($tlin);
 ptable($tlog);
index 1014ab6d51aff967173e7df0df64764814d69ff0..7395a2781d31a194df6df740b963b2c1d6e9052e 100644 (file)
@@ -39,12 +39,13 @@ bulkres-items.partlist:
                ./farnell-resistor-convert.pl <bulkres-items.descs MRS25 std $o
 
 divider-table.txt:     divider-table.pl
-               ./$^ $o
+               ./$< $o
 
 divider-tables:                divider-table.ps divider-table.txt
 
-divider-table.ps:      divider-table.txt
-               a2ps -o- -R -1 --borders no -B -l156 -L"$$(wc -l <$^)" <$^ $o
+divider-table.ps:      divider-table.txt Makefile
+               a2ps -o- -R -1 --borders no -B -L"$$(wc -l <$<)" -l158 \
+                --center-title='E24 resistor ratios and logarithms' <$< $o
 
 %.d4:          %.m4 $(M4INCS) Makefile
                m4 -s <$< $o
index 1014ab6d51aff967173e7df0df64764814d69ff0..7395a2781d31a194df6df740b963b2c1d6e9052e 100644 (file)
--- a/pic.make
+++ b/pic.make
@@ -39,12 +39,13 @@ bulkres-items.partlist:
                ./farnell-resistor-convert.pl <bulkres-items.descs MRS25 std $o
 
 divider-table.txt:     divider-table.pl
-               ./$^ $o
+               ./$< $o
 
 divider-tables:                divider-table.ps divider-table.txt
 
-divider-table.ps:      divider-table.txt
-               a2ps -o- -R -1 --borders no -B -l156 -L"$$(wc -l <$^)" <$^ $o
+divider-table.ps:      divider-table.txt Makefile
+               a2ps -o- -R -1 --borders no -B -L"$$(wc -l <$<)" -l158 \
+                --center-title='E24 resistor ratios and logarithms' <$< $o
 
 %.d4:          %.m4 $(M4INCS) Makefile
                m4 -s <$< $o
index 1014ab6d51aff967173e7df0df64764814d69ff0..7395a2781d31a194df6df740b963b2c1d6e9052e 100644 (file)
@@ -39,12 +39,13 @@ bulkres-items.partlist:
                ./farnell-resistor-convert.pl <bulkres-items.descs MRS25 std $o
 
 divider-table.txt:     divider-table.pl
-               ./$^ $o
+               ./$< $o
 
 divider-tables:                divider-table.ps divider-table.txt
 
-divider-table.ps:      divider-table.txt
-               a2ps -o- -R -1 --borders no -B -l156 -L"$$(wc -l <$^)" <$^ $o
+divider-table.ps:      divider-table.txt Makefile
+               a2ps -o- -R -1 --borders no -B -L"$$(wc -l <$<)" -l158 \
+                --center-title='E24 resistor ratios and logarithms' <$< $o
 
 %.d4:          %.m4 $(M4INCS) Makefile
                m4 -s <$< $o