src/misc/espresso/primes.c File Reference

#include "espresso.h"
Include dependency graph for primes.c:

Go to the source code of this file.

Functions

static bool primes_consensus_special_cases ()
static pcover primes_consensus_merge ()
static pcover and_with_cofactor ()
pcover primes_consensus (pcube *T)
static bool primes_consensus_special_cases (pcube *T, pcover *Tnew)
static pcover primes_consensus_merge (pcover Tl, pcover Tr, pcube cl, pcube cr)
static pcover and_with_cofactor (pset_family A, pset cof)

Function Documentation

static pcover and_with_cofactor ( pset_family  A,
pset  cof 
) [static]

Definition at line 155 of file primes.c.

00158 {
00159     register pset last, p;
00160 
00161     foreach_set(A, last, p) {
00162         INLINEset_and(p, p, cof);
00163         if (cdist(p, cube.fullset) > 0) {
00164             RESET(p, ACTIVE);
00165         } else {
00166             SET(p, ACTIVE);
00167         }
00168     }
00169     return sf_inactive(A);
00170 }

static pcover and_with_cofactor (  )  [static]
pcover primes_consensus ( pcube *  T  ) 

Definition at line 18 of file primes.c.

00020 {
00021     register pcube cl, cr;
00022     register int best;
00023     pcover Tnew, Tl, Tr;
00024 
00025     if (primes_consensus_special_cases(T, &Tnew) == MAYBE) {
00026         cl = new_cube();
00027         cr = new_cube();
00028         best = binate_split_select(T, cl, cr, COMPL);
00029 
00030         Tl = primes_consensus(scofactor(T, cl, best));
00031         Tr = primes_consensus(scofactor(T, cr, best));
00032         Tnew = primes_consensus_merge(Tl, Tr, cl, cr);
00033 
00034         free_cube(cl);
00035         free_cube(cr);
00036         free_cubelist(T);
00037     }
00038 
00039     return Tnew;
00040 }

static pcover primes_consensus_merge ( pcover  Tl,
pcover  Tr,
pcube  cl,
pcube  cr 
) [static]

Definition at line 118 of file primes.c.

00121 {
00122     register pcube pl, pr, lastl, lastr, pt;
00123     pcover T, Tsave;
00124 
00125     Tl = and_with_cofactor(Tl, cl);
00126     Tr = and_with_cofactor(Tr, cr);
00127 
00128     T = sf_new(500, Tl->sf_size);
00129     pt = T->data;
00130     Tsave = sf_contain(sf_join(Tl, Tr));
00131 
00132     foreach_set(Tl, lastl, pl) {
00133         foreach_set(Tr, lastr, pr) {
00134             if (cdist01(pl, pr) == 1) {
00135                 consensus(pt, pl, pr);
00136                 if (++T->count >= T->capacity) {
00137                     Tsave = sf_union(Tsave, sf_contain(T));
00138                     T = sf_new(500, Tl->sf_size);
00139                     pt = T->data;
00140                 } else {
00141                     pt += T->wsize;
00142                 }
00143             }
00144         }
00145     }
00146     free_cover(Tl);
00147     free_cover(Tr);
00148 
00149     Tsave = sf_union(Tsave, sf_contain(T));
00150     return Tsave;
00151 }

static pcover primes_consensus_merge (  )  [static]
static bool primes_consensus_special_cases ( pcube *  T,
pcover *  Tnew 
) [static]

Definition at line 43 of file primes.c.

00046 {
00047     register pcube *T1, p, ceil, cof=T[0];
00048     pcube last;
00049     pcover A;
00050 
00051     /* Check for no cubes in the cover */
00052     if (T[2] == NULL) {
00053         *Tnew = new_cover(0);
00054         free_cubelist(T);
00055         return TRUE;
00056     }
00057 
00058     /* Check for only a single cube in the cover */
00059     if (T[3] == NULL) {
00060         *Tnew = sf_addset(new_cover(1), set_or(cof, cof, T[2]));
00061         free_cubelist(T);
00062         return TRUE;
00063     }
00064 
00065     /* Check for a row of all 1's (implies function is a tautology) */
00066     for(T1 = T+2; (p = *T1++) != NULL; ) {
00067         if (full_row(p, cof)) {
00068             *Tnew = sf_addset(new_cover(1), cube.fullset);
00069             free_cubelist(T);
00070             return TRUE;
00071         }
00072     }
00073 
00074     /* Check for a column of all 0's which can be factored out */
00075     ceil = set_save(cof);
00076     for(T1 = T+2; (p = *T1++) != NULL; ) {
00077         INLINEset_or(ceil, ceil, p);
00078     }
00079     if (! setp_equal(ceil, cube.fullset)) {
00080         p = new_cube();
00081         (void) set_diff(p, cube.fullset, ceil);
00082         (void) set_or(cof, cof, p);
00083         free_cube(p);
00084 
00085         A = primes_consensus(T);
00086         foreach_set(A, last, p) {
00087             INLINEset_and(p, p, ceil);
00088         }
00089         *Tnew = A;
00090         set_free(ceil);
00091         return TRUE;
00092     }
00093     set_free(ceil);
00094 
00095     /* Collect column counts, determine unate variables, etc. */
00096     massive_count(T);
00097 
00098     /* If single active variable not factored out above, then tautology ! */
00099     if (cdata.vars_active == 1) {
00100         *Tnew = sf_addset(new_cover(1), cube.fullset);
00101         free_cubelist(T);
00102         return TRUE;
00103 
00104     /* Check for unate cover */
00105     } else if (cdata.vars_unate == cdata.vars_active) {
00106         A = cubeunlist(T);
00107         *Tnew = sf_contain(A);
00108         free_cubelist(T);
00109         return TRUE;
00110 
00111     /* Not much we can do about it */
00112     } else {
00113         return MAYBE;
00114     }
00115 }

static bool primes_consensus_special_cases (  )  [static]

Generated on Tue Jan 5 12:19:12 2010 for abc70930 by  doxygen 1.6.1