abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
set.c File Reference
#include "espresso.h"

Go to the source code of this file.

Macros

#define largest_string   120
 

Functions

static void intcpy (unsigned int *d, unsigned int *s, long n)
 
int bit_index (unsigned int a)
 
int set_ord (pset a)
 
int set_dist (pset a, pset b)
 
pset set_clear (pset r, int size)
 
pset set_fill (pset r, int size)
 
pset set_copy (pset r, pset a)
 
pset set_and (pset r, pset a, pset b)
 
pset set_or (pset r, pset a, pset b)
 
pset set_diff (pset r, pset a, pset b)
 
pset set_xor (pset r, pset a, pset b)
 
pset set_merge (pset r, pset a, pset b, pset mask)
 
bool set_andp (pset r, pset a, pset b)
 
bool set_orp (pset r, pset a, pset b)
 
bool setp_empty (pset a)
 
bool setp_full (pset a, int size)
 
bool setp_equal (pset a, pset b)
 
bool setp_disjoint (pset a, pset b)
 
bool setp_implies (pset a, pset b)
 
pset sf_or (pset_family A)
 
pset sf_and (pset_family A)
 
pset_family sf_active (pset_family A)
 
pset_family sf_inactive (pset_family A)
 
pset_family sf_copy (pset_family R, pset_family A)
 
pset_family sf_join (pset_family A, pset_family B)
 
pset_family sf_append (pset_family A, pset_family B)
 
pset_family sf_new (int num, int size)
 
pset_family sf_save (pset_family A)
 
void sf_free (pset_family A)
 
void sf_cleanup ()
 
pset_family sf_addset (pset_family A, pset s)
 
void sf_delset (pset_family A, int i)
 
void sf_print (pset_family A)
 
void sf_bm_print (pset_family A)
 
void sf_write (FILE *fp, pset_family A)
 
pset_family sf_read (FILE *fp)
 
void set_write (FILE *fp, pset a)
 
pset_family sf_bm_read (FILE *fp)
 
char * ps1 (pset a)
 
char * pbv1 (pset s, int n)
 
void set_adjcnt (pset a, int *count, int weight)
 
int * sf_count (pset_family A)
 
int * sf_count_restricted (pset_family A, pset r)
 
pset_family sf_delc (pset_family A, int first, int last)
 
pset_family sf_addcol (pset_family A, int firstcol, int n)
 
pset_family sf_delcol (pset_family A, int firstcol, int n)
 
pset_family sf_copy_col (pset_family dst, int dstcol, pset_family src, int srccol)
 
pset_family sf_compress (pset_family A, pset c)
 
pset_family sf_transpose (pset_family A)
 
pset_family sf_permute (pset_family A, int *permute, int npermute)
 

Variables

static
ABC_NAMESPACE_IMPL_START
pset_family 
set_family_garbage = NULL
 
static char s1 [largest_string]
 

Macro Definition Documentation

#define largest_string   120

Definition at line 513 of file set.c.

Function Documentation

int bit_index ( unsigned int  a)

Definition at line 34 of file set.c.

36 {
37  register int i;
38  if (a == 0)
39  return -1;
40  for(i = 0; (a & 1) == 0; a >>= 1, i++)
41  ;
42  return i;
43 }
static void intcpy ( unsigned int *  d,
unsigned int *  s,
long  n 
)
static

Definition at line 22 of file set.c.

25 {
26  register int i;
27  for(i = 0; i < n; i++) {
28  *d++ = *s++;
29  }
30 }
char* pbv1 ( pset  s,
int  n 
)

Definition at line 544 of file set.c.

547 {
548  register int i;
549  for(i = 0; i < n; i++)
550  s1[i] = is_in_set(s,i) ? '1' : '0';
551  s1[n] = '\0';
552  return s1;
553 }
#define is_in_set(set, e)
Definition: espresso.h:170
static char s1[largest_string]
Definition: set.c:514
char* ps1 ( pset  a)

Definition at line 515 of file set.c.

517 {
518  register int i, num, l, len = 0, n = NELEM(a);
519  char temp[20];
520  bool first = TRUE;
521 
522  s1[len++] = '[';
523  for(i = 0; i < n; i++)
524  if (is_in_set(a,i)) {
525  if (! first)
526  s1[len++] = ',';
527  first = FALSE; num = i;
528  /* Generate digits (reverse order) */
529  l = 0; do temp[l++] = num % 10 + '0'; while ((num /= 10) > 0);
530  /* Copy them back in correct order */
531  do s1[len++] = temp[--l]; while (l > 0);
532  if (len > largest_string-15) {
533  s1[len++] = '.'; s1[len++] = '.'; s1[len++] = '.';
534  break;
535  }
536  }
537 
538  s1[len++] = ']';
539  s1[len++] = '\0';
540  return s1;
541 }
#define FALSE
Definition: cudd.h:91
#define is_in_set(set, e)
Definition: espresso.h:170
#define NELEM(set)
Definition: espresso.h:116
static char s1[largest_string]
Definition: set.c:514
#define TRUE
Definition: cudd.h:88
#define largest_string
Definition: set.c:513
void set_adjcnt ( pset  a,
int *  count,
int  weight 
)

Definition at line 558 of file set.c.

561 {
562  register int i, base;
563  register unsigned int val;
564 
565  for(i = LOOP(a); i > 0; ) {
566  for(val = a[i], base = --i << LOGBPI; val != 0; base++, val >>= 1) {
567  if (val & 1) {
568  count[base] += weight;
569  }
570  }
571  }
572 }
#define LOGBPI
Definition: espresso.h:69
#define LOOP(set)
Definition: espresso.h:104
pset set_and ( pset  r,
pset  a,
pset  b 
)

Definition at line 104 of file set.c.

106 {
107  register int i = LOOP(a);
108  PUTLOOP(r,i); do r[i] = a[i] & b[i]; while (--i > 0);
109  return r;
110 }
#define PUTLOOP(set, i)
Definition: espresso.h:105
#define LOOP(set)
Definition: espresso.h:104
bool set_andp ( pset  r,
pset  a,
pset  b 
)

Definition at line 153 of file set.c.

155 {
156  register int i = LOOP(a);
157  register unsigned int x = 0;
158  PUTLOOP(r,i); do {r[i] = a[i] & b[i]; x |= r[i];} while (--i > 0);
159  return x != 0;
160 }
#define PUTLOOP(set, i)
Definition: espresso.h:105
#define LOOP(set)
Definition: espresso.h:104
pset set_clear ( pset  r,
int  size 
)

Definition at line 71 of file set.c.

74 {
75  register int i = LOOPINIT(size);
76  *r = i; do r[i] = 0; while (--i > 0);
77  return r;
78 }
static int size
Definition: cuddSign.c:86
#define LOOPINIT(size)
Definition: espresso.h:117
pset set_copy ( pset  r,
pset  a 
)

Definition at line 95 of file set.c.

97 {
98  register int i = LOOPCOPY(a);
99  do r[i] = a[i]; while (--i >= 0);
100  return r;
101 }
#define LOOPCOPY(set)
Definition: espresso.h:111
pset set_diff ( pset  r,
pset  a,
pset  b 
)

Definition at line 122 of file set.c.

124 {
125  register int i = LOOP(a);
126  PUTLOOP(r,i); do r[i] = a[i] & ~b[i]; while (--i > 0);
127  return r;
128 }
#define PUTLOOP(set, i)
Definition: espresso.h:105
#define LOOP(set)
Definition: espresso.h:104
int set_dist ( pset  a,
pset  b 
)

Definition at line 59 of file set.c.

61 {
62  register int i, sum = 0;
63  register unsigned int val;
64  for(i = LOOP(a); i > 0; i--)
65  if ((val = a[i] & b[i]) != 0)
66  sum += count_ones(val);
67  return sum;
68 }
#define LOOP(set)
Definition: espresso.h:104
#define count_ones(v)
Definition: espresso.h:245
pset set_fill ( pset  r,
int  size 
)

Definition at line 81 of file set.c.

84 {
85  register int i = LOOPINIT(size);
86  *r = i;
87  r[i] = ~ (unsigned) 0;
88  r[i] >>= i * BPI - size;
89  while (--i > 0)
90  r[i] = ~ (unsigned) 0;
91  return r;
92 }
static int size
Definition: cuddSign.c:86
#define LOOPINIT(size)
Definition: espresso.h:117
pset set_merge ( pset  r,
pset  a,
pset  b,
pset  mask 
)

Definition at line 144 of file set.c.

146 {
147  register int i = LOOP(a);
148  PUTLOOP(r,i); do r[i] = (a[i]&mask[i]) | (b[i]&~mask[i]); while (--i > 0);
149  return r;
150 }
#define PUTLOOP(set, i)
Definition: espresso.h:105
#define LOOP(set)
Definition: espresso.h:104
pset set_or ( pset  r,
pset  a,
pset  b 
)

Definition at line 113 of file set.c.

115 {
116  register int i = LOOP(a);
117  PUTLOOP(r,i); do r[i] = a[i] | b[i]; while (--i > 0);
118  return r;
119 }
#define PUTLOOP(set, i)
Definition: espresso.h:105
#define LOOP(set)
Definition: espresso.h:104
int set_ord ( pset  a)

Definition at line 47 of file set.c.

49 {
50  register int i, sum = 0;
51  register unsigned int val;
52  for(i = LOOP(a); i > 0; i--)
53  if ((val = a[i]) != 0)
54  sum += count_ones(val);
55  return sum;
56 }
#define LOOP(set)
Definition: espresso.h:104
#define count_ones(v)
Definition: espresso.h:245
bool set_orp ( pset  r,
pset  a,
pset  b 
)

Definition at line 163 of file set.c.

165 {
166  register int i = LOOP(a);
167  register unsigned int x = 0;
168  PUTLOOP(r,i); do {r[i] = a[i] | b[i]; x |= r[i];} while (--i > 0);
169  return x != 0;
170 }
#define PUTLOOP(set, i)
Definition: espresso.h:105
#define LOOP(set)
Definition: espresso.h:104
void set_write ( FILE *  fp,
pset  a 
)

Definition at line 464 of file set.c.

467 {
468  register int n = LOOP(a), j;
469 
470  for(j = 0; j <= n; j++) {
471  (void) fprintf(fp, "%x ", a[j]);
472  if ((j+1) % 8 == 0 && j != n)
473  (void) fprintf(fp, "\n\t");
474  }
475  (void) fprintf(fp, "\n");
476 }
#define LOOP(set)
Definition: espresso.h:104
pset set_xor ( pset  r,
pset  a,
pset  b 
)

Definition at line 131 of file set.c.

133 {
134  register int i = LOOP(a);
135 #ifdef IBM_WATC
136  PUTLOOP(r,i); do r[i] = (a[i]&~b[i]) | (~a[i]&b[i]); while (--i > 0);
137 #else
138  PUTLOOP(r,i); do r[i] = a[i] ^ b[i]; while (--i > 0);
139 #endif
140  return r;
141 }
#define PUTLOOP(set, i)
Definition: espresso.h:105
#define LOOP(set)
Definition: espresso.h:104
bool setp_disjoint ( pset  a,
pset  b 
)

Definition at line 208 of file set.c.

210 {
211  register int i = LOOP(a);
212  do if (a[i] & b[i]) return FALSE; while (--i > 0);
213  return TRUE;
214 }
#define FALSE
Definition: cudd.h:91
#define TRUE
Definition: cudd.h:88
#define LOOP(set)
Definition: espresso.h:104
bool setp_empty ( pset  a)

Definition at line 173 of file set.c.

175 {
176  register int i = LOOP(a);
177  do if (a[i]) return FALSE; while (--i > 0);
178  return TRUE;
179 }
#define FALSE
Definition: cudd.h:91
#define TRUE
Definition: cudd.h:88
#define LOOP(set)
Definition: espresso.h:104
bool setp_equal ( pset  a,
pset  b 
)

Definition at line 199 of file set.c.

201 {
202  register int i = LOOP(a);
203  do if (a[i] != b[i]) return FALSE; while (--i > 0);
204  return TRUE;
205 }
#define FALSE
Definition: cudd.h:91
#define TRUE
Definition: cudd.h:88
#define LOOP(set)
Definition: espresso.h:104
bool setp_full ( pset  a,
int  size 
)

Definition at line 182 of file set.c.

185 {
186  register int i = LOOP(a);
187  register unsigned int test;
188  test = ~ (unsigned) 0;
189  test >>= i * BPI - size;
190  if (a[i] != test)
191  return FALSE;
192  while (--i > 0)
193  if (a[i] != (~(unsigned) 0))
194  return FALSE;
195  return TRUE;
196 }
#define FALSE
Definition: cudd.h:91
static int size
Definition: cuddSign.c:86
#define TRUE
Definition: cudd.h:88
#define LOOP(set)
Definition: espresso.h:104
bool setp_implies ( pset  a,
pset  b 
)

Definition at line 217 of file set.c.

219 {
220  register int i = LOOP(a);
221  do if (a[i] & ~b[i]) return FALSE; while (--i > 0);
222  return TRUE;
223 }
#define FALSE
Definition: cudd.h:91
#define TRUE
Definition: cudd.h:88
#define LOOP(set)
Definition: espresso.h:104
pset_family sf_active ( pset_family  A)

Definition at line 250 of file set.c.

252 {
253  register pset p, last;
254  foreach_set(A, last, p) {
255  SET(p, ACTIVE);
256  }
257  A->active_count = A->count;
258  return A;
259 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int active_count
Definition: espresso.h:81
int count
Definition: espresso.h:80
#define SET(set, flag)
Definition: espresso.h:122
#define foreach_set(R, last, p)
Definition: espresso.h:135
unsigned int * pset
Definition: espresso.h:73
#define ACTIVE
Definition: espresso.h:129
pset_family sf_addcol ( pset_family  A,
int  firstcol,
int  n 
)

Definition at line 651 of file set.c.

654 {
655  int maxsize;
656 
657  /* Check if adding columns at the end ... */
658  if (firstcol == A->sf_size) {
659  /* If so, check if there is already enough room */
660  maxsize = BPI * LOOPINIT(A->sf_size);
661  if ((A->sf_size + n) <= maxsize) {
662  A->sf_size += n;
663  return A;
664  }
665  }
666  return sf_delcol(A, firstcol, -n);
667 }
pset_family sf_delcol(pset_family A, int firstcol, int n)
Definition: set.c:679
int sf_size
Definition: espresso.h:78
#define LOOPINIT(size)
Definition: espresso.h:117
pset_family sf_addset ( pset_family  A,
pset  s 
)

Definition at line 386 of file set.c.

389 {
390  register pset p;
391 
392  if (A->count >= A->capacity) {
393  A->capacity = A->capacity + A->capacity/2 + 1;
394  A->data = REALLOC(unsigned int, A->data, (long) A->capacity * A->wsize);
395  }
396  p = GETSET(A, A->count++);
397  INLINEset_copy(p, s);
398  return A;
399 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int count
Definition: espresso.h:80
#define INLINEset_copy(r, a)
Definition: espresso.h:195
unsigned int * pset
Definition: espresso.h:73
#define REALLOC(type, obj, num)
Definition: avl.h:29
#define GETSET(family, index)
Definition: espresso.h:161
pset data
Definition: espresso.h:82
int capacity
Definition: espresso.h:79
int wsize
Definition: espresso.h:77
pset sf_and ( pset_family  A)

Definition at line 238 of file set.c.

240 {
241  register pset and, last, p;
242 
243  and = set_fill(set_new(A->sf_size), A->sf_size);
244  foreach_set(A, last, p)
245  INLINEset_and(and, and, p);
246  return and;
247 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define INLINEset_and(r, a, b)
Definition: espresso.h:202
pset set_fill(pset r, int size)
Definition: set.c:81
#define foreach_set(R, last, p)
Definition: espresso.h:135
int sf_size
Definition: espresso.h:78
unsigned int * pset
Definition: espresso.h:73
#define set_new(size)
Definition: espresso.h:164
pset_family sf_append ( pset_family  A,
pset_family  B 
)

Definition at line 317 of file set.c.

319 {
320  long asize = A->count * A->wsize;
321  long bsize = B->count * B->wsize;
322 
323  if (A->sf_size != B->sf_size) fatal("sf_append: sf_size mismatch");
324  A->capacity = A->count + B->count;
325  A->data = REALLOC(unsigned int, A->data, (long) A->capacity * A->wsize);
326  intcpy(A->data + asize, B->data, bsize);
327  A->count += B->count;
328  A->active_count += B->active_count;
329  sf_free(B);
330  return A;
331 }
void fatal(char *s)
Definition: cvrmisc.c:140
int active_count
Definition: espresso.h:81
int count
Definition: espresso.h:80
static void intcpy(unsigned int *d, unsigned int *s, long n)
Definition: set.c:22
int sf_size
Definition: espresso.h:78
#define REALLOC(type, obj, num)
Definition: avl.h:29
void sf_free(pset_family A)
Definition: set.c:364
pset data
Definition: espresso.h:82
int capacity
Definition: espresso.h:79
int wsize
Definition: espresso.h:77
void sf_bm_print ( pset_family  A)

Definition at line 419 of file set.c.

421 {
422  char *pbv1();
423  register pset p;
424  register int i;
425  foreachi_set(A, i, p)
426  printf("[%4d] %s\n", i, pbv1(p, A->sf_size));
427 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * pbv1(pset s, int n)
Definition: set.c:544
unsigned int * pset
Definition: espresso.h:73
#define foreachi_set(R, i, p)
Definition: espresso.h:143
pset_family sf_bm_read ( FILE *  fp)

Definition at line 480 of file set.c.

482 {
483  int i, j, rows, cols;
484  register pset pdest;
485  pset_family A;
486 
487  (void) fscanf(fp, "%d %d\n", &rows, &cols);
488  A = sf_new(rows, cols);
489  for(i = 0; i < rows; i++) {
490  pdest = GETSET(A, A->count++);
491  (void) set_clear(pdest, A->sf_size);
492  for(j = 0; j < cols; j++) {
493  switch(getc(fp)) {
494  case '0':
495  break;
496  case '1':
497  set_insert(pdest, j);
498  break;
499  default:
500  fatal("Error reading set family");
501  }
502  }
503  if (getc(fp) != '\n') {
504  fatal("Error reading set family (at end of line)");
505  }
506  }
507  return A;
508 }
void fatal(char *s)
Definition: cvrmisc.c:140
pset set_clear(pset r, int size)
Definition: set.c:71
pset_family sf_new(int num, int size)
Definition: set.c:335
int count
Definition: espresso.h:80
int sf_size
Definition: espresso.h:78
unsigned int * pset
Definition: espresso.h:73
#define set_insert(set, e)
Definition: espresso.h:172
#define GETSET(family, index)
Definition: espresso.h:161
void sf_cleanup ( )

Definition at line 374 of file set.c.

375 {
376  register pset_family p, pnext;
377  for(p = set_family_garbage; p != (pset_family) NULL; p = pnext) {
378  pnext = p->next;
379  FREE(p);
380  }
382 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
struct set_family * next
Definition: espresso.h:83
#define FREE(obj)
Definition: avl.h:31
struct set_family * pset_family
static ABC_NAMESPACE_IMPL_START pset_family set_family_garbage
Definition: set.c:20
pset_family sf_compress ( pset_family  A,
pset  c 
)

Definition at line 738 of file set.c.

741 {
742  register pset p;
743  register int i, bcol;
744  pset_family B;
745 
746  /* create a clean set family for the result */
747  B = sf_new(A->count, set_ord(c));
748  for(i = 0; i < A->count; i++) {
749  p = GETSET(B, B->count++);
750  INLINEset_clear(p, B->sf_size);
751  }
752 
753  /* copy each column of A which has a 1 in c */
754  bcol = 0;
755  for(i = 0; i < A->sf_size; i++) {
756  if (is_in_set(c, i)) {
757  (void) sf_copy_col(B, bcol++, A, i);
758  }
759  }
760  sf_free(A);
761  return B;
762 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
pset_family sf_new(int num, int size)
Definition: set.c:335
int count
Definition: espresso.h:80
int sf_size
Definition: espresso.h:78
int set_ord(pset a)
Definition: set.c:47
#define is_in_set(set, e)
Definition: espresso.h:170
unsigned int * pset
Definition: espresso.h:73
#define GETSET(family, index)
Definition: espresso.h:161
void sf_free(pset_family A)
Definition: set.c:364
pset_family sf_copy_col(pset_family dst, int dstcol, pset_family src, int srccol)
Definition: set.c:706
#define INLINEset_clear(r, size)
Definition: espresso.h:197
pset_family sf_copy ( pset_family  R,
pset_family  A 
)

Definition at line 284 of file set.c.

286 {
287  R->sf_size = A->sf_size;
288  R->wsize = A->wsize;
289 /*R->capacity = A->count;*/
290 /*R->data = REALLOC(unsigned int, R->data, (long) R->capacity * R->wsize);*/
291  R->count = A->count;
292  R->active_count = A->active_count;
293  intcpy(R->data, A->data, (long) A->wsize * A->count);
294  return R;
295 }
int active_count
Definition: espresso.h:81
int count
Definition: espresso.h:80
static void intcpy(unsigned int *d, unsigned int *s, long n)
Definition: set.c:22
int sf_size
Definition: espresso.h:78
pset data
Definition: espresso.h:82
int wsize
Definition: espresso.h:77
pset_family sf_copy_col ( pset_family  dst,
int  dstcol,
pset_family  src,
int  srccol 
)

Definition at line 706 of file set.c.

709 {
710  register pset last, p, pdest;
711  register int word_test, word_set;
712  unsigned int bit_set, bit_test;
713 
714  /* CHEAT! form these constants outside the loop */
715  word_test = WHICH_WORD(srccol);
716  bit_test = 1 << WHICH_BIT(srccol);
717  word_set = WHICH_WORD(dstcol);
718  bit_set = 1 << WHICH_BIT(dstcol);
719 
720  pdest = dst->data;
721  foreach_set(src, last, p) {
722  if ((p[word_test] & bit_test) != 0)
723  pdest[word_set] |= bit_set;
724 /*
725  * equivalent code for this is ...
726  * if (is_in_set(p, srccol)) set_insert(pdest, destcol);
727  */
728  pdest += dst->wsize;
729  }
730  return dst;
731 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define foreach_set(R, last, p)
Definition: espresso.h:135
unsigned int * pset
Definition: espresso.h:73
#define WHICH_BIT(element)
Definition: espresso.h:88
#define WHICH_WORD(element)
Definition: espresso.h:87
pset data
Definition: espresso.h:82
int wsize
Definition: espresso.h:77
int* sf_count ( pset_family  A)

Definition at line 577 of file set.c.

579 {
580  register pset p, last;
581  register int i, base, *count;
582  register unsigned int val;
583 
584  count = ALLOC(int, A->sf_size);
585  for(i = A->sf_size - 1; i >= 0; i--) {
586  count[i] = 0;
587  }
588 
589  foreach_set(A, last, p) {
590  for(i = LOOP(p); i > 0; ) {
591  for(val = p[i], base = --i << LOGBPI; val != 0; base++, val >>= 1) {
592  if (val & 1) {
593  count[base]++;
594  }
595  }
596  }
597  }
598  return count;
599 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define foreach_set(R, last, p)
Definition: espresso.h:135
#define ALLOC(type, num)
Definition: avl.h:27
#define LOGBPI
Definition: espresso.h:69
int sf_size
Definition: espresso.h:78
unsigned int * pset
Definition: espresso.h:73
#define LOOP(set)
Definition: espresso.h:104
int* sf_count_restricted ( pset_family  A,
pset  r 
)

Definition at line 606 of file set.c.

609 {
610  register pset p;
611  register int i, base, *count;
612  register unsigned int val;
613  int weight;
614  pset last;
615 
616  count = ALLOC(int, A->sf_size);
617  for(i = A->sf_size - 1; i >= 0; i--) {
618  count[i] = 0;
619  }
620 
621  /* Loop for each set */
622  foreach_set(A, last, p) {
623  weight = 1024 / (set_ord(p) - 1);
624  for(i = LOOP(p); i > 0; ) {
625  for(val=p[i]&r[i], base= --i<<LOGBPI; val!=0; base++, val >>= 1) {
626  if (val & 1) {
627  count[base] += weight;
628  }
629  }
630  }
631  }
632  return count;
633 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define foreach_set(R, last, p)
Definition: espresso.h:135
#define ALLOC(type, num)
Definition: avl.h:27
#define LOGBPI
Definition: espresso.h:69
int sf_size
Definition: espresso.h:78
int set_ord(pset a)
Definition: set.c:47
unsigned int * pset
Definition: espresso.h:73
#define LOOP(set)
Definition: espresso.h:104
pset_family sf_delc ( pset_family  A,
int  first,
int  last 
)

Definition at line 639 of file set.c.

642 {
643  return sf_delcol(A, first, last-first + 1);
644 }
pset_family sf_delcol(pset_family A, int firstcol, int n)
Definition: set.c:679
pset_family sf_delcol ( pset_family  A,
int  firstcol,
int  n 
)

Definition at line 679 of file set.c.

682 {
683  register pset p, last, pdest;
684  register int i;
685  pset_family B;
686 
687  B = sf_new(A->count, A->sf_size - n);
688  foreach_set(A, last, p) {
689  pdest = GETSET(B, B->count++);
690  INLINEset_clear(pdest, B->sf_size);
691  for(i = 0; i < firstcol; i++)
692  if (is_in_set(p, i))
693  set_insert(pdest, i);
694  for(i = n > 0 ? firstcol + n : firstcol; i < A->sf_size; i++)
695  if (is_in_set(p, i))
696  set_insert(pdest, i - n);
697  }
698  sf_free(A);
699  return B;
700 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
pset_family sf_new(int num, int size)
Definition: set.c:335
int count
Definition: espresso.h:80
#define foreach_set(R, last, p)
Definition: espresso.h:135
int sf_size
Definition: espresso.h:78
#define is_in_set(set, e)
Definition: espresso.h:170
unsigned int * pset
Definition: espresso.h:73
#define set_insert(set, e)
Definition: espresso.h:172
#define GETSET(family, index)
Definition: espresso.h:161
void sf_free(pset_family A)
Definition: set.c:364
#define INLINEset_clear(r, size)
Definition: espresso.h:197
void sf_delset ( pset_family  A,
int  i 
)

Definition at line 402 of file set.c.

405 { (void) set_copy(GETSET(A,i), GETSET(A, --A->count));}
int count
Definition: espresso.h:80
#define GETSET(family, index)
Definition: espresso.h:161
pset set_copy(pset r, pset a)
Definition: set.c:95
void sf_free ( pset_family  A)

Definition at line 364 of file set.c.

366 {
367  FREE(A->data);
369  set_family_garbage = A;
370 }
struct set_family * next
Definition: espresso.h:83
#define FREE(obj)
Definition: avl.h:31
pset data
Definition: espresso.h:82
static ABC_NAMESPACE_IMPL_START pset_family set_family_garbage
Definition: set.c:20
pset_family sf_inactive ( pset_family  A)

Definition at line 263 of file set.c.

265 {
266  register pset p, last, pdest;
267 
268  pdest = A->data;
269  foreach_set(A, last, p) {
270  if (TESTP(p, ACTIVE)) {
271  if (pdest != p) {
272  INLINEset_copy(pdest, p);
273  }
274  pdest += A->wsize;
275  } else {
276  A->count--;
277  }
278  }
279  return A;
280 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int count
Definition: espresso.h:80
#define foreach_set(R, last, p)
Definition: espresso.h:135
#define INLINEset_copy(r, a)
Definition: espresso.h:195
unsigned int * pset
Definition: espresso.h:73
#define TESTP(set, flag)
Definition: espresso.h:124
#define ACTIVE
Definition: espresso.h:129
pset data
Definition: espresso.h:82
int wsize
Definition: espresso.h:77
pset_family sf_join ( pset_family  A,
pset_family  B 
)

Definition at line 299 of file set.c.

301 {
302  pset_family R;
303  long asize = A->count * A->wsize;
304  long bsize = B->count * B->wsize;
305 
306  if (A->sf_size != B->sf_size) fatal("sf_join: sf_size mismatch");
307  R = sf_new(A->count + B->count, A->sf_size);
308  R->count = A->count + B->count;
310  intcpy(R->data, A->data, asize);
311  intcpy(R->data + asize, B->data, bsize);
312  return R;
313 }
void fatal(char *s)
Definition: cvrmisc.c:140
pset_family sf_new(int num, int size)
Definition: set.c:335
int active_count
Definition: espresso.h:81
int count
Definition: espresso.h:80
static void intcpy(unsigned int *d, unsigned int *s, long n)
Definition: set.c:22
int sf_size
Definition: espresso.h:78
pset data
Definition: espresso.h:82
int wsize
Definition: espresso.h:77
pset_family sf_new ( int  num,
int  size 
)

Definition at line 335 of file set.c.

337 {
338  pset_family A;
339  if (set_family_garbage == NULL) {
340  A = ALLOC(set_family_t, 1);
341  } else {
342  A = set_family_garbage;
344  }
345  A->sf_size = size;
346  A->wsize = SET_SIZE(size);
347  A->capacity = num;
348  A->data = ALLOC(unsigned int, (long) A->capacity * A->wsize);
349  A->count = 0;
350  A->active_count = 0;
351  return A;
352 }
struct set_family * next
Definition: espresso.h:83
int active_count
Definition: espresso.h:81
int count
Definition: espresso.h:80
#define ALLOC(type, num)
Definition: avl.h:27
int sf_size
Definition: espresso.h:78
static int size
Definition: cuddSign.c:86
pset data
Definition: espresso.h:82
static ABC_NAMESPACE_IMPL_START pset_family set_family_garbage
Definition: set.c:20
int capacity
Definition: espresso.h:79
int wsize
Definition: espresso.h:77
#define SET_SIZE(size)
Definition: espresso.h:94
pset sf_or ( pset_family  A)

Definition at line 226 of file set.c.

228 {
229  register pset or, last, p;
230 
231  or = set_new(A->sf_size);
232  foreach_set(A, last, p)
233  INLINEset_or(or, or, p);
234  return or;
235 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define foreach_set(R, last, p)
Definition: espresso.h:135
#define INLINEset_or(r, a, b)
Definition: espresso.h:205
int sf_size
Definition: espresso.h:78
unsigned int * pset
Definition: espresso.h:73
#define set_new(size)
Definition: espresso.h:164
pset_family sf_permute ( pset_family  A,
int *  permute,
int  npermute 
)

Definition at line 801 of file set.c.

804 {
805  pset_family B;
806  register pset p, last, pdest;
807  register int j;
808 
809  B = sf_new(A->count, npermute);
810  B->count = A->count;
811  foreach_set(B, last, p)
812  INLINEset_clear(p, npermute);
813 
814  pdest = B->data;
815  foreach_set(A, last, p) {
816  for(j = 0; j < npermute; j++)
817  if (is_in_set(p, permute[j]))
818  set_insert(pdest, j);
819  pdest += B->wsize;
820  }
821  sf_free(A);
822  return B;
823 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
pset_family sf_new(int num, int size)
Definition: set.c:335
int count
Definition: espresso.h:80
#define foreach_set(R, last, p)
Definition: espresso.h:135
#define is_in_set(set, e)
Definition: espresso.h:170
unsigned int * pset
Definition: espresso.h:73
#define set_insert(set, e)
Definition: espresso.h:172
void sf_free(pset_family A)
Definition: set.c:364
int wsize
Definition: espresso.h:77
#define INLINEset_clear(r, size)
Definition: espresso.h:197
void sf_print ( pset_family  A)

Definition at line 408 of file set.c.

410 {
411  char *ps1();
412  register pset p;
413  register int i;
414  foreachi_set(A, i, p)
415  printf("A[%d] = %s\n", i, ps1(p));
416 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned int * pset
Definition: espresso.h:73
#define foreachi_set(R, i, p)
Definition: espresso.h:143
char * ps1(pset a)
Definition: set.c:515
pset_family sf_read ( FILE *  fp)

Definition at line 444 of file set.c.

446 {
447  int i, j;
448  register pset p, last;
449  pset_family A;
450 
451  (void) fscanf(fp, "%d %d\n", &i, &j);
452  A = sf_new(i, j);
453  A->count = i;
454  foreach_set(A, last, p) {
455  (void) fscanf(fp, "%x", p);
456  for(j = 1; j <= LOOP(p); j++)
457  (void) fscanf(fp, "%x", p+j);
458  }
459  return A;
460 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
pset_family sf_new(int num, int size)
Definition: set.c:335
int count
Definition: espresso.h:80
#define foreach_set(R, last, p)
Definition: espresso.h:135
unsigned int * pset
Definition: espresso.h:73
#define LOOP(set)
Definition: espresso.h:104
pset_family sf_save ( pset_family  A)

Definition at line 356 of file set.c.

358 {
359  return sf_copy(sf_new(A->count, A->sf_size), A);
360 }
pset_family sf_new(int num, int size)
Definition: set.c:335
int count
Definition: espresso.h:80
pset_family sf_copy(pset_family R, pset_family A)
Definition: set.c:284
int sf_size
Definition: espresso.h:78
pset_family sf_transpose ( pset_family  A)

Definition at line 771 of file set.c.

773 {
774  pset_family B;
775  register pset p;
776  register int i, j;
777 
778  B = sf_new(A->sf_size, A->count);
779  B->count = A->sf_size;
780  foreachi_set(B, i, p) {
781  INLINEset_clear(p, B->sf_size);
782  }
783  foreachi_set(A, i, p) {
784  for(j = 0; j < A->sf_size; j++) {
785  if (is_in_set(p, j)) {
786  set_insert(GETSET(B, j), i);
787  }
788  }
789  }
790  sf_free(A);
791  return B;
792 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
pset_family sf_new(int num, int size)
Definition: set.c:335
int count
Definition: espresso.h:80
int sf_size
Definition: espresso.h:78
#define is_in_set(set, e)
Definition: espresso.h:170
unsigned int * pset
Definition: espresso.h:73
#define set_insert(set, e)
Definition: espresso.h:172
#define GETSET(family, index)
Definition: espresso.h:161
void sf_free(pset_family A)
Definition: set.c:364
#define foreachi_set(R, i, p)
Definition: espresso.h:143
#define INLINEset_clear(r, size)
Definition: espresso.h:197
void sf_write ( FILE *  fp,
pset_family  A 
)

Definition at line 431 of file set.c.

434 {
435  register pset p, last;
436  (void) fprintf(fp, "%d %d\n", A->count, A->sf_size);
437  foreach_set(A, last, p)
438  set_write(fp, p);
439  (void) fflush(fp);
440 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int count
Definition: espresso.h:80
#define foreach_set(R, last, p)
Definition: espresso.h:135
void set_write(FILE *fp, pset a)
Definition: set.c:464
int sf_size
Definition: espresso.h:78
unsigned int * pset
Definition: espresso.h:73

Variable Documentation

char s1[largest_string]
static

Definition at line 514 of file set.c.

ABC_NAMESPACE_IMPL_START pset_family set_family_garbage = NULL
static

Definition at line 20 of file set.c.