Skip to content

Commit e56f4fd

Browse files
committed
Documentation and version updates.
1 parent f2db153 commit e56f4fd

File tree

2 files changed

+33
-40
lines changed

2 files changed

+33
-40
lines changed

lib/Algorithm/Networksort.pm

+29-38
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Moose::Exporter->setup_import_methods(
2424
as_is => [\&nwsrt_algorithms, \&nwsrt_title, \&nwsrt],
2525
);
2626

27-
our $VERSION = '2.01';
27+
our $VERSION = '2.02';
2828

2929
#
3030
# Our one use of overload, because default
@@ -162,33 +162,34 @@ Algorithm::Networksort - Create Sorting Networks.
162162
=begin html
163163
164164
<svg xmlns="http://www.w3.org/2000/svg"
165-
xmlns:xlink="http://www.w3.org/1999/xlink" width="157" height="120" viewbox="0 0 157 120">
165+
xmlns:xlink="http://www.w3.org/1999/xlink" width="90" height="84" viewbox="0 0 90 84">
166166
<title>Bose-Nelson Sort for N = 4</title>
167167
<defs>
168-
<g id="I_5649" style="stroke-width:2; fill:#000; stroke:#000" >
169-
<line x1="18" y1="0" x2="139" y2="0" />
168+
<g id="I_1c13" style="stroke-width:2; fill:#000; stroke:#000" >
169+
<line x1="12" y1="0" x2="78" y2="0" />
170170
</g>
171-
<g id="C1_5649" style="stroke-width:3;fill:#000; stroke:#000" >
172-
<line x1="0" y1="0" x2="0" y2="26" />
173-
<circle cx="0" cy="0" r="3" /> <circle cx="0" cy="26" r="3" />
171+
172+
<g id="C1_1c13" style="stroke-width:2;fill:#000; stroke:#000" >
173+
<line x1="0" y1="0" x2="0" y2="14" />
174+
<circle cx="0" cy="0" r="2" /> <circle cx="0" cy="14" r="2" />
174175
</g>
175-
<g id="C2_5649" style="stroke-width:3;fill:#000; stroke:#000" >
176-
<line x1="0" y1="0" x2="0" y2="52" />
177-
<circle cx="0" cy="0" r="3" /> <circle cx="0" cy="52" r="3" />
176+
<g id="C2_1c13" style="stroke-width:2;fill:#000; stroke:#000" >
177+
<line x1="0" y1="0" x2="0" y2="28" />
178+
<circle cx="0" cy="0" r="2" /> <circle cx="0" cy="28" r="2" />
178179
</g>
179180
</defs>
180181
181-
<g id="bosenelson04_5649">
182-
<rect width="100%" height="100%" style="fill:#eee" />
183-
<use xlink:href="#I_5649" y="21" /> <use xlink:href="#I_5649" y="47" />
184-
<use xlink:href="#I_5649" y="73" /> <use xlink:href="#I_5649" y="99" />
182+
<g id="bosenelson04_1c13">
183+
<use xlink:href="#I_1c13" y="21" /> <use xlink:href="#I_1c13" y="35" />
184+
<use xlink:href="#I_1c13" y="49" /> <use xlink:href="#I_1c13" y="63" />
185185
186-
<use xlink:href="#C1_5649" x="38" y="21" /> <use xlink:href="#C1_5649" x="38" y="73" />
187-
<use xlink:href="#C2_5649" x="65" y="21" /> <use xlink:href="#C2_5649" x="92" y="47" />
188-
<use xlink:href="#C1_5649" x="119" y="47" />
186+
<use xlink:href="#C1_1c13" x="24" y="21" /> <use xlink:href="#C1_1c13" x="24" y="49" />
187+
<use xlink:href="#C2_1c13" x="38" y="21" /> <use xlink:href="#C2_1c13" x="52" y="35" />
188+
<use xlink:href="#C1_1c13" x="66" y="35" />
189189
</g>
190190
</svg>
191191
192+
192193
<p>Bose-Nelson sorting network, inputs = 4, drawn as a Knuth diagram.</p>
193194
194195
<!--
@@ -222,14 +223,14 @@ Algorithm::Networksort - Create Sorting Networks.
222223
$nw->graph_text(), "\n";
223224
224225
#
225-
# Change the sizes and add a background color.
226226
# Create an SVG image of the Knuth diagram.
227+
# Set the diagram sizes.
227228
#
228-
$nw->graphsettings(vt_margin => 21, hz_margin => 18, indent => 20,
229-
vt_sep => 24, hz_sep=>24,
230-
compradius => 3, compline => 3, inputradius => 0);
231-
232-
$nw->colorsettings(background => "#eee");
229+
$nw->graphsettings(indent => 12,
230+
hz_margin => 12, hz_sep=>12,
231+
vt_margin => 21, vt_sep => 12,
232+
compradius => 2, compline => 2,
233+
inputradius => 0, inputline => 2);
233234
234235
print $nw->graph_svg();
235236
@@ -561,9 +562,7 @@ sub hibbard
561562
# $t = ceiling(log2($inputs - 1)); but we'll
562563
# find it using the length of the bitstring.
563564
#
564-
my $t = unpack("B32", pack("N", $inputs - 1));
565-
$t =~ s/^0+//;
566-
$t = length $t;
565+
my $t = length sprintf("%b", $inputs - 1);
567566

568567
my $lastbit = 1 << $t;
569568

@@ -775,9 +774,7 @@ sub batcher
775774
# $t = ceiling(log2($inputs)); but we'll
776775
# find it using the length of the bitstring.
777776
#
778-
my $t = unpack("B32", pack("N", $inputs));
779-
$t =~ s/^0+//;
780-
$t = length $t;
777+
my $t = length sprintf("%b", $inputs);
781778

782779
my $p = 1 << ($t -1);
783780

@@ -841,9 +838,7 @@ sub bitonic
841838
# $t = ceiling(log2($n - 1)); but we'll
842839
# find it using the length of the bitstring.
843840
#
844-
my $t = unpack("B32", pack("N", $n - 1));
845-
$t =~ s/^0+//;
846-
$t = length $t;
841+
my $t = length sprintf("%b", $n - 1);
847842

848843
my $m = 1 << ($t - 1);
849844

@@ -951,9 +946,7 @@ sub balanced
951946
# $t = ceiling(log2($inputs - 1)); but we'll
952947
# find it using the length of the bitstring.
953948
#
954-
my $t = unpack("B32", pack("N", $inputs - 1));
955-
$t =~ s/^0+//;
956-
$t = length $t;
949+
my $t = length sprintf("%b", $inputs - 1);
957950

958951
for (1 .. $t)
959952
{
@@ -991,9 +984,7 @@ sub oddevenmerge
991984
# $t = ceiling(log2($inputs - 1)); but we'll
992985
# find it using the length of the bitstring.
993986
#
994-
my $t = unpack("B32", pack("N", $inputs - 1));
995-
$t =~ s/^0+//;
996-
$t = length $t;
987+
my $t = length sprintf("%b", $inputs - 1);
997988

998989
my ($add_elem, $sort, $merge);
999990

lib/Algorithm/Networksort/Best.pm

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use warnings;
3131

3232
@EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
3333

34-
our $VERSION = '2.01';
34+
our $VERSION = '2.02';
3535

3636
#
3737
# The hashes represent each network, with a short, hopefully descriptive, key.
@@ -525,7 +525,9 @@ The current networks are:
525525
526526
=item 'floyd09'
527527
528-
A 9-input network of depth 9 discovered by R. W. Floyd.
528+
A 9-input network of depth 9 discovered by R. W. Floyd. Of interest also
529+
because it is using what are essentially three-way comparators split into
530+
three sets of two-way comparators.
529531
530532
=item 'senso09'
531533

0 commit comments

Comments
 (0)