abc/src/bool/lucky/lucky.c
// compare F with  F1 = (F with swapped two adjacent vars).
// keeps smaller.
// same for all vars in F.
// returns: if pInOnt changed(minimized) by function return 1 if not 0
compare F with  F1 = (F with swapped two adjacent vars).
keeps smaller.
same for all vars in F.
returns: if pInOnt changed(minimized) by function return 1 if not 0
compare F with F1 = ( F with swapped two adjacent vars ) . keeps smaller . same for all vars in F . returns : if pInOnt changed ( minimized ) by function return 1 if not 0
int minimalSwap1(word* pInOut, word* pMinimal, word* PDuplicat, int  nVars) 
{
    int i;
    int blockSize = Kit_TruthWordNum_64bit( nVars )*sizeof(word);
    memcpy(pMinimal, pInOut, blockSize);
    memcpy(PDuplicat, pInOut, blockSize);
    Kit_TruthSwapAdjacentVars_64bit( pInOut, nVars, 0 );
    for(i=1;i<nVars-1;i++)
    {
        if( memCompare(pMinimal,pInOut,nVars) == 1)
        {
            memcpy(pMinimal, pInOut, blockSize);
            Kit_TruthSwapAdjacentVars_64bit( pInOut, nVars, i );
        }
        else
        {
            memcpy(pInOut, pMinimal, blockSize);
            Kit_TruthSwapAdjacentVars_64bit( pInOut, nVars, i );
        }
    }
    if( memCompare(pMinimal,pInOut,nVars) == -1)
        memcpy(pInOut, pMinimal, blockSize);
    if(memcmp(pInOut,PDuplicat,blockSize) == 0)
        return 0;
    else
        return 1;
}
int minimalSwap1 ( word * pInOut , word * pMinimal , word * PDuplicat , int nVars ) { int i ; int blockSize = Kit_TruthWordNum_64bit ( nVars ) * sizeof ( word ) ; memcpy ( pMinimal , pInOut , blockSize ) ; memcpy ( PDuplicat , pInOut , blockSize ) ; Kit_TruthSwapAdjacentVars_64bit ( pInOut , nVars , 0 ) ; for ( i = 1 ; i < nVars - 1 ; i ++ ) { if ( memCompare ( pMinimal , pInOut , nVars ) == 1 ) { memcpy ( pMinimal , pInOut , blockSize ) ; Kit_TruthSwapAdjacentVars_64bit ( pInOut , nVars , i ) ; } else { memcpy ( pInOut , pMinimal , blockSize ) ; Kit_TruthSwapAdjacentVars_64bit ( pInOut , nVars , i ) ; } } if ( memCompare ( pMinimal , pInOut , nVars ) == -1 ) memcpy ( pInOut , pMinimal , blockSize ) ; if ( memcmp ( pInOut , PDuplicat , blockSize ) == 0 ) return 0 ; else return 1 ; }
compare F with  F1 = (F with swapped two adjacent vars).
compare F with F1 = ( F with swapped two adjacent vars ) .