Skip to content

Commit

Permalink
Added the 16-input network by Van Voorhis. Adjusted test file to
Browse files Browse the repository at this point in the history
limit testing to up to 16-input networks.
  • Loading branch information
jgamble committed Jan 15, 2018
1 parent 5f3423f commit ed2cc03
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
19 changes: 19 additions & 0 deletions lib/Algorithm/Networksort/Best.pm
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,19 @@ my %nw_best_by_name = (
[12,13], [2,3], [8,11], [4,9], [10,11], [6,7], [5,6], [4,8],
[7,9], [4,5], [9,11], [11,12], [3,4], [6,8], [7,10], [9,10],
[5,6], [7,8], [8,9], [6,7]]},
voorhis16 => {
inputs => 16,
depth => 9,
title => '16-Input Network by David C. Van Voorhis',
comparators =>
[[0,1], [2,3], [4,5], [6,7], [8,9], [10,11], [12,13], [14,15],
[1,3], [5,7], [9,11], [13,15], [0,2], [4,6], [8,10], [12,14],
[3,7], [11,15], [2,6], [10,14], [1,5], [9,13], [0,4], [8,12],
[7,15], [6,14], [5,13], [4,12], [3,11], [2,10], [1,9], [0,8],
[1,2], [3,12], [13,14], [4,8], [7,11], [5,10], [6,9],
[2,8], [7,13], [3,9], [5,12], [1,4], [6,10], [11,14],
[2,4], [6,8], [10,12], [3,5], [7,9], [11,13],
[3,6], [7,10], [5,8], [9,12], [3,4], [5,6], [7,8], [9,10], [11,12]]},
senso17 => {
inputs => 17,
depth => 17,
Expand Down Expand Up @@ -875,6 +888,12 @@ L<http://etd.ohiolink.edu/view.cgi?acc_num=kent1239814529>.
=item
The 16 input network found by David C. Van Voorhis is described in chapter
5 of Designing Sorting Networks, by Sherenaz W. Al-Haj Baddar and Kenneth E.
Batcher.
=item
The Symmetry and Evolution based Network Sort Optimization (SENSO) found more
networks for inputs of 9 through 23.
Expand Down
40 changes: 28 additions & 12 deletions t/best.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,42 @@ require "t/zero_one.pl";
my @names;

our $author_testing = $ENV{AUTHOR_TESTING};
@names= sort(nw_best_names()); # All, regardless of input size.
diag("Names to run: " . join(", ", @names));
@names= sort sizename_cmp nw_best_names();

#
# Spare the CPAN testers from testing networks greater
# than 16 inputs.
#
unless ($author_testing)
{
plan tests => 1;
ok(scalar @names > 0, "@names");
@names = grep{/^[a-z]+[0-9]$|^[a-z]+1[0-6]$/} @names;
}
else

diag("Networks to test: " . join(", ", @names));

plan tests => 1 + scalar @names;
ok(scalar @names > 0, "@names");

for (@names)
{
plan tests => 1 + scalar @names;
ok(scalar @names > 0, "@names");
my $nw = nwsrt_best(name => $_);

for (@names)
{
my $nw = nwsrt_best(name => $_);
my $status = zero_one($nw);
is($status, "pass", "$_, $status, " . $nw->title());
}

my $status = zero_one($nw);
is($status, "pass", "$_, $status, " . $nw->title());
sub sizename_cmp
{
my($aname, $asize, $bname, $bsize) = ($a, 999, $b, 999);
if ($a =~ /^([a-z]+)(\d+)$/)
{
$aname = $1; $asize = $2;
}
if ($b =~ /^([a-z]+)(\d+)$/)
{
$bname = $1; $bsize = $2;
}
return ($asize <=> $bsize || $aname cmp $bname);
}

1;

0 comments on commit ed2cc03

Please sign in to comment.