#include "util_hack.h"
#include "cuddInt.h"
Go to the source code of this file.
Functions | |
static int cuddZddCountStep | ARGS ((DdNode *P, st_table *table, DdNode *base, DdNode *empty)) |
static enum st_retval st_zdd_countfree | ARGS ((char *key, char *value, char *arg)) |
int | Cudd_zddCount (DdManager *zdd, DdNode *P) |
double | Cudd_zddCountDouble (DdManager *zdd, DdNode *P) |
static int | cuddZddCountStep (DdNode *P, st_table *table, DdNode *base, DdNode *empty) |
static double | cuddZddCountDoubleStep (DdNode *P, st_table *table, DdNode *base, DdNode *empty) |
static enum st_retval | st_zdd_countfree (char *key, char *value, char *arg) |
static enum st_retval | st_zdd_count_dbl_free (char *key, char *value, char *arg) |
Variables | |
static char rcsid[] | DD_UNUSED = "$Id: cuddZddCount.c,v 1.1.1.1 2003/02/24 22:23:53 wjiang Exp $" |
static double cuddZddCountDoubleStep ARGS | ( | (DdNode *P, st_table *table, DdNode *base, DdNode *empty) | ) | [static] |
AutomaticStart
AutomaticEnd Function********************************************************************
Synopsis [Counts the number of minterms in a ZDD.]
Description [Returns an integer representing the number of minterms in a ZDD.]
SideEffects [None]
SeeAlso [Cudd_zddCountDouble]
Definition at line 100 of file cuddZddCount.c.
00103 { 00104 st_table *table; 00105 int res; 00106 DdNode *base, *empty; 00107 00108 base = DD_ONE(zdd); 00109 empty = DD_ZERO(zdd); 00110 table = st_init_table(st_ptrcmp, st_ptrhash); 00111 if (table == NULL) return(CUDD_OUT_OF_MEM); 00112 res = cuddZddCountStep(P, table, base, empty); 00113 if (res == CUDD_OUT_OF_MEM) { 00114 zdd->errorCode = CUDD_MEMORY_OUT; 00115 } 00116 st_foreach(table, st_zdd_countfree, NIL(char)); 00117 st_free_table(table); 00118 00119 return(res); 00120 00121 } /* end of Cudd_zddCount */
Function********************************************************************
Synopsis [Counts the number of minterms of a ZDD.]
Description [Counts the number of minterms of a ZDD. The result is returned as a double. If the procedure runs out of memory, it returns (double) CUDD_OUT_OF_MEM. This procedure is used in Cudd_zddCountMinterm.]
SideEffects [None]
SeeAlso [Cudd_zddCountMinterm Cudd_zddCount]
Definition at line 139 of file cuddZddCount.c.
00142 { 00143 st_table *table; 00144 double res; 00145 DdNode *base, *empty; 00146 00147 base = DD_ONE(zdd); 00148 empty = DD_ZERO(zdd); 00149 table = st_init_table(st_ptrcmp, st_ptrhash); 00150 if (table == NULL) return((double)CUDD_OUT_OF_MEM); 00151 res = cuddZddCountDoubleStep(P, table, base, empty); 00152 if (res == (double)CUDD_OUT_OF_MEM) { 00153 zdd->errorCode = CUDD_MEMORY_OUT; 00154 } 00155 st_foreach(table, st_zdd_count_dbl_free, NIL(char)); 00156 st_free_table(table); 00157 00158 return(res); 00159 00160 } /* end of Cudd_zddCountDouble */
static double cuddZddCountDoubleStep | ( | DdNode * | P, | |
st_table * | table, | |||
DdNode * | base, | |||
DdNode * | empty | |||
) | [static] |
Function********************************************************************
Synopsis [Performs the recursive step of Cudd_zddCountDouble.]
Description []
SideEffects [None]
SeeAlso []
Definition at line 235 of file cuddZddCount.c.
00240 { 00241 double res; 00242 double *dummy; 00243 00244 if (P == empty) 00245 return((double)0.0); 00246 if (P == base) 00247 return((double)1.0); 00248 00249 /* Check cache */ 00250 if (st_lookup(table, (char *)P, (char **)(&dummy))) { 00251 res = *dummy; 00252 return(res); 00253 } 00254 00255 res = cuddZddCountDoubleStep(cuddE(P), table, base, empty) + 00256 cuddZddCountDoubleStep(cuddT(P), table, base, empty); 00257 00258 dummy = ALLOC(double, 1); 00259 if (dummy == NULL) { 00260 return((double)CUDD_OUT_OF_MEM); 00261 } 00262 *dummy = res; 00263 if (st_insert(table, (char *)P, (char *)dummy) == ST_OUT_OF_MEM) { 00264 FREE(dummy); 00265 return((double)CUDD_OUT_OF_MEM); 00266 } 00267 00268 return(res); 00269 00270 } /* end of cuddZddCountDoubleStep */
static int cuddZddCountStep | ( | DdNode * | P, | |
st_table * | table, | |||
DdNode * | base, | |||
DdNode * | empty | |||
) | [static] |
Function********************************************************************
Synopsis [Performs the recursive step of Cudd_zddCount.]
Description []
SideEffects [None]
SeeAlso []
Definition at line 185 of file cuddZddCount.c.
00190 { 00191 int res; 00192 int *dummy; 00193 00194 if (P == empty) 00195 return(0); 00196 if (P == base) 00197 return(1); 00198 00199 /* Check cache. */ 00200 if (st_lookup(table, (char *)P, (char **)(&dummy))) { 00201 res = *dummy; 00202 return(res); 00203 } 00204 00205 res = cuddZddCountStep(cuddE(P), table, base, empty) + 00206 cuddZddCountStep(cuddT(P), table, base, empty); 00207 00208 dummy = ALLOC(int, 1); 00209 if (dummy == NULL) { 00210 return(CUDD_OUT_OF_MEM); 00211 } 00212 *dummy = res; 00213 if (st_insert(table, (char *)P, (char *)dummy) == ST_OUT_OF_MEM) { 00214 FREE(dummy); 00215 return(CUDD_OUT_OF_MEM); 00216 } 00217 00218 return(res); 00219 00220 } /* end of cuddZddCountStep */
static enum st_retval st_zdd_count_dbl_free | ( | char * | key, | |
char * | value, | |||
char * | arg | |||
) | [static] |
Function********************************************************************
Synopsis [Frees the memory associated with the computed table of Cudd_zddCountDouble.]
Description []
SideEffects [None]
SeeAlso []
Definition at line 313 of file cuddZddCount.c.
00317 { 00318 double *d; 00319 00320 d = (double *)value; 00321 FREE(d); 00322 return(ST_CONTINUE); 00323 00324 } /* end of st_zdd_count_dbl_free */
static enum st_retval st_zdd_countfree | ( | char * | key, | |
char * | value, | |||
char * | arg | |||
) | [static] |
Function********************************************************************
Synopsis [Frees the memory associated with the computed table of Cudd_zddCount.]
Description []
SideEffects [None]
SeeAlso []
Definition at line 286 of file cuddZddCount.c.
00290 { 00291 int *d; 00292 00293 d = (int *)value; 00294 FREE(d); 00295 return(ST_CONTINUE); 00296 00297 } /* end of st_zdd_countfree */
char rcsid [] DD_UNUSED = "$Id: cuddZddCount.c,v 1.1.1.1 2003/02/24 22:23:53 wjiang Exp $" [static] |
CFile***********************************************************************
FileName [cuddZddCount.c]
PackageName [cudd]
Synopsis [Procedures to count the number of minterms of a ZDD.]
Description [External procedures included in this module:
Internal procedures included in this module:
procedures included in this module:
]
SeeAlso []
Author [Hyong-Kyoon Shin, In-Ho Moon]
Copyright [ This file was created at the University of Colorado at Boulder. The University of Colorado at Boulder makes no warranty about the suitability of this software for any purpose. It is presented on an AS IS basis.]
Definition at line 60 of file cuddZddCount.c.