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

  Synopsis [Computes the fraction of minterms in the on-set of all the
  positive cofactors of a BDD or ADD.]

  Description [Computes the fraction of minterms in the on-set of all
  the positive cofactors of DD. Returns the pointer to an array of
  doubles if successful; NULL otherwise. The array has as many
  positions as there are BDD variables in the manager plus one. The
  last position of the array contains the fraction of the minterms in
  the ON-set of the function represented by the BDD or ADD. The other
  positions of the array hold the variable signatures.]

  SideEffects [None]

******************************************************************************/
Function
Synopsis [Computes the fraction of minterms in the on-set of all the
positive cofactors of a BDD or ADD.]

Description [Computes the fraction of minterms in the on-set of all
the positive cofactors of DD. Returns the pointer to an array of
doubles if successful; NULL otherwise. The array has as many
positions as there are BDD variables in the manager plus one. The
last position of the array contains the fraction of the minterms in
the ON-set of the function represented by the BDD or ADD. The other
positions of the array hold the variable signatures.]


Function Synopsis [ Computes the fraction of minterms in the on - set of all the positive cofactors of a BDD or ADD . ] Description [ Computes the fraction of minterms in the on - set of all the positive cofactors of DD . Returns the pointer to an array of doubles if successful ; NULL otherwise . The array has as many positions as there are BDD variables in the manager plus one . The last position of the array contains the fraction of the minterms in the ON - set of the function represented by the BDD or ADD . The other positions of the array hold the variable signatures . ]
double *
Cudd_CofMinterm(
  DdManager * dd,
  DdNode * node)
{
    st__table    *table;
    double      *values;
    double      *result = NULL;
    int         i, firstLevel;
#ifdef DD_STATS
    long startTime;
    startTime = util_cpu_time();
    num_calls = 0;
    table_mem = sizeof( st__table);
#endif
    table = st__init_table( st__ptrcmp, st__ptrhash);
    if (table == NULL) {
        (void) fprintf(dd->err,
                       "out-of-memory, couldn't measure DD cofactors.\n");
        dd->errorCode = CUDD_MEMORY_OUT;
        return(NULL);
    }
    size = dd->size;
    values = ddCofMintermAux(dd, node, table);
    if (values != NULL) {
        result = ABC_ALLOC(double,size + 1);
        if (result != NULL) {
#ifdef DD_STATS
            table_mem += (size + 1) * sizeof(double);
#endif
            if (Cudd_IsConstant(node))
                firstLevel = 1;
            else
                firstLevel = cuddI(dd,Cudd_Regular(node)->index);
            for (i = 0; i < size; i++) {
                if (i >= cuddI(dd,Cudd_Regular(node)->index)) {
                    result[dd->invperm[i]] = values[i - firstLevel];
                } else {
                    result[dd->invperm[i]] = values[size - firstLevel];
                }
            }
            result[size] = values[size - firstLevel];
        } else {
            dd->errorCode = CUDD_MEMORY_OUT;
        }
    }
#ifdef DD_STATS
    table_mem += table->num_bins * sizeof( st__table_entry *);
#endif
    if (Cudd_Regular(node)->ref == 1) ABC_FREE(values);
    st__foreach(table, cuddStCountfree, NULL);
    st__free_table(table);
#ifdef DD_STATS
    (void) fprintf(dd->out,"Number of calls: %d\tTable memory: %d bytes\n",
                  num_calls, table_mem);
    (void) fprintf(dd->out,"Time to compute measures: %s\n",
                  util_print_time(util_cpu_time() - startTime));
#endif
    if (result == NULL) {
        (void) fprintf(dd->out,
                       "out-of-memory, couldn't measure DD cofactors.\n");
        dd->errorCode = CUDD_MEMORY_OUT;
    }
    return(result);
}
double * Cudd_CofMinterm ( DdManager * dd , DdNode * node ) { st__table * table ; double * values ; double * result = NULL ; int i , firstLevel ; #ifdef DD_STATS long startTime ; startTime = util_cpu_time ( ) ; num_calls = 0 ; table_mem = sizeof ( st__table ) ; #endif table = st__init_table ( st__ptrcmp , st__ptrhash ) ; if ( table == NULL ) { ( void ) fprintf ( dd -> err , " \n " ) ; dd -> errorCode = CUDD_MEMORY_OUT ; return ( NULL ) ; } size = dd -> size ; values = ddCofMintermAux ( dd , node , table ) ; if ( values != NULL ) { result = ABC_ALLOC ( double , size + 1 ) ; if ( result != NULL ) { #ifdef DD_STATS table_mem += ( size + 1 ) * sizeof ( double ) ; #endif if ( Cudd_IsConstant ( node ) ) firstLevel = 1 ; else firstLevel = cuddI ( dd , Cudd_Regular ( node ) -> index ) ; for ( i = 0 ; i < size ; i ++ ) { if ( i >= cuddI ( dd , Cudd_Regular ( node ) -> index ) ) { result [ dd -> invperm [ i ] ] = values [ i - firstLevel ] ; } else { result [ dd -> invperm [ i ] ] = values [ size - firstLevel ] ; } } result [ size ] = values [ size - firstLevel ] ; } else { dd -> errorCode = CUDD_MEMORY_OUT ; } } #ifdef DD_STATS table_mem += table -> num_bins * sizeof ( st__table_entry * ) ; #endif if ( Cudd_Regular ( node ) -> ref == 1 ) ABC_FREE ( values ) ; st__foreach ( table , cuddStCountfree , NULL ) ; st__free_table ( table ) ; #ifdef DD_STATS ( void ) fprintf ( dd -> out , " \t \n " , num_calls , table_mem ) ; ( void ) fprintf ( dd -> out , " \n " , util_print_time ( util_cpu_time ( ) - startTime ) ) ; #endif if ( result == NULL ) { ( void ) fprintf ( dd -> out , " \n " ) ; dd -> errorCode = CUDD_MEMORY_OUT ; } return ( result ) ; }
Function
Synopsis [Computes the fraction of minterms in the on-set of all the
positive cofactors of a BDD or ADD.]
Function Synopsis [ Computes the fraction of minterms in the on - set of all the positive cofactors of a BDD or ADD . ]