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).

covered_least()

Find the term with the fewest implicant covers, along with a list of those covers.

      my($term, @covers) = covered_least(\%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 reference to a hash of arrayrefs and a reference to an array of values, remove the values from the individual arrayrefs if the values matches their masks.

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

      remels(\%primes, @elements);

Returns the number of removals made.

uniqels()

Returns the unique arrays from an array of arrays (i.e., we're ensuring non-duplicate answers).

      my @uels = uniqels(@els);

columns()

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

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

hammingd1pos()

Very specialized Hamming distance and position function.

Our calling code is only interested in Hamming distances of 1. In those cases return the string position where the two values differ. In all the other cases where the distance isn't one, return a -1.

      $idx = hammingd1pos($val1, $val2);

SEE ALSO

Algorithm::QuineMcCluskey

AUTHOR

Darren M. Kulp <darren@kulp.ch>

John M. Gamble jgamble@cpan.org (current maintainer)