📄 fxupair.c
字号:
*pnLits1 = nLits1; *pnLits2 = nLits2; return Key;}/**Function************************************************************* Synopsis [Compares the two pairs.] Description [Returns 1 if the divisors represented by these pairs are equal.] SideEffects [] SeeAlso []***********************************************************************/int Fxu_PairCompare( Fxu_Pair * pPair1, Fxu_Pair * pPair2 ){ Fxu_Lit * pD1C1, * pD1C2; Fxu_Lit * pD2C1, * pD2C2; int TopVar1, TopVar2; int Code; if ( pPair1->nLits1 != pPair2->nLits1 ) return 0; if ( pPair1->nLits2 != pPair2->nLits2 ) return 0; pD1C1 = pPair1->pCube1->lLits.pHead; pD1C2 = pPair1->pCube2->lLits.pHead; pD2C1 = pPair2->pCube1->lLits.pHead; pD2C2 = pPair2->pCube2->lLits.pHead; Code = pD1C1? 8: 0; Code |= pD1C2? 4: 0; Code |= pD2C1? 2: 0; Code |= pD2C2? 1: 0; assert( Code == 15 ); while ( 1 ) { switch ( Code ) { case 0: // -- -- NULL NULL NULL NULL return 1; case 1: // -- -1 NULL NULL NULL pD2C2 return 0; case 2: // -- 1- NULL NULL pD2C1 NULL return 0; case 3: // -- 11 NULL NULL pD2C1 pD2C2 if ( pD2C1->iVar != pD2C2->iVar ) return 0; pD2C1 = pD2C1->pHNext; pD2C2 = pD2C2->pHNext; break; case 4: // -1 -- NULL pD1C2 NULL NULL return 0; case 5: // -1 -1 NULL pD1C2 NULL pD2C2 if ( pD1C2->iVar != pD2C2->iVar ) return 0; pD1C2 = pD1C2->pHNext; pD2C2 = pD2C2->pHNext; break; case 6: // -1 1- NULL pD1C2 pD2C1 NULL return 0; case 7: // -1 11 NULL pD1C2 pD2C1 pD2C2 TopVar2 = Fxu_Min( pD2C1->iVar, pD2C2->iVar ); if ( TopVar2 == pD1C2->iVar ) { if ( pD2C1->iVar <= pD2C2->iVar ) return 0; pD1C2 = pD1C2->pHNext; pD2C2 = pD2C2->pHNext; } else if ( TopVar2 < pD1C2->iVar ) { if ( pD2C1->iVar != pD2C2->iVar ) return 0; pD2C1 = pD2C1->pHNext; pD2C2 = pD2C2->pHNext; } else return 0; break; case 8: // 1- -- pD1C1 NULL NULL NULL return 0; case 9: // 1- -1 pD1C1 NULL NULL pD2C2 return 0; case 10: // 1- 1- pD1C1 NULL pD2C1 NULL if ( pD1C1->iVar != pD2C1->iVar ) return 0; pD1C1 = pD1C1->pHNext; pD2C1 = pD2C1->pHNext; break; case 11: // 1- 11 pD1C1 NULL pD2C1 pD2C2 TopVar2 = Fxu_Min( pD2C1->iVar, pD2C2->iVar ); if ( TopVar2 == pD1C1->iVar ) { if ( pD2C1->iVar >= pD2C2->iVar ) return 0; pD1C1 = pD1C1->pHNext; pD2C1 = pD2C1->pHNext; } else if ( TopVar2 < pD1C1->iVar ) { if ( pD2C1->iVar != pD2C2->iVar ) return 0; pD2C1 = pD2C1->pHNext; pD2C2 = pD2C2->pHNext; } else return 0; break; case 12: // 11 -- pD1C1 pD1C2 NULL NULL if ( pD1C1->iVar != pD1C2->iVar ) return 0; pD1C1 = pD1C1->pHNext; pD1C2 = pD1C2->pHNext; break; case 13: // 11 -1 pD1C1 pD1C2 NULL pD2C2 TopVar1 = Fxu_Min( pD1C1->iVar, pD1C2->iVar ); if ( TopVar1 == pD2C2->iVar ) { if ( pD1C1->iVar <= pD1C2->iVar ) return 0; pD1C2 = pD1C2->pHNext; pD2C2 = pD2C2->pHNext; } else if ( TopVar1 < pD2C2->iVar ) { if ( pD1C1->iVar != pD1C2->iVar ) return 0; pD1C1 = pD1C1->pHNext; pD1C2 = pD1C2->pHNext; } else return 0; break; case 14: // 11 1- pD1C1 pD1C2 pD2C1 NULL TopVar1 = Fxu_Min( pD1C1->iVar, pD1C2->iVar ); if ( TopVar1 == pD2C1->iVar ) { if ( pD1C1->iVar >= pD1C2->iVar ) return 0; pD1C1 = pD1C1->pHNext; pD2C1 = pD2C1->pHNext; } else if ( TopVar1 < pD2C1->iVar ) { if ( pD1C1->iVar != pD1C2->iVar ) return 0; pD1C1 = pD1C1->pHNext; pD1C2 = pD1C2->pHNext; } else return 0; break; case 15: // 11 11 pD1C1 pD1C2 pD2C1 pD2C2 TopVar1 = Fxu_Min( pD1C1->iVar, pD1C2->iVar ); TopVar2 = Fxu_Min( pD2C1->iVar, pD2C2->iVar ); if ( TopVar1 == TopVar2 ) { if ( pD1C1->iVar == pD1C2->iVar ) { if ( pD2C1->iVar != pD2C2->iVar ) return 0; pD1C1 = pD1C1->pHNext; pD1C2 = pD1C2->pHNext; pD2C1 = pD2C1->pHNext; pD2C2 = pD2C2->pHNext; } else { if ( pD2C1->iVar == pD2C2->iVar ) return 0; if ( pD1C1->iVar < pD1C2->iVar ) { if ( pD2C1->iVar > pD2C2->iVar ) return 0; pD1C1 = pD1C1->pHNext; pD2C1 = pD2C1->pHNext; } else { if ( pD2C1->iVar < pD2C2->iVar ) return 0; pD1C2 = pD1C2->pHNext; pD2C2 = pD2C2->pHNext; } } } else if ( TopVar1 < TopVar2 ) { if ( pD1C1->iVar != pD1C2->iVar ) return 0; pD1C1 = pD1C1->pHNext; pD1C2 = pD1C2->pHNext; } else { if ( pD2C1->iVar != pD2C2->iVar ) return 0; pD2C1 = pD2C1->pHNext; pD2C2 = pD2C2->pHNext; } break; default: assert( 0 ); break; } Code = pD1C1? 8: 0; Code |= pD1C2? 4: 0; Code |= pD2C1? 2: 0; Code |= pD2C2? 1: 0; } return 1;}/**Function************************************************************* Synopsis [Allocates the storage for cubes pairs.] Description [] SideEffects [] SeeAlso []***********************************************************************/void Fxu_PairAllocStorage( Fxu_Var * pVar, int nCubes ){ int k;// assert( pVar->nCubes == 0 ); pVar->nCubes = nCubes; // allocate memory for all the pairs pVar->ppPairs = ALLOC( Fxu_Pair **, nCubes ); pVar->ppPairs[0] = ALLOC( Fxu_Pair *, nCubes * nCubes ); memset( pVar->ppPairs[0], 0, sizeof(Fxu_Pair *) * nCubes * nCubes ); for ( k = 1; k < nCubes; k++ ) pVar->ppPairs[k] = pVar->ppPairs[k-1] + nCubes;}/**Function************************************************************* Synopsis [Clears all pairs associated with this cube.] Description [] SideEffects [] SeeAlso []***********************************************************************/void Fxu_PairClearStorage( Fxu_Cube * pCube ){ Fxu_Var * pVar; int i; pVar = pCube->pVar; for ( i = 0; i < pVar->nCubes; i++ ) { pVar->ppPairs[pCube->iCube][i] = NULL; pVar->ppPairs[i][pCube->iCube] = NULL; }}/**Function************************************************************* Synopsis [Clears all pairs associated with this cube.] Description [] SideEffects [] SeeAlso []***********************************************************************/void Fxu_PairFreeStorage( Fxu_Var * pVar ){ if ( pVar->ppPairs ) { FREE( pVar->ppPairs[0] ); FREE( pVar->ppPairs ); }}/**Function************************************************************* Synopsis [Adds the pair to storage.] Description [] SideEffects [] SeeAlso []***********************************************************************/Fxu_Pair * Fxu_PairAlloc( Fxu_Matrix * p, Fxu_Cube * pCube1, Fxu_Cube * pCube2 ){ Fxu_Pair * pPair; assert( pCube1->pVar == pCube2->pVar ); pPair = MEM_ALLOC_FXU( p, Fxu_Pair, 1 ); memset( pPair, 0, sizeof(Fxu_Pair) ); pPair->pCube1 = pCube1; pPair->pCube2 = pCube2; pPair->iCube1 = pCube1->iCube; pPair->iCube2 = pCube2->iCube; return pPair;}/**Function************************************************************* Synopsis [Adds the pair to storage.] Description [] SideEffects [] SeeAlso []***********************************************************************/void Fxu_PairAdd( Fxu_Pair * pPair ){ Fxu_Var * pVar; pVar = pPair->pCube1->pVar; assert( pVar == pPair->pCube2->pVar ); pVar->ppPairs[pPair->iCube1][pPair->iCube2] = pPair; pVar->ppPairs[pPair->iCube2][pPair->iCube1] = pPair;}/////////////////////////////////////////////////////////////////////////// END OF FILE ///////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -