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

  Synopsis    [Reorders variables according to a given permutation.]

  Description [Reorders variables according to a given permutation.
  The i-th permutation array contains the index of the variable that
  should be brought to the i-th level. ddShuffle assumes that no
  dead nodes are present and that the interaction matrix is properly
  initialized.  The reordering is achieved by a series of upward sifts.
  Returns 1 if successful; 0 otherwise.]

  SideEffects [None]

  SeeAlso []

******************************************************************************/
Function
Synopsis    [Reorders variables according to a given permutation.]

Description [Reorders variables according to a given permutation.
The i-th permutation array contains the index of the variable that
should be brought to the i-th level. ddShuffle assumes that no
dead nodes are present and that the interaction matrix is properly
initialized.  The reordering is achieved by a series of upward sifts.
Returns 1 if successful; 0 otherwise.]




Function Synopsis [ Reorders variables according to a given permutation . ] Description [ Reorders variables according to a given permutation . The i - th permutation array contains the index of the variable that should be brought to the i - th level . ddShuffle assumes that no dead nodes are present and that the interaction matrix is properly initialized . The reordering is achieved by a series of upward sifts . Returns 1 if successful ; 0 otherwise . ]
static int
ddShuffle(
  DdManager * table,
  DdHalfWord * permutation,
  int  lower,
  int  upper)
{
    DdHalfWord  index;
    int         level;
    int         position;
#if 0
    int         numvars;
#endif
    int         result;
#ifdef DD_STATS
    long        localTime;
    int         initialSize;
#ifdef DD_VERBOSE
    int         finalSize;
#endif
    int         previousSize;
#endif
#ifdef DD_STATS
    localTime = util_cpu_time();
    initialSize = table->keys - table->isolated;
#endif
#if 0
    numvars = table->size;
    (void) fprintf(table->out,"%d:", ddTotalShuffles);
    for (level = 0; level < numvars; level++) {
        (void) fprintf(table->out," %d", table->invperm[level]);
    }
    (void) fprintf(table->out,"\n");
#endif
    for (level = 0; level <= upper - lower; level++) {
        index = permutation[level];
        position = table->perm[index];
#ifdef DD_STATS
        previousSize = table->keys - table->isolated;
#endif
        result = ddSiftUp(table,position,level+lower);
        if (!result) return(0);
    }
#ifdef DD_STATS
    ddTotalShuffles++;
#ifdef DD_VERBOSE
    finalSize = table->keys - table->isolated;
    if (finalSize < initialSize) {
        (void) fprintf(table->out,"-");
    } else if (finalSize > initialSize) {
        (void) fprintf(table->out,"+");
    } else {
        (void) fprintf(table->out,"=");
    }
    if ((ddTotalShuffles & 63) == 0) (void) fprintf(table->out,"\n");
    fflush(table->out);
#endif
#endif
    return(1);
}
static int ddShuffle ( DdManager * table , DdHalfWord * permutation , int lower , int upper ) { DdHalfWord index ; int level ; int position ; #if 0 int numvars ; #endif int result ; #ifdef DD_STATS long localTime ; int initialSize ; #ifdef DD_VERBOSE int finalSize ; #endif int previousSize ; #endif #ifdef DD_STATS localTime = util_cpu_time ( ) ; initialSize = table -> keys - table -> isolated ; #endif #if 0 numvars = table -> size ; ( void ) fprintf ( table -> out , " " , ddTotalShuffles ) ; for ( level = 0 ; level < numvars ; level ++ ) { ( void ) fprintf ( table -> out , " " , table -> invperm [ level ] ) ; } ( void ) fprintf ( table -> out , " \n " ) ; #endif for ( level = 0 ; level <= upper - lower ; level ++ ) { index = permutation [ level ] ; position = table -> perm [ index ] ; #ifdef DD_STATS previousSize = table -> keys - table -> isolated ; #endif result = ddSiftUp ( table , position , level + lower ) ; if ( ! result ) return ( 0 ) ; } #ifdef DD_STATS ddTotalShuffles ++ ; #ifdef DD_VERBOSE finalSize = table -> keys - table -> isolated ; if ( finalSize < initialSize ) { ( void ) fprintf ( table -> out , " " ) ; } else if ( finalSize > initialSize ) { ( void ) fprintf ( table -> out , " " ) ; } else { ( void ) fprintf ( table -> out , " " ) ; } if ( ( ddTotalShuffles & 63 ) == 0 ) ( void ) fprintf ( table -> out , " \n " ) ; fflush ( table -> out ) ; #endif #endif return ( 1 ) ; }
Function
Synopsis    [Reorders variables according to a given permutation.]
Function Synopsis [ Reorders variables according to a given permutation . ]