| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
$nelt = int($ARGV[0]); |
| 4 |
$leng = int($ARGV[1]); |
| 5 |
|
| 6 |
print "/* This file auto-generated with ./vperm.pl $nelt $leng. */\n\n"; |
| 7 |
|
| 8 |
for ($i = 0; $i < $nelt; ++$i) { $perm[$i] = 0; } |
| 9 |
$ncheck = 0; |
| 10 |
|
| 11 |
for ($i = 0; $i < ($leng * $nelt) ** $nelt; ++$i) |
| 12 |
{ |
| 13 |
if ($i % 128 == 0) |
| 14 |
{ |
| 15 |
print "}\n\n" if $ncheck > 0; |
| 16 |
print "void check$ncheck(void)\n{\n"; |
| 17 |
++$ncheck; |
| 18 |
} |
| 19 |
|
| 20 |
print " TEST ("; |
| 21 |
for ($j = 0; $j < $nelt; ++$j) |
| 22 |
{ |
| 23 |
print $perm[$j]; |
| 24 |
print ", " if $j < $nelt - 1; |
| 25 |
} |
| 26 |
print ")\n"; |
| 27 |
|
| 28 |
INCR: for ($j = 0; $j < $nelt; ++$j) |
| 29 |
{ |
| 30 |
last INCR if ++$perm[$j] < $leng * $nelt; |
| 31 |
$perm[$j] = 0; |
| 32 |
} |
| 33 |
} |
| 34 |
print "}\n\n"; |
| 35 |
|
| 36 |
print "void check(void)\n{\n"; |
| 37 |
for ($i = 0; $i < $ncheck; ++$i) |
| 38 |
{ |
| 39 |
print " check$i ();\n"; |
| 40 |
} |
| 41 |
print "}\n\n"; |