void test_communicate() { int valuebuf[] = { 1 }; size_t i; ListObject *lp = list_new(); for(i = 0; i < 10; i++) { *valuebuf = i; list_add(lp, valuebuf); } ListObject *lp2 = list_new(); for(i = 5; i < 15; i++) { *valuebuf = i; list_add(lp2, valuebuf); } printf("list1 is:\n"); list_print(lp); printf("list2 is:\n"); list_print(lp2); SetObject *sp = set_fromlist(lp, int_hash, lp->keycmp, lp->keydup, 0); printf("set from list1 is:\n"); set_print_int(sp); SetObject *sp2 = set_fromlist(lp2, int_hash, lp2->keycmp, lp2->keydup, 0); printf("set from list2 is:\n"); set_print_int(sp2); printf("so, intersection of the two list is\n"); set_print_int(set_and(sp, sp2)); list_free(lp); list_free(lp2); set_free(sp); set_free(sp2); }
static void test_set(void) { char *keys1[] = {"a", "b", "r", "a", "c", "a", "d", "a", "b", "r", "a"}; char *keys2[] = {"a", "l", "a", "c", "a", "z", "a", "m"}; SetObject *a = set_new(); SetObject *b = set_new(); set_addfrom(a, (void**)keys1, 11); set_addfrom(b, (void**)keys2, 8); set_print(a); // { 'c', 'd', 'r', 'a', 'b', } set_print(b); // { 'c', 'l', 'm', 'a', 'z', } set_print(set_rsub(a, b)); //{ 'd', 'b', 'r', } set_print(set_ror(a, b)); //{ 'a', 'b', 'c', 'd', 'l', 'm', 'r', 'z', } set_print(set_rand(a, b)); //{ 'c', 'a', } set_print(set_rxor(a, b)); //{ 'b', 'd', 'l', 'm', 'r', 'z', } set_ior(a, b); set_print(a); set_isub(a, b); set_print(a); set_ixor(a, b); set_print(a); set_iand(a, b); set_print(a); set_free(a); set_free(b); char *keys3[] = {"a", "b"}; char *keys4[] = {"a", "b", "d", "c", "e", "f", "g", "h"}; SetObject *c = set_new(); SetObject *d = set_new(); set_addfrom(c, (void**)keys3, 2); set_addfrom(d, (void**)keys4, 8); set_print(set_xor(c, d)); set_print(set_and(c, d)); set_print(set_sub(c, d)); }
static void r_mult(int arg1,int arg2,set index1) { char name0[8],name1[8],name2[8]; set mind; unsigned m,mm,maxmm; int pstn[15]; int n,l; set index; index=index1; sprintf(name1,"Vrt_%d",arg1); sprintf(name2,"Vrt_%d",arg2); if(arg1 < arg2) strcpy(name0,name1); else strcpy(name0,name2); mind=set_and(index,setmassindex); if(set_eq0(mind)) reducemult(name0,name1,name2,index); else { reducemult("Vrt_0",name1,name2,index); l = 1; n = 0; while (!set_eq0(mind)) { if (set_in(l,mind)) pstn[n++] = l; set_del1(&mind,l++); } maxmm = (1 << n) - 1 ; for (mm = 1;mm <= maxmm ; mm++) { writeF(" Vrt_L:=%s$ Vrt_R:=%s$\n",name1,name2); mind=set_constr(_E); m = mm; n = 1; while (m != 0) { if ((m & 1) != 0 && (l = pstn[n-1]) != 0) { writeF(" Vrt_L:=(Vrt_L where %s)$\n",subst(l,arg1)); writeF(" Vrt_R:=(Vrt_R where %s)$\n",subst(l,arg2)); set_add1(&mind,l); } ++(n); m >>= 1; } reducemult("Vrt_0","Vrt_0 + Vrt_L","Vrt_R",set_aun(index,mind)); writeF(" Clear Vrt_L $ Clear Vrt_R $\n"); } writeF(" %s:=Vrt_0 $ Clear Vrt_0 $\n",name0); } if (arg1 < arg2) { writeF(" Clear %s$\n",name2); for (n = 1; n <= vcs.sizet; n++) if (vertmap[n-1] == arg2) vertmap[n-1] = arg1; } if (arg2 < arg1) { writeF(" Clear %s$\n",name1); for (n = 1; n <= vcs.sizet; n++) if (vertmap[n-1] == arg1) vertmap[n-1] = arg2; } } /* R_mult */
static void emitreducecode(void) { int i, j, v1, v2; set ind1, ind2; for(i=0; i<vcs.sizet; i++) parsedverts[i]=parseVertex(i,1); fermprgemit(); formblocks(&n_vrt); makeprgcode(); for(i=0; i<vcs.sizet; i++) free(parsedverts[i]); for (i = n_vrt - 1; i >= 1; i--) { v1 = prgcode[i-1][0]; v2 = prgcode[i-1][1]; ind1=vertinfo[v1-1].ind; ind2=vertinfo[v2-1].ind; r_mult(v1,v2,set_and(ind1,ind2)); vertinfo[MIN(v1,v2)-1].g5 = vertinfo[v1-1].g5 + vertinfo[v2-1].g5; vertinfo[MIN(v1,v2)-1].ind= set_aun(set_or(ind1,ind2),set_and(ind1,ind2)); } for (i = 0; i < vcs.sizet; i++) for (j = 0; j <vcs.valence[i]; j++) { int mom,np; mom=vcs.vertlist[i][j].moment; np =vcs.vertlist[i][j].partcl; if (mom>0 && prtclbase1[np].hlp == 't') { writeF("Vrt_1:=Vrt_1*(%s**2",prtclbase1[np].massidnt); if(prtclbase1[ghostmother(np)].hlp=='*') writeF(")$\n"); else writeF("-p%d.p%d)$\n",mom,mom); } } writeF("%%\n"); }
static set_family_t *compl_merge(set **T1, set_family_t *L, set_family_t *R, set *cl, set *cr, int var, int lifting) /* Original ON-set */ /* Complement from each recursion branch */ /* cubes used for cofactoring */ /* splitting variable */ /* whether to perform lifting or not */ { set *p, *last, *pt; set_family_t *T, *Tbar; set **L1, **R1; if (debug & COMPL) { printf("compl_merge: left %d, right %d\n", L->count, R->count); printf("%s (cl)\n%s (cr)\nLeft is\n", pc1(cl), pc2(cr)); cprint(L); printf("Right is\n"); cprint(R); } // Intersect each cube with the cofactored cube foreach_set(L, last, p) { set_and(p, p, cl); SET(p, ACTIVE); }
foreach_set(R, last, p) { set_and(p, p, cr); SET(p, ACTIVE); }