The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Algorithm::QuineMcCluskey::Util - provide utility functions to Algorithm::QuineMcCluskey

DESCRIPTION

This module provides various utilities designed for (but not limited to) use in Algorithm::QuineMcCluskey.

The prime implicant and essentials "tables" are in the form of a hash of array refs, and are manipulated with the functions columns(), find_essentials(), least_covered(), purge_elements(), remels(), row_dominance(), and uniqels().

FUNCTIONS

matchcount()

Returns the count of a search string Y found in the source string X.

E.g.:

      my $str = "d10d11d1d"; 
      matchcount($str, "d");     # returns 4
      matchcount($str, "d1");    # returns 3

To search for only the string without a regular expression accidentally interfering, enclose the search string between '\Q' and '\E'. E.g.:

      #
      # We don't know what's in $looking, so de-magic it.
      #
      matchcount($str, '\E' . $looking . '\Q]);

maskedmatch()

Returns the terms that match a mask made up of zeros, ones, and don't-care characters.

      my @rterms = maskedmatch("010-0", @terms);

find_essentials()

Find the essential prime implicants in a primes table, filtered by a list of terms.

      my $ess = find_essentials(\%primes, @terms);

row_dominance()

Row dominance checking.

@dominated_rows = row_dominance(\%primes, 0); @dominant_rows = row_dominance(\%primes, 1);

A row (column) i of a PI chart dominates row (column) j if row (column) i contains an x in each column (row) dominated by it.

Return those rows (columns are handled by rotating the primes hash before calling this function).

least_covered()

Find the term with the fewest implicant covers.

      my $t = least_covered(\%primes, @terms);

purge_elements()

      purge_elements(\%prime_implicants, @essentials);

Given a table of prime implicants, delete the list of elements (usually the essential prime implicants) from the table, both row-wise and column-wise.

remels()

Given a value and a reference to a hash of arrayrefs, remove the value from the individual arrayrefs if the value matches the masks.

Deletes the entire arrayref from the hash if the last element of the array is removed.

      remels($element, \%primes);

Returns the number of removals made.

countels()

Returns a count of all elements in the array ref that are equal to $el.

      my $c = countels($el, \@array);

uniqels()

Returns the unique arrays from an array of arrays.

      my @uels = uniqels(@els);

columns()

Rotates 90 degrees a hashtable of the type used for %primes, using only @columms.

      my %table90 = columns(\%table, @columns)

diffpos()

Find the location of the first difference between two strings

      my $p = diffpos($str1, $str2);

hdist()

Return the Hamming distance between two strings.

      $d = hdist($str1, $str2);

SEE ALSO

Algorithm::QuineMcCluskey

AUTHOR

Darren M. Kulp <darren@kulp.ch>