📄 extrazddmaxmin.c
字号:
/* check cache */ zRes = cuddCacheLookup2Zdd(dd, extraZddMinUnion, S, T); if (zRes) return(zRes); else { DdNode *zSet0, *zSet1, *zRes0, *zRes1; if ( TopS == TopT ) { /* compute maximal for subsets without the top-most element */ zSet0 = extraZddMinUnion(dd, cuddE(S), cuddE(T) ); if ( zSet0 == NULL ) return NULL; cuddRef( zSet0 ); /* compute maximal for subsets with the top-most element */ zSet1 = extraZddMinUnion(dd, cuddT(S), cuddT(T) ); if ( zSet1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zSet0); return NULL; } cuddRef( zSet1 ); } else /* if ( TopS < TopT ) */ { /* compute maximal for subsets without the top-most element */ zSet0 = extraZddMinUnion(dd, cuddE(S), T ); if ( zSet0 == NULL ) return NULL; cuddRef( zSet0 ); /* subset with this element is just the cofactor of S */ zSet1 = cuddT(S); cuddRef( zSet1 ); } /* subset without this element remains unchanged */ zRes0 = zSet0; /* remove subsets with this element that contain subsets without this element */ zRes1 = extraZddNotSupSet(dd, zSet1, zSet0); if ( zRes1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); return NULL; } cuddRef( zRes1 ); Cudd_RecursiveDerefZdd(dd, zSet1); /* create the new node */ zRes = cuddZddGetNode( dd, S->index, zRes1, zRes0 ); if ( zRes == NULL ) { Cudd_RecursiveDerefZdd( dd, zRes0 ); Cudd_RecursiveDerefZdd( dd, zRes1 ); return NULL; } cuddDeref( zRes0 ); cuddDeref( zRes1 ); /* insert the result into cache */ cuddCacheInsert2(dd, extraZddMinUnion, S, T, zRes); return zRes; }} /* end of extraZddMinUnion *//**Function******************************************************************** Synopsis [Performs the recursive step of Extra_zddDotProduct.] Description [] SideEffects [None] SeeAlso []******************************************************************************/DdNode *extraZddDotProduct( DdManager * dd, DdNode * S, DdNode * T){ DdNode *zRes; int TopS, TopT; statLine(dd); /* consider terminal cases */ if ( S == z0 || T == z0 ) return z0; if ( S == z1 ) return T; if ( T == z1 ) return S; /* the operation is commutative - normalize the problem */ TopS = dd->permZ[S->index]; TopT = dd->permZ[T->index]; if ( TopS > TopT || (TopS == TopT && (unsigned)S > (unsigned)T) ) return extraZddDotProduct(dd, T, S); /* check cache */ zRes = cuddCacheLookup2Zdd(dd, extraZddDotProduct, S, T); if (zRes) return zRes; else { DdNode *zSet0, *zSet1, *zRes0, *zRes1, *zTemp; if ( TopS == TopT ) { /* compute the union of two cofactors of T (T0+T1) */ zTemp = cuddZddUnion(dd, cuddE(T), cuddT(T) ); if ( zTemp == NULL ) return NULL; cuddRef( zTemp ); /* compute DotProduct with the top element for subsets (S1, T0+T1) */ zSet0 = extraZddDotProduct(dd, cuddT(S), zTemp ); if ( zSet0 == NULL ) { Cudd_RecursiveDerefZdd(dd, zTemp); return NULL; } cuddRef( zSet0 ); Cudd_RecursiveDerefZdd(dd, zTemp); /* compute DotProduct with the top element for subsets (S0, T1) */ zSet1 = extraZddDotProduct(dd, cuddE(S), cuddT(T) ); if ( zSet1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zSet0); return NULL; } cuddRef( zSet1 ); /* compute the union of these two partial results (zSet0 + zSet1) */ zRes1 = cuddZddUnion(dd, zSet0, zSet1 ); if ( zRes1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); return NULL; } cuddRef( zRes1 ); Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); /* compute DotProduct for subsets without the top-most element */ zRes0 = extraZddDotProduct(dd, cuddE(S), cuddE(T) ); if ( zRes0 == NULL ) { Cudd_RecursiveDerefZdd(dd, zRes1); return NULL; } cuddRef( zRes0 ); } else /* if ( TopS < TopT ) */ { /* compute DotProduct with the top element for subsets (S1, T) */ zRes1 = extraZddDotProduct(dd, cuddT(S), T ); if ( zRes1 == NULL ) return NULL; cuddRef( zRes1 ); /* compute DotProduct for subsets without the top-most element */ zRes0 = extraZddDotProduct(dd, cuddE(S), T ); if ( zRes0 == NULL ) { Cudd_RecursiveDerefZdd(dd, zRes1); return NULL; } cuddRef( zRes0 ); } /* create the new node */ zRes = cuddZddGetNode( dd, S->index, zRes1, zRes0 ); if ( zRes == NULL ) { Cudd_RecursiveDerefZdd( dd, zRes0 ); Cudd_RecursiveDerefZdd( dd, zRes1 ); return NULL; } cuddDeref( zRes0 ); cuddDeref( zRes1 ); /* insert the result into cache */ cuddCacheInsert2(dd, extraZddDotProduct, S, T, zRes); return zRes; }} /* end of extraZddDotProduct *//**Function******************************************************************** Synopsis [Performs the recursive step of Extra_zddExorProduct.] Description [] SideEffects [None] SeeAlso []******************************************************************************/DdNode *extraZddExorProduct( DdManager * dd, DdNode * S, DdNode * T){ DdNode *zRes; int TopS, TopT; statLine(dd); /* consider terminal cases */ if ( S == z0 || T == z0 ) return z0; if ( S == z1 ) return T; if ( T == z1 ) return S; /* the operation is commutative - normalize the problem */ TopS = dd->permZ[S->index]; TopT = dd->permZ[T->index]; if ( TopS > TopT || (TopS == TopT && (unsigned)S > (unsigned)T) ) return extraZddExorProduct(dd, T, S); /* check cache */ zRes = cuddCacheLookup2Zdd(dd, extraZddExorProduct, S, T); if (zRes) return zRes; else { DdNode * zSet0, * zSet1, * zRes0, * zRes1; if ( TopS == TopT ) { /* compute ExorProducts for zRes0 */ zSet0 = extraZddExorProduct(dd, cuddE(S), cuddE(T) ); if ( zSet0 == NULL ) return NULL; cuddRef( zSet0 ); zSet1 = extraZddExorProduct(dd, cuddT(S), cuddT(T) ); if ( zSet1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zSet0); return NULL; } cuddRef( zSet1 ); /* compute the union of these two partial results (zSet0 + zSet1) */ zRes0 = cuddZddUnion(dd, zSet0, zSet1 ); if ( zRes0 == NULL ) { Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); return NULL; } cuddRef( zRes0 ); Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); /* compute ExorProducts for zRes1 */ zSet0 = extraZddExorProduct(dd, cuddE(S), cuddT(T) ); if ( zSet0 == NULL ) { Cudd_RecursiveDerefZdd(dd, zRes0); return NULL; } cuddRef( zSet0 ); zSet1 = extraZddExorProduct(dd, cuddT(S), cuddE(T) ); if ( zSet1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zRes0); Cudd_RecursiveDerefZdd(dd, zSet0); return NULL; } cuddRef( zSet1 ); /* compute the union of these two partial results (zSet0 + zSet1) */ zRes1 = cuddZddUnion(dd, zSet0, zSet1 ); if ( zRes1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zRes0); Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); return NULL; } cuddRef( zRes1 ); Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); } else /* if ( TopS < TopT ) */ { /* without top element */ zRes0 = extraZddExorProduct(dd, cuddE(S), T ); if ( zRes0 == NULL ) return NULL; cuddRef( zRes0 ); /* with top element */ zRes1 = extraZddExorProduct(dd, cuddT(S), T ); if ( zRes1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zRes0); return NULL; } cuddRef( zRes1 ); } /* create the new node */ zRes = cuddZddGetNode( dd, S->index, zRes1, zRes0 ); if ( zRes == NULL ) { Cudd_RecursiveDerefZdd( dd, zRes0 ); Cudd_RecursiveDerefZdd( dd, zRes1 ); return NULL; } cuddDeref( zRes0 ); cuddDeref( zRes1 ); /* insert the result into cache */ cuddCacheInsert2(dd, extraZddExorProduct, S, T, zRes); return zRes; }} /* end of extraZddExorProduct *//**Function******************************************************************** Synopsis [Performs the recursive step of Extra_zddCrossProduct.] Description [] SideEffects [None] SeeAlso []******************************************************************************/DdNode *extraZddCrossProduct( DdManager * dd, DdNode * S, DdNode * T){ DdNode *zRes; int TopS, TopT; statLine(dd); /* consider terminal cases */ if ( S == z0 || T == z0 ) return z0; if ( S == z1 || T == z1 ) return z1; /* the operation is commutative - normalize the problem */ TopS = dd->permZ[S->index]; TopT = dd->permZ[T->index]; if ( TopS > TopT || (TopS == TopT && (unsigned)S > (unsigned)T) ) return extraZddCrossProduct(dd, T, S); /* check cache */ zRes = cuddCacheLookup2Zdd(dd, extraZddCrossProduct, S, T); if (zRes) return zRes; else { DdNode *zSet0, *zSet1, *zRes0, *zRes1, *zTemp; if ( TopS == TopT ) { /* compute the union of two cofactors of T (T0+T1) */ zTemp = cuddZddUnion(dd, cuddE(T), cuddT(T) ); if ( zTemp == NULL ) return NULL; cuddRef( zTemp ); /* compute CrossProduct without the top element for subsets (S0, T0+T1) */ zSet0 = extraZddCrossProduct(dd, cuddE(S), zTemp ); if ( zSet0 == NULL ) { Cudd_RecursiveDerefZdd(dd, zTemp); return NULL; } cuddRef( zSet0 ); Cudd_RecursiveDerefZdd(dd, zTemp); /* compute CrossProduct without the top element for subsets (S1, T0) */ zSet1 = extraZddCrossProduct(dd, cuddT(S), cuddE(T) ); if ( zSet1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zSet0); return NULL; } cuddRef( zSet1 ); /* compute the union of these two partial results (zSet0 + zSet1) */ zRes0 = cuddZddUnion(dd, zSet0, zSet1 ); if ( zRes0 == NULL ) { Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); return NULL; } cuddRef( zRes0 ); Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); /* compute CrossProduct for subsets with the top-most element */ zRes1 = extraZddCrossProduct(dd, cuddT(S), cuddT(T) ); if ( zRes1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zRes0); return NULL; } cuddRef( zRes1 ); /* create the new node */ zRes = cuddZddGetNode( dd, S->index, zRes1, zRes0 ); if ( zRes == NULL ) { Cudd_RecursiveDerefZdd( dd, zRes0 ); Cudd_RecursiveDerefZdd( dd, zRes1 ); return NULL; } cuddDeref( zRes0 ); cuddDeref( zRes1 ); } else /* if ( TopS < TopT ) */ { /* compute CrossProduct without the top element (S0, T) */ zSet0 = extraZddCrossProduct(dd, cuddE(S), T ); if ( zSet0 == NULL ) return NULL; cuddRef( zSet0 ); /* compute CrossProduct without the top element (S1, T) */ zSet1 = extraZddCrossProduct(dd, cuddT(S), T ); if ( zSet1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zSet0); return NULL; } cuddRef( zSet1 ); /* compute the union of these two partial results (zSet0 + zSet1) */ zRes = cuddZddUnion(dd, zSet0, zSet1 ); if ( zRes == NULL ) { Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); return NULL; } cuddRef( zRes ); Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); cuddDeref( zRes ); } /* insert the result into cache */ cuddCacheInsert2(dd, extraZddCrossProduct, S, T, zRes); return zRes; }} /* end of extraZddCrossProduct *//**Function******************************************************************** Synopsis [Performs the recursive step of Extra_zddMaxDotProduct.] Description [] SideEffects [None] SeeAlso []******************************************************************************/DdNode *extraZddMaxDotProduct( DdManager * dd, DdNode * S, DdNode * T){ DdNode *zRes; int TopS, TopT; statLine(dd); /* consider terminal cases */ if ( S == z0 || T == z0 ) return z0; if ( S == z1 ) return T; if ( T == z1 ) return S; /* the operation is commutative - normalize the problem */ TopS = dd->permZ[S->index]; TopT = dd->permZ[T->index]; if ( TopS > TopT || (TopS == TopT && (unsigned)S > (unsigned)T) ) return extraZddMaxDotProduct(dd, T, S); /* check cache */ zRes = cuddCacheLookup2Zdd(dd, extraZddMaxDotProduct, S, T); if (zRes) return zRes; else { DdNode *zSet0, *zSet1, *zRes0, *zRes1, *zTemp; if ( TopS == TopT ) { /* compute the union of two cofactors of T (T0+T1) */ zTemp = extraZddMaxUnion(dd, cuddE(T), cuddT(T) ); if ( zTemp == NULL ) return NULL; cuddRef( zTemp ); /* compute MaxDotProduct with the top element for subsets (S1, T0+T1) */ zSet0 = extraZddMaxDotProduct(dd, cuddT(S), zTemp ); if ( zSet0 == NULL ) { Cudd_RecursiveDerefZdd(dd, zTemp); return NULL; } cuddRef( zSet0 ); Cudd_RecursiveDerefZdd(dd, zTemp); /* compute MaxDotProduct with the top element for subsets (S0, T1) */ zSet1 = extraZddMaxDotProduct(dd, cuddE(S), cuddT(T) ); if ( zSet1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zSet0); return NULL; } cuddRef( zSet1 ); /* compute the union of these two partial results (zSet0 + zSet1) */ zRes1 = extraZddMaxUnion(dd, zSet0, zSet1 ); if ( zRes1 == NULL ) { Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); return NULL; } cuddRef( zRes1 ); Cudd_RecursiveDerefZdd(dd, zSet0); Cudd_RecursiveDerefZdd(dd, zSet1); /* compute MaxDotProduct for subsets without the top-most element */ zRes0 = extraZddMaxDotProduct(dd, cuddE(S), cuddE(T) ); if ( zRes0 == NULL ) { Cudd_RecursiveDerefZdd(dd, zRes1); return NULL; } cuddRef( zRes0 ); } else /* if ( TopS < TopT ) */ { /* compute MaxDotProduct with the top element for subsets (S1, T) */ zRes1 = extraZddMaxDotProduct(dd, cuddT(S), T ); if ( zRes1 == NULL ) return NULL; cuddRef( zRes1 ); /* compute MaxDotProduct for subsets without the top-most element */ zRes0 = extraZddMaxDotProduct(dd, cuddE(S), T ); if ( zRes0 == NULL ) { Cudd_RecursiveDerefZdd(dd, zRes1); return NULL; } cuddRef( zRes0 ); } /* remove subsets without this element covered by subsets with this element */ zRes0 = extraZddNotSubSet(dd, zTemp = zRes0, zRes1); if ( zRes0 == NULL ) { Cudd_RecursiveDerefZdd(dd, zTemp); Cudd_RecursiveDerefZdd(dd, zRes1); return NULL; } cuddRef( zRes0 ); Cudd_RecursiveDerefZdd(dd, zTemp); /* create the new node */ zRes = cuddZddGetNode( dd, S->index, zRes1, zRes0 ); if ( zRes == NULL ) { Cudd_RecursiveDerefZdd( dd, zRes0 ); Cudd_RecursiveDerefZdd( dd, zRes1 ); return NULL; } cuddDeref( zRes0 ); cuddDeref( zRes1 ); /* insert the result into cache */ cuddCacheInsert2(dd, extraZddMaxDotProduct, S, T, zRes); return zRes; }} /* end of extraZddMaxDotProduct *//*---------------------------------------------------------------------------*//* Definition of staTc Functions *//*---------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -