#!/usr/local/bin/perl -w # BCY.p # reads in a difference set and writes out # a BIcyclic code in alist format. # BCY.p M=157 DSfile=string/DS10.157 > A # based on binarize.p and G2H.p # writes Alist matrix to stdout $M=0; $DSfile = "string/157.10" ; # difference set # $v = 0 ; eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; if($M eq "0" ) { print STDERR "usage:\n "; print STDERR " BCY.p M=157 DSfile=string/DS10.157 > A\n" ; } # read the design $matrices = 2 ; $orientation[1] = 1 ; $orientation[2] = -1 ; # done open ( H , "< $DSfile" ) ; $i = 0 ; $k = 0 ; $_ = ; s/^\s+//; @r = split ; # @r contains the difference set. $I = $#r ; close(H) ; for ( $k = 1 ; $k <= $M ; $k ++ ) { $offset = 0 ; for ( $m = 1 ; $m <= $matrices ; $m ++ ) { # set up the current difference set. for ( $i = 0 ; $i <= $I ; $i ++ ) { $difference = $M + $orientation[$m] * $r[$i] ; $nnn = $difference + $k ; # add the row number ; while ( $nnn > $M ) { $nnn -= $M ; } $nnn += $offset ; mnadd( $k , $nnn ) ; } $offset += $M ; } print STDERR "." ; } $N = $offset ; print STDERR "done N = $N ; M = $M\n" ; if ( 1 ) { $head = "$N $M\n" ; print STDERR "Writing code.\n" ; # find $t (max) and $tr (max) $t = 0 ; $tr = 0 ; for ( $n = 1 ; $n <= $N ; $n ++ ) { if ( $numnlist[$n] > $t ) { $t = $numnlist[$n] ; } } for ( $m = 1 ; $m <= $M ; $m ++ ) { if ( $nummlist[$m] > $tr ) { $tr = $nummlist[$m] ; } } $head .= "$t $tr\n" ; # append zeros to short lines for ( $n = 1 ; $n <= $N ; $n ++ ) { $thisn = $numnlist[$n] ; $head .= "$thisn " ; while ( $thisn < $t ) { $nlist[$n] .= "0\t" ; $thisn ++ ; } } $head .= "\n" ; for ( $m = 1 ; $m <= $M ; $m ++ ) { $thism = $nummlist[$m] ; $head .= "$thism " ; while ( $thism < $tr ) { $mlist[$m] .= "0\t" ; $thism ++ ; } } $head .= "\n" ; print $head ; # finish lists for ( $n = 1 ; $n <= $N ; $n ++ ) { $nlist[$n] =~ s/\t$/\n/ ; print $nlist[$n] ; } for ( $m = 1 ; $m <= $M ; $m ++ ) { $mlist[$m] =~ s/\t$/\n/ ; print $mlist[$m] ; } } sub mnadd { local($m,$n)=@_; # put m and n on each others lists $nlist[$n] .= $m."\t" ; $mlist[$m] .= $n."\t" ; $numnlist[$n] ++ ; $nummlist[$m] ++ ; }