40 x = x - ((x >> 1) &
ABC_CONST(0x5555555555555555));
42 x = (x + (x >> 4)) &
ABC_CONST(0x0F0F0F0F0F0F0F0F);
46 return (
int)(x & 0xFF);
61 memset( pStore, 0,
sizeof(
int) * nVars );
80 for ( k = 0; k <
nWords; k++ )
83 for ( i = 6; i < nVars; i++ )
84 if ( (k & (1 << (i-6))) == 0)
88 for ( k = nWords/2; k>0; k-- )
103 int i, Step,SizeOfBlock;
109 for ( i = 0; i <
nWords; i++ )
110 pInOut[i] = ((pInOut[i] &
mask0[iVar]) << (1<<(iVar))) | ((pInOut[i] & ~
mask0[iVar]) >> (1<<(iVar)));
114 Step = (1 << (iVar - 6));
115 SizeOfBlock =
sizeof(
word)*Step;
116 for ( i = 0; i <
nWords; i += 2*Step )
118 memcpy(Temp,pInOut,SizeOfBlock);
119 memcpy(pInOut,pInOut+Step,SizeOfBlock);
120 memcpy(pInOut+Step,Temp,SizeOfBlock);
143 int i, Step, Shift, SizeOfBlock;
154 assert( iVar < nVars - 1 );
158 for ( i = 0; i <
nWords; i++ )
159 pInOut[i] = (pInOut[i] & PMasks[iVar][0]) | ((pInOut[i] & PMasks[iVar][1]) << Shift) | ((pInOut[i] & PMasks[iVar][2]) >> Shift);
163 Step = 1 << (iVar - 6);
164 SizeOfBlock =
sizeof(
word)*Step;
166 for(i=2*Step; i<
nWords; i+=4*Step)
168 memcpy(temp,pInOut-Step,SizeOfBlock);
169 memcpy(pInOut-Step,pInOut,SizeOfBlock);
170 memcpy(pInOut,temp,SizeOfBlock);
176 for ( i = 0; i <
nWords; i += 2 )
178 temp[0] = pInOut[i+1] << 32;
179 pInOut[i+1] ^= (temp[0] ^ pInOut[i]) >> 32;
180 pInOut[i] = (pInOut[i] & 0x00000000FFFFFFFF) | temp[0];
190 int i, Temp, fChange, nOnes;
191 unsigned uCanonPhase=0;
196 if ( (nOnes > nWords * 32) )
198 uCanonPhase |= (1 << nVars);
200 nOnes = nWords*64 - nOnes;
207 for ( i = 0; i < nVars; i++ )
209 if ( pStore[i] >= nOnes-pStore[i])
211 uCanonPhase |= (1 << i);
212 pStore[i] = nOnes-pStore[i];
218 for ( i = 0; i < nVars-1; i++ )
220 if ( pStore[i] <= pStore[i+1] )
224 Temp = pCanonPerm[i];
225 pCanonPerm[i] = pCanonPerm[i+1];
226 pCanonPerm[i+1] = Temp;
229 pStore[i] = pStore[i+1];
233 if ( ((uCanonPhase & (1 << i)) > 0) != ((uCanonPhase & (1 << (i+1))) > 0) )
235 uCanonPhase ^= (1 << i);
236 uCanonPhase ^= (1 << (i+1));
248 int i, fChange, nOnes;
250 unsigned uCanonPhase=0;
254 if ( nOnes == nWords * 32 )
255 uCanonPhase |= (1 << (nVars+2));
257 else if ( (nOnes > nWords * 32) )
259 uCanonPhase |= (1 << nVars);
261 nOnes = nWords*64 - nOnes;
268 for ( i = 0; i < nVars; i++ )
270 if ( 2*pStore[i] == nOnes)
272 uCanonPhase |= (1 << (nVars+1));
275 if ( pStore[i] > nOnes-pStore[i])
277 uCanonPhase |= (1 << i);
278 pStore[i] = nOnes-pStore[i];
284 for ( i = 0; i < nVars-1; i++ )
286 if ( pStore[i] <= pStore[i+1] )
290 Temp = pCanonPerm[i];
291 pCanonPerm[i] = pCanonPerm[i+1];
292 pCanonPerm[i+1] = Temp;
295 pStore[i] = pStore[i+1];
299 if ( ((uCanonPhase & (1 << i)) > 0) != ((uCanonPhase & (1 << (i+1))) > 0) )
301 uCanonPhase ^= (1 << i);
302 uCanonPhase ^= (1 << (i+1));
361 int i, Temp, fChange, nOnes;
366 if ( (nOnes > nWords * 32) )
369 nOnes = nWords*64 - nOnes;
376 for ( i = 0; i < nVars; i++ )
378 if ( pStore[i] >= nOnes-pStore[i])
380 pStore[i] = nOnes-pStore[i];
386 for ( i = 0; i < nVars-1; i++ )
388 if ( pStore[i] <= pStore[i+1] )
393 pStore[i] = pStore[i+1];
int Kit_WordCountOnes_64bit(word x)
static ABC_NAMESPACE_IMPL_START word mask0[6]
void Kit_TruthCopy_64bit(word *pOut, word *pIn, int nVars)
unsigned Kit_TruthSemiCanonicize_Yasha(word *pInOut, int nVars, char *pCanonPerm)
int Kit_TruthWordNum_64bit(int nVars)
int Kit_TruthCountOnes_64bit(word *pIn, int nVars)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
void Kit_TruthSwapAdjacentVars_64bit(word *pInOut, int nVars, int iVar)
void Kit_TruthNot_64bit(word *pIn, int nVars)
#define ABC_NAMESPACE_IMPL_START
unsigned Kit_TruthSemiCanonicize_Yasha1(word *pInOut, int nVars, char *pCanonPerm, int *pStore)
#define ABC_CONST(number)
PARAMETERS ///.
void Kit_TruthSemiCanonicize_Yasha_simple(word *pInOut, int nVars, int *pStore)
void Kit_TruthCountOnesInCofs_64bit(word *pTruth, int nVars, int *pStore)
void Kit_TruthChangePhase_64bit(word *pInOut, int nVars, int iVar)