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

  Synopsis    [Returns the ZDD variable with index i.]

  Description [Retrieves the ZDD variable with index i if it already
  exists, or creates a new ZDD variable.  Returns a pointer to the
  variable if successful; NULL otherwise.]

  SideEffects [None]

  SeeAlso     [Cudd_bddIthVar Cudd_addIthVar]

******************************************************************************/
Function
Synopsis    [Returns the ZDD variable with index i.]

Description [Retrieves the ZDD variable with index i if it already
exists, or creates a new ZDD variable.  Returns a pointer to the
variable if successful; NULL otherwise.]




Function Synopsis [ Returns the ZDD variable with index i . ] Description [ Retrieves the ZDD variable with index i if it already exists or creates a new ZDD variable . Returns a pointer to the variable if successful ; NULL otherwise . ]
DdNode *
Cudd_zddIthVar(
  DdManager * dd,
  int  i)
{
    DdNode *res;
    DdNode *zvar;
    DdNode *lower;
    int j;
    if ((unsigned int) i >= CUDD_MAXINDEX - 1) return(NULL);
    lower = (i < dd->sizeZ - 1) ? dd->univ[dd->permZ[i]+1] : DD_ONE(dd);
    do {
        dd->reordered = 0;
        zvar = cuddUniqueInterZdd(dd, i, lower, DD_ZERO(dd));
    } while (dd->reordered == 1);
    if (zvar == NULL)
        return(NULL);
    cuddRef(zvar);
    for (j = dd->permZ[i] - 1; j >= 0; j--) {
        do {
            dd->reordered = 0;
            res = cuddUniqueInterZdd(dd, dd->invpermZ[j], zvar, zvar);
        } while (dd->reordered == 1);
        if (res == NULL) {
            Cudd_RecursiveDerefZdd(dd,zvar);
            return(NULL);
        }
        cuddRef(res);
        Cudd_RecursiveDerefZdd(dd,zvar);
        zvar = res;
    }
    cuddDeref(zvar);
    return(zvar);
}
DdNode * Cudd_zddIthVar ( DdManager * dd , int i ) { DdNode * res ; DdNode * zvar ; DdNode * lower ; int j ; if ( ( unsigned int ) i >= CUDD_MAXINDEX - 1 ) return ( NULL ) ; lower = ( i < dd -> sizeZ - 1 ) ? dd -> univ [ dd -> permZ [ i ] + 1 ] : DD_ONE ( dd ) ; do { dd -> reordered = 0 ; zvar = cuddUniqueInterZdd ( dd , i , lower , DD_ZERO ( dd ) ) ; } while ( dd -> reordered == 1 ) ; if ( zvar == NULL ) return ( NULL ) ; cuddRef ( zvar ) ; for ( j = dd -> permZ [ i ] - 1 ; j >= 0 ; j -- ) { do { dd -> reordered = 0 ; res = cuddUniqueInterZdd ( dd , dd -> invpermZ [ j ] , zvar , zvar ) ; } while ( dd -> reordered == 1 ) ; if ( res == NULL ) { Cudd_RecursiveDerefZdd ( dd , zvar ) ; return ( NULL ) ; } cuddRef ( res ) ; Cudd_RecursiveDerefZdd ( dd , zvar ) ; zvar = res ; } cuddDeref ( zvar ) ; return ( zvar ) ; }
Function
Synopsis    [Returns the ZDD variable with index i.]
Function Synopsis [ Returns the ZDD variable with index i . ]
/* The i-th variable function has the following structure:
    ** at the level corresponding to index i there is a node whose "then"
    ** child points to the universe, and whose "else" child points to zero.
    ** Above that level there are nodes with identical children.
    */ /* First we build the node at the level of index i. */ /* Now we add the "filler" nodes above the level of index i. */