00001
00021 #include "cutInt.h"
00022
00026
00030
00042 static inline void Cut_NodeShiftCutLeaves( Cut_Cut_t * pList, int nLat )
00043 {
00044 Cut_Cut_t * pTemp;
00045 int i;
00046
00047 Cut_ListForEachCut( pList, pTemp )
00048 {
00049 pTemp->uSign = 0;
00050 for ( i = 0; i < (int)pTemp->nLeaves; i++ )
00051 {
00052 pTemp->pLeaves[i] += nLat;
00053 pTemp->uSign |= Cut_NodeSign( pTemp->pLeaves[i] );
00054 }
00055 }
00056 }
00057
00069 void Cut_NodeComputeCutsSeq( Cut_Man_t * p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int nLat0, int nLat1, int fTriv, int CutSetNum )
00070 {
00071 Cut_List_t Super, * pSuper = &Super;
00072 Cut_Cut_t * pListNew;
00073 int clk;
00074
00075
00076 p->nNodeCuts = Cut_CutCountList( Cut_NodeReadCutsOld(p, Node) );
00077 if ( p->nNodeCuts >= p->pParams->nKeepMax )
00078 return;
00079
00080
00081 if ( p->nNodeCuts == 0 )
00082 p->nNodes++;
00083
00084
00085 p->pStore0[0] = Cut_NodeReadCutsOld( p, Node0 );
00086 p->pStore0[1] = Cut_NodeReadCutsNew( p, Node0 );
00087 p->pStore1[0] = Cut_NodeReadCutsOld( p, Node1 );
00088 p->pStore1[1] = Cut_NodeReadCutsNew( p, Node1 );
00089
00090
00091 if ( Node == Node0 || Node == Node1 || Node0 == Node1 )
00092 {
00093 p->pStore0[0] = Cut_CutDupList( p, p->pStore0[0] );
00094 p->pStore0[1] = Cut_CutDupList( p, p->pStore0[1] );
00095 p->pStore1[0] = Cut_CutDupList( p, p->pStore1[0] );
00096 p->pStore1[1] = Cut_CutDupList( p, p->pStore1[1] );
00097 }
00098
00099
00100 if ( nLat0 ) Cut_NodeShiftCutLeaves( p->pStore0[0], nLat0 );
00101 if ( nLat0 ) Cut_NodeShiftCutLeaves( p->pStore0[1], nLat0 );
00102 if ( nLat1 ) Cut_NodeShiftCutLeaves( p->pStore1[0], nLat1 );
00103 if ( nLat1 ) Cut_NodeShiftCutLeaves( p->pStore1[1], nLat1 );
00104
00105
00106 p->pCompareOld = Cut_NodeReadCutsOld( p, Node );
00107 p->pCompareNew = Cut_NodeReadCutsNew( p, Node );
00108
00109
00110 clk = clock();
00111 Cut_ListStart( pSuper );
00112 Cut_NodeDoComputeCuts( p, pSuper, Node, fCompl0, fCompl1, p->pStore0[0], p->pStore1[1], 0, 0 );
00113 Cut_NodeDoComputeCuts( p, pSuper, Node, fCompl0, fCompl1, p->pStore0[1], p->pStore1[0], 0, 0 );
00114 Cut_NodeDoComputeCuts( p, pSuper, Node, fCompl0, fCompl1, p->pStore0[1], p->pStore1[1], fTriv, 0 );
00115 pListNew = Cut_ListFinish( pSuper );
00116 p->timeMerge += clock() - clk;
00117
00118
00119 if ( Node == Node0 || Node == Node1 || Node0 == Node1 )
00120 {
00121 Cut_CutRecycleList( p, p->pStore0[0] );
00122 Cut_CutRecycleList( p, p->pStore0[1] );
00123 Cut_CutRecycleList( p, p->pStore1[0] );
00124 Cut_CutRecycleList( p, p->pStore1[1] );
00125 }
00126 else
00127 {
00128 if ( nLat0 ) Cut_NodeShiftCutLeaves( p->pStore0[0], -nLat0 );
00129 if ( nLat0 ) Cut_NodeShiftCutLeaves( p->pStore0[1], -nLat0 );
00130 if ( nLat1 ) Cut_NodeShiftCutLeaves( p->pStore1[0], -nLat1 );
00131 if ( nLat1 ) Cut_NodeShiftCutLeaves( p->pStore1[1], -nLat1 );
00132 }
00133
00134
00135 if ( CutSetNum >= 0 )
00136 {
00137 assert( Cut_NodeReadCutsTemp(p, CutSetNum) == NULL );
00138 Cut_NodeWriteCutsTemp( p, CutSetNum, pListNew );
00139 }
00140 else
00141 {
00142 assert( Cut_NodeReadCutsNew(p, Node) == NULL );
00143 Cut_NodeWriteCutsNew( p, Node, pListNew );
00144 }
00145
00146
00147 if ( p->nNodeCuts >= p->pParams->nKeepMax )
00148 p->nCutsLimit++;
00149 }
00150
00162 void Cut_NodeNewMergeWithOld( Cut_Man_t * p, int Node )
00163 {
00164 Cut_Cut_t * pListOld, * pListNew, * pList;
00165
00166 pListNew = Cut_NodeReadCutsNew( p, Node );
00167 if ( pListNew == NULL )
00168 return;
00169 Cut_NodeWriteCutsNew( p, Node, NULL );
00170
00171 pListOld = Cut_NodeReadCutsOld( p, Node );
00172 if ( pListOld == NULL )
00173 {
00174 Cut_NodeWriteCutsOld( p, Node, pListNew );
00175 return;
00176 }
00177
00178 pList = Cut_CutMergeLists( pListOld, pListNew );
00179 Cut_NodeWriteCutsOld( p, Node, pList );
00180 }
00181
00182
00194 int Cut_NodeTempTransferToNew( Cut_Man_t * p, int Node, int CutSetNum )
00195 {
00196 Cut_Cut_t * pList;
00197 pList = Cut_NodeReadCutsTemp( p, CutSetNum );
00198 Cut_NodeWriteCutsTemp( p, CutSetNum, NULL );
00199 Cut_NodeWriteCutsNew( p, Node, pList );
00200 return pList != NULL;
00201 }
00202
00214 void Cut_NodeOldTransferToNew( Cut_Man_t * p, int Node )
00215 {
00216 Cut_Cut_t * pList;
00217 pList = Cut_NodeReadCutsOld( p, Node );
00218 Cut_NodeWriteCutsOld( p, Node, NULL );
00219 Cut_NodeWriteCutsNew( p, Node, pList );
00220
00221 }
00222
00226
00227