abc/src/bdd/cudd/cuddZddLin.c
/**Function********************************************************************

  Synopsis    [Sifts a variable down and applies the XOR transformation.]

  Description [Sifts a variable down. Moves x down until either it
  reaches the bound (xHigh) or the size of the ZDD heap increases too
  much. Returns the set of moves in case of success; NULL if memory is
  full.]

  SideEffects [None]

  SeeAlso     []

******************************************************************************/
Function
Synopsis    [Sifts a variable down and applies the XOR transformation.]

Description [Sifts a variable down. Moves x down until either it
reaches the bound (xHigh) or the size of the ZDD heap increases too
much. Returns the set of moves in case of success; NULL if memory is
full.]




Function Synopsis [ Sifts a variable down and applies the XOR transformation . ] Description [ Sifts a variable down . Moves x down until either it reaches the bound ( xHigh ) or the size of the ZDD heap increases too much . Returns the set of moves in case of success ; NULL if memory is full . ]
static Move *
cuddZddLinearDown(
  DdManager * table,
  int  x,
  int  xHigh,
  Move * prevMoves)
{
    Move        *moves;
    Move        *move;
    int         y;
    int         size, newsize;
    int         limitSize;
    moves = prevMoves;
    limitSize = table->keysZ;
    y = cuddZddNextHigh(table, x);
    while (y <= xHigh) {
        size = cuddZddSwapInPlace(table, x, y);
        if (size == 0)
            goto cuddZddLinearDownOutOfMem;
        newsize = cuddZddLinearInPlace(table, x, y);
        if (newsize == 0)
            goto cuddZddLinearDownOutOfMem;
        move = (Move *) cuddDynamicAllocNode(table);
        if (move == NULL)
            goto cuddZddLinearDownOutOfMem;
        move->x = x;
        move->y = y;
        move->next = moves;
        moves = move;
        move->flags = CUDD_SWAP_MOVE;
        if (newsize > size) {
            newsize = cuddZddLinearInPlace(table,x,y);
            if (newsize == 0) goto cuddZddLinearDownOutOfMem;
            if (newsize != size) {
                (void) fprintf(table->err,"Change in size after identity transformation! From %d to %d\n",size,newsize);
            }
        } else {
            size = newsize;
            move->flags = CUDD_LINEAR_TRANSFORM_MOVE;
        }
        move->size = size;
        if ((double)size > (double)limitSize * table->maxGrowth)
            break;
        if (size < limitSize)
            limitSize = size;
        x = y;
        y = cuddZddNextHigh(table, x);
    }
    return(moves);
cuddZddLinearDownOutOfMem:
    while (moves != NULL) {
        move = moves->next;
        cuddDeallocMove(table, moves);
        moves = move;
    }
    return((Move *) CUDD_OUT_OF_MEM);
}
static Move * cuddZddLinearDown ( DdManager * table , int x , int xHigh , Move * prevMoves ) { Move * moves ; Move * move ; int y ; int size , newsize ; int limitSize ; moves = prevMoves ; limitSize = table -> keysZ ; y = cuddZddNextHigh ( table , x ) ; while ( y <= xHigh ) { size = cuddZddSwapInPlace ( table , x , y ) ; if ( size == 0 ) goto cuddZddLinearDownOutOfMem ; newsize = cuddZddLinearInPlace ( table , x , y ) ; if ( newsize == 0 ) goto cuddZddLinearDownOutOfMem ; move = ( Move * ) cuddDynamicAllocNode ( table ) ; if ( move == NULL ) goto cuddZddLinearDownOutOfMem ; move -> x = x ; move -> y = y ; move -> next = moves ; moves = move ; move -> flags = CUDD_SWAP_MOVE ; if ( newsize > size ) { newsize = cuddZddLinearInPlace ( table , x , y ) ; if ( newsize == 0 ) goto cuddZddLinearDownOutOfMem ; if ( newsize != size ) { ( void ) fprintf ( table -> err , " \n " , size , newsize ) ; } } else { size = newsize ; move -> flags = CUDD_LINEAR_TRANSFORM_MOVE ; } move -> size = size ; if ( ( double ) size > ( double ) limitSize * table -> maxGrowth ) break ; if ( size < limitSize ) limitSize = size ; x = y ; y = cuddZddNextHigh ( table , x ) ; } return ( moves ) ; cuddZddLinearDownOutOfMem : while ( moves != NULL ) { move = moves -> next ; cuddDeallocMove ( table , moves ) ; moves = move ; } return ( ( Move * ) CUDD_OUT_OF_MEM ) ; }
Function
Synopsis    [Sifts a variable down and applies the XOR transformation.]
Function Synopsis [ Sifts a variable down and applies the XOR transformation . ]
/* Undo transformation. The transformation we apply is
            ** its own inverse. Hence, we just apply the transformation
            ** again.
            */