#************************Creating Arrays*************************************** #These are the subroutines which create the arrays of 1s and 0s which represent the shadows of the top vertices. sub h1is3 { my ($x1,$x2,$x3) = @_; for ($i=0; $i<=$x1; $i++) { for ($j=0; $j<=$x2; $j++) { for ($k=0; $k<=$x3; $k++) { $countingarray[$i][$j][$k] = 1; } } } } #*******************Counting Monomials******************************** #This section contains the subroutines which count the number of monomials of each degree. #The input is the r^{h1}-dimensional array created in the subroutines in the previous section. sub counth1is3 { my @osequence = (0); for ($q=1; $q<=$r; $q++) { @osequence = (@osequence,0); } for ($i=0; $i<=$r; $i++) { for ($j=0; $j<=$r; $j++) { for ($k=0; $k<=$r; $k++) { if ($countingarray[$i][$j][$k]== 1) { $osequence[$i+$j+$k]= $osequence[$i+$j+$k]+1; } } } } use Tie::File; use Fcntl; #here you will set the file to compare to #change each oseqr#var#p# to reflect the rank, variable, and part #change each compare_r#var#p# to reflect the rank, variable, and part tie @currentlist, Tie::File, oseqr4var3p15 or die "Can't tie file"; tie @currentcompare, Tie::File, compare_r4var3p15 or die "Can't tie to file"; my $string = "@osequence"; my $yesorno = 0; while ($yesorno == 0) { for ($i=0; $i<=$#currentcompare; $i++) { if ($string eq $currentcompare[$i]) { $yesorno = 1; } } if ($yesorno == 0) { open (MYFILE, '>>compare_r4var3p15'); print MYFILE "$string\n"; close (MYFILE); open (MYFILE, '>>oseqr4var3p15'); print MYFILE "("; for ($i=0; $i<$r; $i++) { print MYFILE "@osequence[$i]"; print MYFILE ","; } print MYFILE "@osequence[$r]"; print MYFILE ") & "; #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #here we include the code to print the latex format to file #*************************************** #h_r=15 print MYFILE "["; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array1[$j]"; print MYFILE ","; } print MYFILE "$h_array1[$h_1-1]"; print MYFILE "],"; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array2[$j]"; print MYFILE ","; } print MYFILE "$h_array2[$h_1-1]"; print MYFILE "],"; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array3[$j]"; print MYFILE ","; } print MYFILE "$h_array3[$h_1-1]"; print MYFILE "],"; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array4[$j]"; print MYFILE ","; } print MYFILE "$h_array4[$h_1-1]"; print MYFILE "],"; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array5[$j]"; print MYFILE ","; } print MYFILE "$h_array5[$h_1-1]"; print MYFILE "],"; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array6[$j]"; print MYFILE ","; } print MYFILE "$h_array6[$h_1-1]"; print MYFILE "],"; print MYFILE "\\\\ & "; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array7[$j]"; print MYFILE ","; } print MYFILE "$h_array7[$h_1-1]"; print MYFILE "],"; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array8[$j]"; print MYFILE ","; } print MYFILE "$h_array8[$h_1-1]"; print MYFILE "],"; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array9[$j]"; print MYFILE ","; } print MYFILE "$h_array9[$h_1-1]"; print MYFILE "],"; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array10[$j]"; print MYFILE ","; } print MYFILE "$h_array10[$h_1-1]"; print MYFILE "],"; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array11[$j]"; print MYFILE ","; } print MYFILE "$h_array11[$h_1-1]"; print MYFILE "],"; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array12[$j]"; print MYFILE ","; } print MYFILE "$h_array12[$h_1-1]"; print MYFILE "],"; print MYFILE "\\\\ & "; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array13[$j]"; print MYFILE ","; } print MYFILE "$h_array13[$h_1-1]"; print MYFILE "],"; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array14[$j]"; print MYFILE ","; } print MYFILE "$h_array14[$h_1-1]"; print MYFILE "],"; print MYFILE "["; for ($j=0; $j<$h1-1; $j++) { print MYFILE "@h_array15[$j]"; print MYFILE ","; } print MYFILE "$h_array15[$h_1-1]"; print MYFILE "]]\\\\"; print MYFILE " & \\\\"; #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ print MYFILE "\n"; close (MYFILE); $yesorno = 2; } } } #************************************************************************* #This is the overall routine to generate the o-sequences #Make sure that you: #1. Change the vertex file you are tying to (@data =...) #2. Change the rank to reflect the vertex file you are using #3. Change the filenames in the subroutine 'counth1is#' to reflect how many vertices you are choosing in the topmost tier (let this number be k) #4. Put in the appropriate number (k) of nested for loops so that you run through all subsets of k vertices use Tie::File; use Fcntl; #here you will need to replace 'verticesr#var#' with your file of choice tie @data, Tie::File, verticesr4var3 or die "Can't tie to file"; $possvert = $#data; $r = 4; #here you will set the rank $h1 = 3; #here you set the number of variables #here you will add the appropriate number of for loops #********************************* #here h_r=15 for ($a1=0; $a1<=$possvert; $a1++) { for ($a2=$a1+1; $a2<=$possvert; $a2++) { for ($a3=$a2+1; $a3<=$possvert; $a3++) { for ($a4=$a3+1; $a4<=$possvert; $a4++) { for ($a5=$a4+1; $a5<=$possvert; $a5++) { for ($a6=$a5+1; $a6<=$possvert; $a6++) { for ($a7=$a6+1; $a7<=$possvert; $a7++) { for ($a8=$a7+1; $a8<=$possvert; $a8++) { for ($a9=$a8+1; $a9<=$possvert; $a9++) { for ($a10=$a9+1; $a10<=$possvert; $a10++) { for ($a11=$a10+1; $a11<=$possvert; $a11++) { for ($a12=$a11+1; $a12<=$possvert; $a12++) { for ($a13=$a12+1; $a13<=$possvert; $a13++) { for ($a14=$a13+1; $a14<=$possvert; $a14++) { for ($a15=$a14+1; $a15<=$possvert; $a15++) { $vertex1=$data[$a1]; @h_array1=(split('',$vertex1)); $vertex2=$data[$a2]; @h_array2=(split('',$vertex2)); $vertex3=$data[$a3]; @h_array3=(split('',$vertex3)); $vertex4=$data[$a4]; @h_array4=(split('',$vertex4)); $vertex5=$data[$a5]; @h_array5=(split('',$vertex5)); $vertex6=$data[$a6]; @h_array6=(split('',$vertex6)); $vertex7=$data[$a7]; @h_array7=(split('',$vertex7)); $vertex8=$data[$a8]; @h_array8=(split('',$vertex8)); $vertex9=$data[$a9]; @h_array9=(split('',$vertex9)); $vertex10=$data[$a10]; @h_array10=(split('',$vertex10)); $vertex11=$data[$a11]; @h_array11=(split('',$vertex11)); $vertex12=$data[$a12]; @h_array12=(split('',$vertex12)); $vertex13=$data[$a13]; @h_array13=(split('',$vertex13)); $vertex14=$data[$a14]; @h_array14=(split('',$vertex14)); $vertex15=$data[$a15]; @h_array15=(split('',$vertex15)); @countingarray=(); h1is3(@h_array1); h1is3(@h_array2); h1is3(@h_array3); h1is3(@h_array4); h1is3(@h_array5); h1is3(@h_array6); h1is3(@h_array7); h1is3(@h_array8); h1is3(@h_array9); h1is3(@h_array10); h1is3(@h_array11); h1is3(@h_array12); h1is3(@h_array13); h1is3(@h_array14); h1is3(@h_array15); counth1is3 }}}}}}}}}}}}}}}