abc/src/bool/kit/kitTruth.c
/**Function*************************************************************

  Synopsis    [Shrinks the truth table according to the phase.]

  Description [The input and output truth tables are in pIn/pOut. The current number
  of variables is nVars. The total number of variables in nVarsAll. The last argument
  (Phase) shows what variables should remain.]
               
  SideEffects [The input truth table is modified.]

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Shrinks the truth table according to the phase.]

Description [The input and output truth tables are in pIn/pOut. The current number
of variables is nVars. The total number of variables in nVarsAll. The last argument
(Phase) shows what variables should remain.]

SideEffects [The input truth table is modified.]


Function Synopsis [ Shrinks the truth table according to the phase . ] Description [ The input and output truth tables are in pIn / pOut . The current number of variables is nVars . The total number of variables in nVarsAll . The last argument ( Phase ) shows what variables should remain . ] SideEffects [ The input truth table is modified . ]
void Kit_TruthShrink( unsigned * pOut, unsigned * pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn )
{
    unsigned * pTemp;
    int i, k, Var = 0, Counter = 0;
    for ( i = 0; i < nVarsAll; i++ )
        if ( Phase & (1 << i) )
        {
            for ( k = i-1; k >= Var; k-- )
            {
                Kit_TruthSwapAdjacentVars( pOut, pIn, nVarsAll, k );
                pTemp = pIn; pIn = pOut; pOut = pTemp;
                Counter++;
            }
            Var++;
        }
    assert( Var == nVars );
    if ( fReturnIn ^ !(Counter & 1) )
        Kit_TruthCopy( pOut, pIn, nVarsAll );
}
void Kit_TruthShrink ( unsigned * pOut , unsigned * pIn , int nVars , int nVarsAll , unsigned Phase , int fReturnIn ) { unsigned * pTemp ; int i , k , Var = 0 , Counter = 0 ; for ( i = 0 ; i < nVarsAll ; i ++ ) if ( Phase & ( 1 << i ) ) { for ( k = i - 1 ; k >= Var ; k -- ) { Kit_TruthSwapAdjacentVars ( pOut , pIn , nVarsAll , k ) ; pTemp = pIn ; pIn = pOut ; pOut = pTemp ; Counter ++ ; } Var ++ ; } assert ( Var == nVars ) ; if ( fReturnIn ^ ! ( Counter & 1 ) ) Kit_TruthCopy ( pOut , pIn , nVarsAll ) ; }
Function
Synopsis    [Shrinks the truth table according to the phase.]
Function Synopsis [ Shrinks the truth table according to the phase . ]
// swap if it was moved an even number of times