/**Function******************************************************************** Synopsis [Swaps two sets of variables of the same size (x and y) in the ADD f.] Description [Swaps two sets of variables of the same size (x and y) in the ADD f. The size is given by n. The two sets of variables are assumed to be disjoint. Returns a pointer to the resulting ADD if successful; NULL otherwise.] SideEffects [None] SeeAlso [Cudd_addPermute Cudd_bddSwapVariables] ******************************************************************************/ DdNode * Cudd_addSwapVariables( DdManager * dd, DdNode * f, DdNode ** x, DdNode ** y, int n) { DdNode *swapped; int i, j, k; int *permut; permut = ALLOC(int,dd->size); if (permut == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); } for (i = 0; i < dd->size; i++) permut[i] = i; for (i = 0; i < n; i++) { j = x[i]->index; k = y[i]->index; permut[j] = k; permut[k] = j; } swapped = Cudd_addPermute(dd,f,permut); FREE(permut); return(swapped); } /* end of Cudd_addSwapVariables */
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ DdNode * Extra_addRemapNatural2Sequential( DdManager * dd, DdNode * aSource, DdNode * bVars ) { static int Vars[MAXINPUTS]; static int Permute[MAXINPUTS]; int k, nVars = 0; DdNode * bTemp; // create the array of variables in the set bVars for ( bTemp = bVars; bTemp != b1; bTemp = cuddT(bTemp) ) Vars[nVars++] = bTemp->index; k = 0; for ( bTemp = bVars; bTemp != b1; bTemp = cuddT(bTemp), k++ ) Permute[bTemp->index] = Vars[nVars-1-k]; return Cudd_addPermute( dd, aSource, Permute ); }