- SEE ALSO
- LICENSE AND COPYRIGHT
Algorithm::QuineMcCluskey::Util - provide utility functions to Algorithm::QuineMcCluskey
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 find_essentials(), least_covered(), purge_elements(), remels(), row_dominance(), transpose(), and uniqels().
Returns the count of a search string Y found in the source string X.
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]);
Returns the terms that match a mask made up of zeros, ones, and don't-care characters.
my @rterms = maskedmatch("010-0", @terms);
Returns the indexes of the terms that match a mask made up of zeros, ones, and don't-care characters.
my @pos = maskedmatchindexes("010-0", @terms);
Find the essential prime implicants in a primes table.
my @essentials = find_essentials(\%primes);
Row dominance checking.
@dominated_rows = row_dominance(\%primes, 0); @dominant_rows = row_dominance(\%primes, 1);
A row i of a PI chart dominates row j if row i contains an x in each column dominated by it.
A column p of a PI chart dominates column q if column p contains an x in each row dominated by it.
Return those rows (columns are handled by rotating the primes hash before calling this function).
Find the term with the fewest implicant covers, along with a list of those covers.
my($term, @covers) = covered_least(\%primes);
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.
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.
Returns the number of removals made.
Returns the unique arrays from an array of arrays (i.e., we're ensuring non-duplicate answers).
my @uels = uniqels(@els);
Transposes a hash-of-arrays structure of the type used for %primes.
my %table90 = transpose(\%table)
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);
Darren M. Kulp
John M. Gamble firstname.lastname@example.org (current maintainer)
Copyright (c) 2006 Darren Kulp. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/ for more information.