73 #define CUDD_SWAP_MOVE 0
74 #define CUDD_LINEAR_TRANSFORM_MOVE 1
75 #define CUDD_INVERSE_TRANSFORM_MOVE 2
92 static char rcsid[]
DD_UNUSED =
"$Id: cuddZddLin.c,v 1.14 2004/08/13 18:04:53 fabio Exp $";
178 goto cuddZddSiftingOutOfMem;
183 goto cuddZddSiftingOutOfMem;
186 for (i = 0; i <
size; i++) {
198 x = table->
permZ[var[i]];
199 if (x < lower || x > upper)
continue;
201 previousSize = table->
keysZ;
205 goto cuddZddSiftingOutOfMem;
207 if (table->
keysZ < (
unsigned) previousSize) {
208 (void) fprintf(table->
out,
"-");
209 }
else if (table->
keysZ > (
unsigned) previousSize) {
210 (void) fprintf(table->
out,
"+");
211 (void) fprintf(table->
out,
"\nSize increased from %d to %d while sifting variable %d\n", previousSize, table->
keysZ , var[i]);
213 (void) fprintf(table->
out,
"=");
224 cuddZddSiftingOutOfMem:
264 int oldxkeys, oldykeys;
265 int newxkeys, newykeys;
268 DdNode *f, *f1, *f0, *f11, *f10, *f01, *f00;
269 DdNode *newf1, *newf0, *g, *next, *previous;
305 for (i = 0; i < xslots; i++) {
307 if (f == NULL)
continue;
315 if ((
int) f1->
index == yindex &&
cuddE(f1) == empty &&
316 (
int) f0->
index != yindex) {
330 for (i = 0; i < yslots; i++) {
357 f->
next = ylist[posn];
374 if ((
int) f1->
index == yindex || (
int) f1->
index == xindex) {
377 f11 =
empty; f10 = f1;
380 if ((
int) f0->
index == yindex || (
int) f0->
index == xindex) {
383 f01 =
empty; f00 = f0;
395 while (newf1 != NULL) {
396 if (
cuddT(newf1) == f01 &&
cuddE(newf1) == f10 &&
397 (
int) newf1->
index == yindex) {
406 goto zddSwapOutOfMem;
407 newf1->
index = yindex; newf1->
ref = 1;
414 newf1->
next = ylist[posn];
432 while (newf0 != NULL) {
433 if (
cuddT(newf0) == f11 &&
cuddE(newf0) == f00 &&
434 (
int) newf0->
index == yindex) {
443 goto zddSwapOutOfMem;
444 newf0->
index = yindex; newf0->
ref = 1;
450 newf0->
next = ylist[posn];
464 f->
next = xlist[posn];
472 for (i = 0; i < yslots; i++) {
482 if (previous == NULL)
485 previous->
next = next;
486 }
else if ((
int) f->
index == xindex) {
487 if (previous == NULL)
490 previous->
next = next;
497 while (newf1 != NULL) {
498 if (
cuddT(newf1) == f1 &&
cuddE(newf1) == empty &&
499 (
int) newf1->
index == yindex) {
508 goto zddSwapOutOfMem;
509 newf1->
index = yindex; newf1->
ref = 1;
515 newf1->
next = ylist[posn];
517 if (posn == i && previous == NULL)
528 f->
next = xlist[posn];
541 table->
keysZ += newxkeys + newykeys - oldxkeys - oldykeys;
547 (void) fprintf(table->
out,
"x = %d y = %d\n", x, y);
552 return (table->
keysZ);
555 (void) fprintf(table->
err,
"Error: cuddZddSwapInPlace out of memory\n");
590 initial_size = table->
keysZ;
603 goto cuddZddLinearAuxOutOfMem;
607 goto cuddZddLinearAuxOutOfMem;
609 }
else if (x == xHigh) {
613 goto cuddZddLinearAuxOutOfMem;
617 goto cuddZddLinearAuxOutOfMem;
619 }
else if ((x - xLow) > (xHigh - x)) {
623 goto cuddZddLinearAuxOutOfMem;
626 assert(moveUp == NULL || moveUp->
x == x);
630 goto cuddZddLinearAuxOutOfMem;
634 goto cuddZddLinearAuxOutOfMem;
640 goto cuddZddLinearAuxOutOfMem;
644 assert(moveDown == NULL || moveDown->
y == x);
648 goto cuddZddLinearAuxOutOfMem;
652 goto cuddZddLinearAuxOutOfMem;
655 while (moveDown != NULL) {
656 move = moveDown->
next;
660 while (moveUp != NULL) {
668 cuddZddLinearAuxOutOfMem:
670 while (moveDown != NULL) {
671 move = moveDown->
next;
677 while (moveUp != NULL) {
717 limitSize = table->
keysZ;
723 goto cuddZddLinearUpOutOfMem;
726 goto cuddZddLinearUpOutOfMem;
729 goto cuddZddLinearUpOutOfMem;
735 if (newsize > size) {
741 if (newsize == 0)
goto cuddZddLinearUpOutOfMem;
743 if (newsize != size) {
744 (void) fprintf(table->
err,
"Change in size after identity transformation! From %d to %d\n",size,newsize);
753 if ((
double)size > (double)limitSize * table->
maxGrowth)
755 if (size < limitSize)
763 cuddZddLinearUpOutOfMem:
764 while (moves != NULL) {
802 limitSize = table->
keysZ;
808 goto cuddZddLinearDownOutOfMem;
811 goto cuddZddLinearDownOutOfMem;
814 goto cuddZddLinearDownOutOfMem;
820 if (newsize > size) {
826 if (newsize == 0)
goto cuddZddLinearDownOutOfMem;
827 if (newsize != size) {
828 (void) fprintf(table->
err,
"Change in size after identity transformation! From %d to %d\n",size,newsize);
836 if ((
double)size > (double)limitSize * table->
maxGrowth)
838 if (size < limitSize)
846 cuddZddLinearDownOutOfMem:
847 while (moves != NULL) {
882 for (move = moves; move != NULL; move = move->
next) {
883 if (move->
size < size) {
888 for (move = moves; move != NULL; move = move->
next) {
889 if (move->
size == size)
return(1);
925 Move *invmoves = NULL;
930 for (move = moves; move != NULL; move = move->
next) {
932 if (invmove == NULL)
goto cuddZddUndoMovesOutOfMem;
933 invmove->
x = move->
x;
934 invmove->
y = move->
y;
935 invmove->
next = invmoves;
940 if (!size)
goto cuddZddUndoMovesOutOfMem;
944 if (!size)
goto cuddZddUndoMovesOutOfMem;
946 if (!size)
goto cuddZddUndoMovesOutOfMem;
949 (void) fprintf(table->
err,
"Unforseen event in ddUndoMoves!\n");
953 if (!size)
goto cuddZddUndoMovesOutOfMem;
955 if (!size)
goto cuddZddUndoMovesOutOfMem;
962 cuddZddUndoMovesOutOfMem:
963 while (invmoves != NULL) {
964 move = invmoves->
next;
#define CUDD_INVERSE_TRANSFORM_MOVE
static int zddTotalNumberLinearTr
#define CUDD_LINEAR_TRANSFORM_MOVE
#define cuddDeallocMove(unique, node)
int(* DD_QSFP)(const void *, const void *)
int cuddZddSwapInPlace(DdManager *table, int x, int y)
#define ABC_ALLOC(type, num)
static Move * cuddZddLinearUp(DdManager *table, int y, int xLow, Move *prevMoves)
static Move * cuddZddUndoMoves(DdManager *table, Move *moves)
static char rcsid[] DD_UNUSED
#define ABC_NAMESPACE_IMPL_END
int Cudd_DebugCheck(DdManager *table)
static int cuddZddLinearAux(DdManager *table, int x, int xLow, int xHigh)
int cuddZddNextHigh(DdManager *table, int x)
DdNode * cuddDynamicAllocNode(DdManager *table)
#define cuddDeallocNode(unique, node)
static int cuddZddLinearInPlace(DdManager *table, int x, int y)
#define ABC_NAMESPACE_IMPL_START
static int cuddZddLinearBackward(DdManager *table, int size, Move *moves)
int Cudd_CheckKeys(DdManager *table)
static Move * cuddZddLinearDown(DdManager *table, int x, int xHigh, Move *prevMoves)
int cuddZddUniqueCompare(int *ptr_x, int *ptr_y)
int cuddZddNextLow(DdManager *table, int x)
int cuddZddLinearSifting(DdManager *table, int lower, int upper)
int zddTotalNumberSwapping