23 register
unsigned int *d, *s;
27 for(i = 0; i < n; i++) {
35 register
unsigned int a;
40 for(i = 0; (a & 1) == 0; a >>= 1, i++)
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)
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)
76 *r = i;
do r[i] = 0;
while (--i > 0);
87 r[i] = ~ (unsigned) 0;
88 r[i] >>= i * BPI -
size;
90 r[i] = ~ (unsigned) 0;
99 do r[i] = a[i];
while (--i >= 0);
105 register
pset r, a, b;
107 register int i =
LOOP(a);
108 PUTLOOP(r,i);
do r[i] = a[i] & b[i];
while (--i > 0);
114 register
pset r, a, b;
116 register int i =
LOOP(a);
117 PUTLOOP(r,i);
do r[i] = a[i] | b[i];
while (--i > 0);
123 register
pset r, a, b;
125 register int i =
LOOP(a);
126 PUTLOOP(r,i);
do r[i] = a[i] & ~b[i];
while (--i > 0);
132 register
pset r, a, b;
134 register int i =
LOOP(a);
136 PUTLOOP(r,i);
do r[i] = (a[i]&~b[i]) | (~a[i]&b[i]);
while (--i > 0);
138 PUTLOOP(r,i);
do r[i] = a[i] ^ b[i];
while (--i > 0);
145 register
pset r, a, b, mask;
147 register int i =
LOOP(a);
148 PUTLOOP(r,i);
do r[i] = (a[i]&mask[i]) | (b[i]&~mask[i]);
while (--i > 0);
154 register
pset r, a, b;
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);
164 register
pset r, a, b;
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);
176 register int i =
LOOP(a);
177 do if (a[i])
return FALSE;
while (--i > 0);
186 register int i =
LOOP(a);
187 register unsigned int test;
188 test = ~ (unsigned) 0;
189 test >>= i * BPI -
size;
193 if (a[i] != (~(
unsigned) 0))
202 register int i =
LOOP(a);
203 do if (a[i] != b[i])
return FALSE;
while (--i > 0);
211 register int i =
LOOP(a);
212 do if (a[i] & b[i])
return FALSE;
while (--i > 0);
220 register int i =
LOOP(a);
221 do if (a[i] & ~b[i])
return FALSE;
while (--i > 0);
229 register pset or, last,
p;
241 register pset and, last,
p;
253 register pset p, last;
257 A->active_count = A->count;
266 register pset p, last, pdest;
292 R->active_count = A->active_count;
293 intcpy(R->data, A->data, (
long) A->wsize * A->count);
303 long asize = A->
count * A->wsize;
304 long bsize = B->count * B->wsize;
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;
320 long asize = A->
count * A->wsize;
321 long bsize = B->count * B->wsize;
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;
339 if (set_family_garbage == NULL) {
343 set_family_garbage = A->
next;
369 set_family_garbage = A;
377 for(p = set_family_garbage; p != (
pset_family) NULL; p = pnext) {
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);
396 p =
GETSET(A, A->count++);
415 printf(
"A[%d] = %s\n", i,
ps1(p));
426 printf(
"[%4d] %s\n", i,
pbv1(p, A->sf_size));
435 register pset p, last;
448 register pset p, last;
451 (void) fscanf(fp,
"%d %d\n", &i, &j);
455 (void) fscanf(fp,
"%x", p);
456 for(j = 1; j <=
LOOP(p); j++)
457 (
void) fscanf(fp,
"%x", p+j);
468 register int n =
LOOP(a), j;
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");
475 (void) fprintf(fp,
"\n");
483 int i, j, rows, cols;
487 (void) fscanf(fp,
"%d %d\n", &rows, &cols);
489 for(i = 0; i < rows; i++) {
492 for(j = 0; j < cols; j++) {
500 fatal(
"Error reading set family");
503 if (getc(fp) !=
'\n') {
504 fatal(
"Error reading set family (at end of line)");
513 #define largest_string 120
518 register int i, num, l, len = 0, n =
NELEM(a);
523 for(i = 0; i < n; i++)
527 first =
FALSE; num = i;
529 l = 0;
do temp[l++] = num % 10 +
'0';
while ((num /= 10) > 0);
531 do s1[len++] = temp[--l];
while (l > 0);
533 s1[len++] =
'.';
s1[len++] =
'.';
s1[len++] =
'.';
549 for(i = 0; i < n; i++)
560 register
int *count, weight;
562 register int i, base;
563 register unsigned int val;
565 for(i =
LOOP(a); i > 0; ) {
566 for(val = a[i], base = --i <<
LOGBPI; val != 0; base++, val >>= 1) {
568 count[base] += weight;
580 register pset p, last;
581 register int i, base, *count;
582 register unsigned int val;
584 count =
ALLOC(
int, A->sf_size);
585 for(i = A->sf_size - 1; i >= 0; i--) {
590 for(i =
LOOP(p); i > 0; ) {
591 for(val = p[i], base = --i <<
LOGBPI; val != 0; base++, val >>= 1) {
611 register int i, base, *count;
612 register unsigned int val;
616 count =
ALLOC(
int, A->sf_size);
617 for(i = A->sf_size - 1; i >= 0; i--) {
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) {
627 count[base] += weight;
643 return sf_delcol(A, first, last-first + 1);
658 if (firstcol == A->sf_size) {
660 maxsize = BPI *
LOOPINIT(A->sf_size);
661 if ((A->sf_size + n) <= maxsize) {
681 register
int firstcol, n;
683 register pset p, last, pdest;
687 B =
sf_new(A->count, A->sf_size - n);
691 for(i = 0; i < firstcol; i++)
694 for(i = n > 0 ? firstcol + n : firstcol; i < A->sf_size; i++)
710 register pset last,
p, pdest;
711 register int word_test, word_set;
712 unsigned int bit_set, bit_test;
722 if ((p[word_test] & bit_test) != 0)
723 pdest[word_set] |= bit_set;
743 register int i, bcol;
748 for(i = 0; i < A->count; i++) {
755 for(i = 0; i < A->sf_size; i++) {
778 B =
sf_new(A->sf_size, A->count);
779 B->
count = A->sf_size;
784 for(j = 0; j < A->sf_size; j++) {
803 register
int *permute, npermute;
806 register pset p, last, pdest;
809 B =
sf_new(A->count, npermute);
816 for(j = 0; j < npermute; j++)
pset_family sf_delcol(pset_family A, int firstcol, int n)
void sf_delset(pset_family A, int i)
pset_family sf_addset(pset_family A, pset s)
pset set_clear(pset r, int size)
void sf_print(pset_family A)
pset_family sf_append(pset_family A, pset_family B)
bool set_andp(pset r, pset a, pset b)
pset_family sf_new(int num, int size)
#define INLINEset_and(r, a, b)
pset sf_and(pset_family A)
pset set_fill(pset r, int size)
static void intcpy(unsigned int *d, unsigned int *s, long n)
pset_family sf_inactive(pset_family A)
pset_family sf_copy(pset_family R, pset_family A)
pset set_merge(pset r, pset a, pset b, pset mask)
int * sf_count_restricted(pset_family A, pset r)
#define foreach_set(R, last, p)
void set_write(FILE *fp, pset a)
pset set_diff(pset r, pset a, pset b)
#define INLINEset_or(r, a, b)
char * pbv1(pset s, int n)
void sf_write(FILE *fp, pset_family A)
bool setp_full(pset a, int size)
bool set_orp(pset r, pset a, pset b)
int set_dist(pset a, pset b)
bool setp_disjoint(pset a, pset b)
pset_family sf_permute(pset_family A, int *permute, int npermute)
pset set_xor(pset r, pset a, pset b)
int bit_index(unsigned int a)
bool setp_implies(pset a, pset b)
pset_family sf_delc(pset_family A, int first, int last)
pset_family sf_save(pset_family A)
#define INLINEset_copy(r, a)
pset_family sf_read(FILE *fp)
#define ABC_NAMESPACE_IMPL_END
#define is_in_set(set, e)
pset_family sf_compress(pset_family A, pset c)
static char s1[largest_string]
void set_adjcnt(pset a, int *count, int weight)
int * sf_count(pset_family A)
bool setp_equal(pset a, pset b)
#define REALLOC(type, obj, num)
#define WHICH_BIT(element)
#define ABC_NAMESPACE_IMPL_START
#define set_insert(set, e)
#define GETSET(family, index)
#define WHICH_WORD(element)
void sf_free(pset_family A)
void sf_bm_print(pset_family A)
struct set_family * pset_family
pset_family sf_copy_col(pset_family dst, int dstcol, pset_family src, int srccol)
pset_family sf_active(pset_family A)
pset sf_or(pset_family A)
pset_family sf_join(pset_family A, pset_family B)
pset_family sf_addcol(pset_family A, int firstcol, int n)
pset_family sf_transpose(pset_family A)
pset set_and(pset r, pset a, pset b)
pset_family sf_bm_read(FILE *fp)
static ABC_NAMESPACE_IMPL_START pset_family set_family_garbage
pset set_or(pset r, pset a, pset b)
#define foreachi_set(R, i, p)
pset set_copy(pset r, pset a)
#define INLINEset_clear(r, size)