19 #ifndef ABC__opt__fxu__fxuInt_h
20 #define ABC__opt__fxu__fxuInt_h
283 #define Fxu_Min( a, b ) ( ((a)<(b))? (a):(b) )
284 #define Fxu_Max( a, b ) ( ((a)>(b))? (a):(b) )
287 #define Fxu_PairMinCube( pPair ) (((pPair)->iCube1 < (pPair)->iCube2)? (pPair)->pCube1: (pPair)->pCube2)
288 #define Fxu_PairMaxCube( pPair ) (((pPair)->iCube1 > (pPair)->iCube2)? (pPair)->pCube1: (pPair)->pCube2)
289 #define Fxu_PairMinCubeInt( pPair ) (((pPair)->iCube1 < (pPair)->iCube2)? (pPair)->iCube1: (pPair)->iCube2)
290 #define Fxu_PairMaxCubeInt( pPair ) (((pPair)->iCube1 > (pPair)->iCube2)? (pPair)->iCube1: (pPair)->iCube2)
294 #define Fxu_MatrixForEachCube( Matrix, Cube )\
295 for ( Cube = (Matrix)->lCubes.pHead;\
298 #define Fxu_MatrixForEachCubeSafe( Matrix, Cube, Cube2 )\
299 for ( Cube = (Matrix)->lCubes.pHead, Cube2 = (Cube? Cube->pNext: NULL);\
301 Cube = Cube2, Cube2 = (Cube? Cube->pNext: NULL) )
303 #define Fxu_MatrixForEachVariable( Matrix, Var )\
304 for ( Var = (Matrix)->lVars.pHead;\
307 #define Fxu_MatrixForEachVariableSafe( Matrix, Var, Var2 )\
308 for ( Var = (Matrix)->lVars.pHead, Var2 = (Var? Var->pNext: NULL);\
310 Var = Var2, Var2 = (Var? Var->pNext: NULL) )
312 #define Fxu_MatrixForEachSingle( Matrix, Single )\
313 for ( Single = (Matrix)->lSingles.pHead;\
315 Single = Single->pNext )
316 #define Fxu_MatrixForEachSingleSafe( Matrix, Single, Single2 )\
317 for ( Single = (Matrix)->lSingles.pHead, Single2 = (Single? Single->pNext: NULL);\
319 Single = Single2, Single2 = (Single? Single->pNext: NULL) )
321 #define Fxu_TableForEachDouble( Matrix, Key, Div )\
322 for ( Div = (Matrix)->pTable[Key].pHead;\
325 #define Fxu_TableForEachDoubleSafe( Matrix, Key, Div, Div2 )\
326 for ( Div = (Matrix)->pTable[Key].pHead, Div2 = (Div? Div->pNext: NULL);\
328 Div = Div2, Div2 = (Div? Div->pNext: NULL) )
330 #define Fxu_MatrixForEachDouble( Matrix, Div, Index )\
331 for ( Index = 0; Index < (Matrix)->nTableSize; Index++ )\
332 Fxu_TableForEachDouble( Matrix, Index, Div )
333 #define Fxu_MatrixForEachDoubleSafe( Matrix, Div, Div2, Index )\
334 for ( Index = 0; Index < (Matrix)->nTableSize; Index++ )\
335 Fxu_TableForEachDoubleSafe( Matrix, Index, Div, Div2 )
338 #define Fxu_CubeForEachLiteral( Cube, Lit )\
339 for ( Lit = (Cube)->lLits.pHead;\
342 #define Fxu_CubeForEachLiteralSafe( Cube, Lit, Lit2 )\
343 for ( Lit = (Cube)->lLits.pHead, Lit2 = (Lit? Lit->pHNext: NULL);\
345 Lit = Lit2, Lit2 = (Lit? Lit->pHNext: NULL) )
347 #define Fxu_VarForEachLiteral( Var, Lit )\
348 for ( Lit = (Var)->lLits.pHead;\
352 #define Fxu_CubeForEachDivisor( Cube, Div )\
353 for ( Div = (Cube)->lDivs.pHead;\
357 #define Fxu_DoubleForEachPair( Div, Pair )\
358 for ( Pair = (Div)->lPairs.pHead;\
360 Pair = Pair->pDNext )
361 #define Fxu_DoubleForEachPairSafe( Div, Pair, Pair2 )\
362 for ( Pair = (Div)->lPairs.pHead, Pair2 = (Pair? Pair->pDNext: NULL);\
364 Pair = Pair2, Pair2 = (Pair? Pair->pDNext: NULL) )
368 #define Fxu_CubeForEachPair( pCube, pPair, i )\
370 i < pCube->pVar->nCubes && (((pPair) = (pCube)->pVar->ppPairs[(pCube)->iCube][i]), 1);\
372 if ( pPair == NULL ) {} else
375 #define Fxu_HeapDoubleForEachItem( Heap, Div )\
377 Heap->i <= Heap->nItems && (Div = Heap->pTree[Heap->i]);\
379 #define Fxu_HeapSingleForEachItem( Heap, Single )\
381 Heap->i <= Heap->nItems && (Single = Heap->pTree[Heap->i]);\
385 #define Fxu_MatrixRingCubesStart( Matrix ) (((Matrix)->ppTailCubes = &((Matrix)->pOrderCubes)), ((Matrix)->pOrderCubes = NULL))
386 #define Fxu_MatrixRingVarsStart( Matrix ) (((Matrix)->ppTailVars = &((Matrix)->pOrderVars)), ((Matrix)->pOrderVars = NULL))
388 #define Fxu_MatrixRingCubesStop( Matrix )
389 #define Fxu_MatrixRingVarsStop( Matrix )
391 #define Fxu_MatrixRingCubesReset( Matrix ) (((Matrix)->pOrderCubes = NULL), ((Matrix)->ppTailCubes = NULL))
392 #define Fxu_MatrixRingVarsReset( Matrix ) (((Matrix)->pOrderVars = NULL), ((Matrix)->ppTailVars = NULL))
394 #define Fxu_MatrixRingCubesAdd( Matrix, Cube) ((*((Matrix)->ppTailCubes) = Cube), ((Matrix)->ppTailCubes = &(Cube)->pOrder), ((Cube)->pOrder = (Fxu_Cube *)1))
395 #define Fxu_MatrixRingVarsAdd( Matrix, Var ) ((*((Matrix)->ppTailVars ) = Var ), ((Matrix)->ppTailVars = &(Var)->pOrder ), ((Var)->pOrder = (Fxu_Var *)1))
397 #define Fxu_MatrixForEachCubeInRing( Matrix, Cube )\
398 if ( (Matrix)->pOrderCubes )\
399 for ( Cube = (Matrix)->pOrderCubes;\
400 Cube != (Fxu_Cube *)1;\
401 Cube = Cube->pOrder )
402 #define Fxu_MatrixForEachCubeInRingSafe( Matrix, Cube, Cube2 )\
403 if ( (Matrix)->pOrderCubes )\
404 for ( Cube = (Matrix)->pOrderCubes, Cube2 = ((Cube != (Fxu_Cube *)1)? Cube->pOrder: (Fxu_Cube *)1);\
405 Cube != (Fxu_Cube *)1;\
406 Cube = Cube2, Cube2 = ((Cube != (Fxu_Cube *)1)? Cube->pOrder: (Fxu_Cube *)1) )
407 #define Fxu_MatrixForEachVarInRing( Matrix, Var )\
408 if ( (Matrix)->pOrderVars )\
409 for ( Var = (Matrix)->pOrderVars;\
410 Var != (Fxu_Var *)1;\
412 #define Fxu_MatrixForEachVarInRingSafe( Matrix, Var, Var2 )\
413 if ( (Matrix)->pOrderVars )\
414 for ( Var = (Matrix)->pOrderVars, Var2 = ((Var != (Fxu_Var *)1)? Var->pOrder: (Fxu_Var *)1);\
415 Var != (Fxu_Var *)1;\
416 Var = Var2, Var2 = ((Var != (Fxu_Var *)1)? Var->pOrder: (Fxu_Var *)1) )
425 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT
426 #define MEM_ALLOC_FXU( Manager, Type, Size ) ((Type *)ABC_ALLOC( char, (Size) * sizeof(Type) ))
427 #define MEM_FREE_FXU( Manager, Type, Size, Pointer ) if ( Pointer ) { ABC_FREE(Pointer); Pointer = NULL; }
429 #define MEM_ALLOC_FXU( Manager, Type, Size )\
430 ((Type *)Fxu_MemFetch( Manager, (Size) * sizeof(Type) ))
431 #define MEM_FREE_FXU( Manager, Type, Size, Pointer )\
432 if ( Pointer ) { Fxu_MemRecycle( Manager, (char *)(Pointer), (Size) * sizeof(Type) ); Pointer = NULL; }
void Fxu_ListVarDelLiteral(Fxu_Var *pVar, Fxu_Lit *pLit)
void Fxu_HeapDoubleCheck(Fxu_HeapDouble *p)
void Fxu_HeapSingleUpdate(Fxu_HeapSingle *p, Fxu_Single *pSingle)
void Fxu_HeapDoublePrint(FILE *pFile, Fxu_HeapDouble *p)
void Fxu_ListMatrixAddVariable(Fxu_Matrix *p, Fxu_Var *pVar)
DECLARATIONS ///.
void Fxu_MatrixPrintDivisorProfile(FILE *pFile, Fxu_Matrix *p)
int Fxu_PairCompare(Fxu_Pair *pPair1, Fxu_Pair *pPair2)
void Fxu_PairCanonicize(Fxu_Cube **ppCube1, Fxu_Cube **ppCube2)
FUNCTION DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Fxu_Matrix * Fxu_MatrixAllocate()
DECLARATIONS ///.
void Fxu_ListDoubleAddPairMiddle(Fxu_Double *pDiv, Fxu_Pair *pSpot, Fxu_Pair *pLink)
void Fxu_ListMatrixAddCube(Fxu_Matrix *p, Fxu_Cube *pCube)
void Fxu_ListTableDelDivisor(Fxu_Matrix *p, Fxu_Double *pDiv)
void Fxu_PairClearStorage(Fxu_Cube *pCube)
void Fxu_MatrixRingVarsUnmark(Fxu_Matrix *p)
void Fxu_HeapDoubleStop(Fxu_HeapDouble *p)
void Fxu_ListTableAddDivisor(Fxu_Matrix *p, Fxu_Double *pDiv)
void Fxu_MatrixAddDivisor(Fxu_Matrix *p, Fxu_Cube *pCube1, Fxu_Cube *pCube2)
void Fxu_Update(Fxu_Matrix *p, Fxu_Single *pSingle, Fxu_Double *pDouble)
FUNCTION DEFINITIONS ///.
void Fxu_MatrixRingCubesUnmark(Fxu_Matrix *p)
Fxu_Double * Fxu_HeapDoubleReadMax(Fxu_HeapDouble *p)
void Fxu_PairAllocStorage(Fxu_Var *pVar, int nCubes)
void Fxu_ListMatrixDelCube(Fxu_Matrix *p, Fxu_Cube *pCube)
void Fxu_HeapSingleStop(Fxu_HeapSingle *p)
void Fxu_HeapDoubleUpdate(Fxu_HeapDouble *p, Fxu_Double *pDiv)
void Fxu_HeapSinglePrint(FILE *pFile, Fxu_HeapSingle *p)
void Fxu_MatrixDelete(Fxu_Matrix *p)
void Fxu_ListVarAddLiteral(Fxu_Var *pVar, Fxu_Lit *pLit)
void Fxu_MatrixPrint(FILE *pFile, Fxu_Matrix *p)
DECLARATIONS ///.
void Fxu_ListCubeAddLiteral(Fxu_Cube *pCube, Fxu_Lit *pLit)
Fxu_HeapSingle * Fxu_HeapSingleStart()
FUNCTION DEFINITIONS ///.
Fxu_HeapDouble * Fxu_HeapDoubleStart()
FUNCTION DEFINITIONS ///.
void Fxu_MatrixComputeSingles(Fxu_Matrix *p, int fUse0, int nSingleMax)
FUNCTION DEFINITIONS ///.
unsigned Fxu_PairHashKeyMv(Fxu_Matrix *p, Fxu_Cube *pCube1, Fxu_Cube *pCube2, int *pnBase, int *pnLits1, int *pnLits2)
void Fxu_UpdateSingle(Fxu_Matrix *p)
void Fxu_HeapSingleInsert(Fxu_HeapSingle *p, Fxu_Single *pSingle)
void Fxu_ListCubeDelLiteral(Fxu_Cube *pCube, Fxu_Lit *pLit)
int Fxu_HeapSingleReadMaxWeight(Fxu_HeapSingle *p)
void Fxu_PairFreeStorage(Fxu_Var *pVar)
void Fxu_MatrixAddLiteral(Fxu_Matrix *p, Fxu_Cube *pCube, Fxu_Var *pVar)
void Fxu_HeapDoubleInsert(Fxu_HeapDouble *p, Fxu_Double *pDiv)
unsigned Fxu_PairHashKeyArray(Fxu_Matrix *p, int piVarsC1[], int piVarsC2[], int nVarsC1, int nVarsC2)
void Fxu_MatrixDelLiteral(Fxu_Matrix *p, Fxu_Lit *pLit)
unsigned Fxu_PairHashKey(Fxu_Matrix *p, Fxu_Cube *pCube1, Fxu_Cube *pCube2, int *pnBase, int *pnLits1, int *pnLits2)
void Fxu_HeapSingleCheck(Fxu_HeapSingle *p)
void Fxu_HeapSingleCheckOne(Fxu_HeapSingle *p, Fxu_Single *pSingle)
void Fxu_HeapDoubleCheckOne(Fxu_HeapDouble *p, Fxu_Double *pDiv)
void Fxu_ListMatrixAddSingle(Fxu_Matrix *p, Fxu_Single *pSingle)
Fxu_Cube * Fxu_MatrixAddCube(Fxu_Matrix *p, Fxu_Var *pVar, int iCube)
void Fxu_UpdateDouble(Fxu_Matrix *p)
Fxu_HeapSingle * pHeapSingle
void Fxu_MatrixDelDivisor(Fxu_Matrix *p, Fxu_Double *pDiv)
Fxu_HeapDouble * pHeapDouble
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
void Fxu_MatrixComputeSinglesOne(Fxu_Matrix *p, Fxu_Var *pVar)
int Fxu_SelectSCD(Fxu_Matrix *p, int Weight, Fxu_Var **ppVar1, Fxu_Var **ppVar2)
char * Fxu_MemFetch(Fxu_Matrix *p, int nBytes)
FUNCTION DEFINITIONS ///.
void Fxu_ListDoubleAddPairFirst(Fxu_Double *pDiv, Fxu_Pair *pLink)
void Fxu_MatrixAddSingle(Fxu_Matrix *p, Fxu_Var *pVar1, Fxu_Var *pVar2, int Weight)
#define ABC_NAMESPACE_HEADER_END
Fxu_Pair * Fxu_PairAlloc(Fxu_Matrix *p, Fxu_Cube *pCube1, Fxu_Cube *pCube2)
Extra_MmFixed_t * pMemMan
int Fxu_SingleCountCoincidence(Fxu_Matrix *p, Fxu_Var *pVar1, Fxu_Var *pVar2)
void Fxu_ListMatrixDelSingle(Fxu_Matrix *p, Fxu_Single *pSingle)
Fxu_Double * Fxu_HeapDoubleGetMax(Fxu_HeapDouble *p)
int Fxu_HeapDoubleReadMaxWeight(Fxu_HeapDouble *p)
void Fxu_PairAdd(Fxu_Pair *pPair)
void Fxu_MemRecycle(Fxu_Matrix *p, char *pItem, int nBytes)
void Fxu_HeapDoubleDelete(Fxu_HeapDouble *p, Fxu_Double *pDiv)
void Fxu_ListMatrixDelVariable(Fxu_Matrix *p, Fxu_Var *pVar)
Fxu_Single * Fxu_HeapSingleGetMax(Fxu_HeapSingle *p)
void Fxu_HeapSingleDelete(Fxu_HeapSingle *p, Fxu_Single *pSingle)
void Fxu_ListDoubleAddPairLast(Fxu_Double *pDiv, Fxu_Pair *pLink)
Fxu_Single * Fxu_HeapSingleReadMax(Fxu_HeapSingle *p)
typedefABC_NAMESPACE_HEADER_START struct FxuMatrix Fxu_Matrix
INCLUDES ///.
Fxu_Var * Fxu_MatrixAddVar(Fxu_Matrix *p)
void Fxu_ListDoubleDelPair(Fxu_Double *pDiv, Fxu_Pair *pPair)
int Fxu_Select(Fxu_Matrix *p, Fxu_Single **ppSingle, Fxu_Double **ppDouble)
FUNCTION DEFINITIONS ///.