src/misc/espresso/setc.c File Reference

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

Go to the source code of this file.

Functions

bool full_row (IN register pcube p, IN register pcube cof)
bool cdist0 (pcube a, pcube b)
int cdist01 (pset a, pset b)
int cdist (pset a, pset b)
pset force_lower (INOUT pset xlower, IN register pset a, IN register pset b)
void consensus (INOUT pcube r, IN register pcube a, IN register pcube b)
int cactive (pcube a)
bool ccommon (pcube a, pcube b, pcube cof)
int descend (pset *a, pset *b)
int ascend (pset *a, pset *b)
int lex_order (pset *a, pset *b)
int d1_order (pset *a, pset *b)
int desc1 (pset a, pset b)

Function Documentation

int ascend ( pset a,
pset b 
)

Definition at line 420 of file setc.c.

00422 {
00423     register pset a1 = *a, b1 = *b;
00424     if (SIZE(a1) > SIZE(b1)) return 1;
00425     else if (SIZE(a1) < SIZE(b1)) return -1;
00426     else {
00427         register int i = LOOP(a1);
00428         do
00429             if (a1[i] > b1[i]) return 1; else if (a1[i] < b1[i]) return -1;
00430         while (--i > 0);
00431     }
00432     return 0;
00433 }

int cactive ( pcube  a  ) 

Definition at line 290 of file setc.c.

00292 {
00293     int active = -1, dist = 0, bit_index();
00294 
00295  {  /* Check binary variables */
00296     register int w, last;
00297     register unsigned int x;
00298     if ((last = cube.inword) != -1) {
00299 
00300         /* Check the partial word of binary variables */
00301         x = a[last];
00302         if (x = ~ (x & x >> 1) & cube.inmask) {
00303             if ((dist = count_ones(x)) > 1)
00304                 return -1;              /* more than 2 active variables */
00305             active = (last-1)*(BPI/2) + bit_index(x) / 2;
00306         }
00307 
00308         /* Check the full words of binary variables */
00309         for(w = 1; w < last; w++) {
00310             x = a[w];
00311             if (x = ~ (x & x >> 1) & DISJOINT) {
00312                 if ((dist += count_ones(x)) > 1)
00313                     return -1;          /* more than 2 active variables */
00314                 active = (w-1)*(BPI/2) + bit_index(x) / 2;
00315             }
00316         }
00317     }
00318  }
00319 
00320  {  /* Check the multiple-valued variables */
00321     register int w, var, last;
00322     register pcube mask;
00323     for(var = cube.num_binary_vars; var < cube.num_vars; var++) {
00324         mask = cube.var_mask[var];
00325         last = cube.last_word[var];
00326         for(w = cube.first_word[var]; w <= last; w++)
00327             if (mask[w] & ~ a[w]) {
00328                 if (++dist > 1)
00329                     return -1;
00330                 active = var;
00331                 break;
00332             }
00333     }
00334  }
00335  return active;
00336 }

bool ccommon ( pcube  a,
pcube  b,
pcube  cof 
)

Definition at line 343 of file setc.c.

00345 {
00346  {  /* Check binary variables */
00347     int last;
00348     register int w;
00349     register unsigned int x, y;
00350     if ((last = cube.inword) != -1) {
00351 
00352         /* Check the partial word of binary variables */
00353         x = a[last] | cof[last];
00354         y = b[last] | cof[last];
00355         if (~(x & x>>1) & ~(y & y>>1) & cube.inmask)
00356             return TRUE;
00357 
00358         /* Check the full words of binary variables */
00359         for(w = 1; w < last; w++) {
00360             x = a[w] | cof[w];
00361             y = b[w] | cof[w];
00362             if (~(x & x>>1) & ~(y & y>>1) & DISJOINT)
00363                 return TRUE;
00364         }
00365     }
00366  }
00367 
00368  {  /* Check the multiple-valued variables */
00369     int var;
00370     register int w, last;
00371     register pcube mask;
00372     for(var = cube.num_binary_vars; var < cube.num_vars; var++) {
00373         mask = cube.var_mask[var]; last = cube.last_word[var];
00374         /* Check for some part missing from a */
00375         for(w = cube.first_word[var]; w <= last; w++)
00376             if (mask[w] & ~a[w] & ~cof[w]) {
00377 
00378                 /* If so, check for some part missing from b */
00379                 for(w = cube.first_word[var]; w <= last; w++)
00380                     if (mask[w] & ~b[w] & ~cof[w])
00381                         return TRUE;            /* both active */
00382                 break;
00383             }
00384     }
00385  }
00386     return FALSE;
00387 }

int cdist ( pset  a,
pset  b 
)

Definition at line 151 of file setc.c.

00153 {
00154     int dist = 0;
00155 
00156  {  /* Check binary variables */
00157     register int w, last; register unsigned int x;
00158     if ((last = cube.inword) != -1) {
00159 
00160         /* Check the partial word of binary variables */
00161         x = a[last] & b[last];
00162         if (x = ~ (x | x >> 1) & cube.inmask)
00163             dist = count_ones(x);
00164 
00165         /* Check the full words of binary variables */
00166         for(w = 1; w < last; w++) {
00167             x = a[w] & b[w];
00168             if (x = ~ (x | x >> 1) & DISJOINT)
00169                 dist += count_ones(x);
00170         }
00171     }
00172  }
00173 
00174  {  /* Check the multiple-valued variables */
00175     register int w, var, last; register pcube mask;
00176     for(var = cube.num_binary_vars; var < cube.num_vars; var++) {
00177         mask = cube.var_mask[var]; last = cube.last_word[var];
00178         for(w = cube.first_word[var]; w <= last; w++)
00179             if (a[w] & b[w] & mask[w])
00180                 goto nextvar;
00181         dist++;
00182     nextvar: ;
00183     }
00184  }
00185     return dist;
00186 }

bool cdist0 ( pcube  a,
pcube  b 
)

Definition at line 65 of file setc.c.

00067 {
00068  {  /* Check binary variables */
00069     register int w, last; register unsigned int x;
00070     if ((last = cube.inword) != -1) {
00071 
00072         /* Check the partial word of binary variables */
00073         x = a[last] & b[last];
00074         if (~(x | x >> 1) & cube.inmask)
00075             return FALSE;               /* disjoint in some variable */
00076 
00077         /* Check the full words of binary variables */
00078         for(w = 1; w < last; w++) {
00079             x = a[w] & b[w];
00080             if (~(x | x >> 1) & DISJOINT)
00081                 return FALSE;           /* disjoint in some variable */
00082         }
00083     }
00084  }
00085 
00086  {  /* Check the multiple-valued variables */
00087     register int w, var, last; register pcube mask;
00088     for(var = cube.num_binary_vars; var < cube.num_vars; var++) {
00089         mask = cube.var_mask[var]; last = cube.last_word[var];
00090         for(w = cube.first_word[var]; w <= last; w++)
00091             if (a[w] & b[w] & mask[w])
00092                 goto nextvar;
00093         return FALSE;           /* disjoint in this variable */
00094     nextvar: ;
00095     }
00096  }
00097     return TRUE;
00098 }

int cdist01 ( pset  a,
pset  b 
)

Definition at line 106 of file setc.c.

00108 {
00109     int dist = 0;
00110 
00111  {  /* Check binary variables */
00112     register int w, last; register unsigned int x;
00113     if ((last = cube.inword) != -1) {
00114 
00115         /* Check the partial word of binary variables */
00116         x = a[last] & b[last];
00117         if (x = ~ (x | x >> 1) & cube.inmask)
00118             if ((dist = count_ones(x)) > 1)
00119                 return 2;
00120 
00121         /* Check the full words of binary variables */
00122         for(w = 1; w < last; w++) {
00123             x = a[w] & b[w];
00124             if (x = ~ (x | x >> 1) & DISJOINT)
00125                 if (dist == 1 || (dist += count_ones(x)) > 1)
00126                     return 2;
00127         }
00128     }
00129  }
00130 
00131  {  /* Check the multiple-valued variables */
00132     register int w, var, last; register pcube mask;
00133     for(var = cube.num_binary_vars; var < cube.num_vars; var++) {
00134         mask = cube.var_mask[var]; last = cube.last_word[var];
00135         for(w = cube.first_word[var]; w <= last; w++)
00136             if (a[w] & b[w] & mask[w])
00137                 goto nextvar;
00138         if (++dist > 1)
00139             return 2;
00140     nextvar: ;
00141     }
00142  }
00143     return dist;
00144 }

void consensus ( INOUT pcube  r,
IN register pcube  a,
IN register pcube  b 
)

Definition at line 243 of file setc.c.

00246 {
00247     INLINEset_clear(r, cube.size);
00248 
00249  {  /* Check binary variables (if any) */
00250     register int w, last; register unsigned int x;
00251     if ((last = cube.inword) != -1) {
00252 
00253         /* Check the partial word of binary variables */
00254         r[last] = x = a[last] & b[last];
00255         if (x = ~(x | x >> 1) & cube.inmask)
00256             r[last] |= (x | (x << 1)) & (a[last] | b[last]);
00257 
00258         /* Check the full words of binary variables */
00259         for(w = 1; w < last; w++) {
00260             r[w] = x = a[w] & b[w];
00261             if (x = ~(x | x >> 1) & DISJOINT)
00262                 r[w] |= (x | (x << 1)) & (a[w] | b[w]);
00263         }
00264     }
00265  }
00266 
00267 
00268  {  /* Check the multiple-valued variables */
00269     bool empty; int var; unsigned int x;
00270     register int w, last; register pcube mask;
00271     for(var = cube.num_binary_vars; var < cube.num_vars; var++) {
00272         mask = cube.var_mask[var];
00273         last = cube.last_word[var];
00274         empty = TRUE;
00275         for(w = cube.first_word[var]; w <= last; w++)
00276             if (x = a[w] & b[w] & mask[w])
00277                 empty = FALSE, r[w] |= x;
00278         if (empty)
00279             for(w = cube.first_word[var]; w <= last; w++)
00280                 r[w] |= mask[w] & (a[w] | b[w]);
00281     }
00282  }
00283 }

int d1_order ( pset a,
pset b 
)

Definition at line 450 of file setc.c.

00452 {
00453     register pset a1 = *a, b1 = *b, c1 = cube.temp[0];
00454     register int i = LOOP(a1);
00455     register unsigned int x1, x2;
00456     do
00457         if ((x1 = a1[i] | c1[i]) > (x2 = b1[i] | c1[i])) return -1;
00458         else if (x1 < x2) return 1;
00459     while (--i > 0);
00460     return 0;
00461 }

int desc1 ( pset  a,
pset  b 
)

Definition at line 467 of file setc.c.

00469 {
00470     if (a == (pset) NULL)
00471         return (b == (pset) NULL) ? 0 : 1;
00472     else if (b == (pset) NULL)
00473         return -1;
00474     if (SIZE(a) > SIZE(b)) return -1;
00475     else if (SIZE(a) < SIZE(b)) return 1;
00476     else {
00477         register int i = LOOP(a);
00478         do
00479             if (a[i] > b[i]) return -1; else if (a[i] < b[i]) return 1;
00480         while (--i > 0);
00481     }
00482     return 0;
00483 }

int descend ( pset a,
pset b 
)

Definition at line 404 of file setc.c.

00406 {
00407     register pset a1 = *a, b1 = *b;
00408     if (SIZE(a1) > SIZE(b1)) return -1;
00409     else if (SIZE(a1) < SIZE(b1)) return 1;
00410     else {
00411         register int i = LOOP(a1);
00412         do
00413             if (a1[i] > b1[i]) return -1; else if (a1[i] < b1[i]) return 1;
00414         while (--i > 0);
00415     }
00416     return 0;
00417 }

pset force_lower ( INOUT pset  xlower,
IN register pset  a,
IN register pset  b 
)

Definition at line 192 of file setc.c.

00195 {
00196 
00197  {  /* Check binary variables (if any) */
00198     register int w, last; register unsigned int x;
00199     if ((last = cube.inword) != -1) {
00200 
00201         /* Check the partial word of binary variables */
00202         x = a[last] & b[last];
00203         if (x = ~(x | x >> 1) & cube.inmask)
00204             xlower[last] |= (x | (x << 1)) & a[last];
00205 
00206         /* Check the full words of binary variables */
00207         for(w = 1; w < last; w++) {
00208             x = a[w] & b[w];
00209             if (x = ~(x | x >> 1) & DISJOINT)
00210                 xlower[w] |= (x | (x << 1)) & a[w];
00211         }
00212     }
00213  }
00214 
00215  {  /* Check the multiple-valued variables */
00216     register int w, var, last; register pcube mask;
00217     for(var = cube.num_binary_vars; var < cube.num_vars; var++) {
00218         mask = cube.var_mask[var]; last = cube.last_word[var];
00219         for(w = cube.first_word[var]; w <= last; w++)
00220             if (a[w] & b[w] & mask[w])
00221                 goto nextvar;
00222         for(w = cube.first_word[var]; w <= last; w++)
00223             xlower[w] |= a[w] & mask[w];
00224     nextvar: ;
00225     }
00226  }
00227     return xlower;
00228 }

bool full_row ( IN register pcube  p,
IN register pcube  cof 
)

Definition at line 53 of file setc.c.

00055 {
00056     register int i = LOOP(p);
00057     do if ((p[i] | cof[i]) != cube.fullset[i]) return FALSE; while (--i > 0);
00058     return TRUE;
00059 }

int lex_order ( pset a,
pset b 
)

Definition at line 437 of file setc.c.

00439 {
00440     register pset a1 = *a, b1 = *b;
00441     register int i = LOOP(a1);
00442     do
00443         if (a1[i] > b1[i]) return -1; else if (a1[i] < b1[i]) return 1;
00444     while (--i > 0);
00445     return 0;
00446 }


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