Algorithm::Networksort 1.05 review

Download
by rbytes.net on

Algorithm::Networksort can create inline comparisons for sorting. SYNOPSIS use Algorithm::Networksort qw(:all); my $inpu

License: Perl Artistic License
File size: 15K
Developer: John M. Gamble
0 stars award from rbytes.net

Algorithm::Networksort can create inline comparisons for sorting.

SYNOPSIS

use Algorithm::Networksort qw(:all);

my $inputs = 4;

#
# Generate the network (a list of comparators).
#
my @network = nw_comparators($inputs);

#
# Print the list, and print the graph of the list.
#
print nw_format(@network, $inputs), "n";
print nw_graph(@network, $inputs), "n";

This module will create sorting networks, a sequence of comparisons that do not depend upon the results of prior comparisons.

Since the sequences and their order never change, they can be very useful if deployed in hardware or used in software with a compiler that can take advantage of parallelism. Unfortunately a network cannot be used for generic run-time sorting like quicksort since the arrangement of the comparisons is fixed according to the number of elements to be sorted.

This module's main purpose is to create compare-and-swap macros (or functions, or templates) that one may insert into source code. It may also be used to create images of the networks in either encapsulated postscript (EPS), scalar vector graphics (SVG), or in "ascii art" format.

Requirements:
Perl

Algorithm::Networksort 1.05 search tags