45# define __builtin_popcount __popcnt
76void InsertVars(
Cube * pC,
int * pVars,
int nVarsIn,
int * pVarValues );
88static int SparseNumbers[163] = {
89 0,1,4,5,16,17,20,21,64,65,68,69,80,81,84,85,256,257,260,
90 261,272,273,276,277,320,321,324,325,336,337,340,1024,1025,
91 1028,1029,1040,1041,1044,1045,1088,1089,1092,1093,1104,1105,
92 1108,1280,1281,1284,1285,1296,1297,1300,1344,1345,1348,1360,
93 4096,4097,4100,4101,4112,4113,4116,4117,4160,4161,4164,4165,
94 4176,4177,4180,4352,4353,4356,4357,4368,4369,4372,4416,4417,
95 4420,4432,5120,5121,5124,5125,5136,5137,5140,5184,5185,5188,
96 5200,5376,5377,5380,5392,5440,16384,16385,16388,16389,16400,
97 16401,16404,16405,16448,16449,16452,16453,16464,16465,16468,
98 16640,16641,16644,16645,16656,16657,16660,16704,16705,16708,
99 16720,17408,17409,17412,17413,17424,17425,17428,17472,17473,
100 17476,17488,17664,17665,17668,17680,17728,20480,20481,20484,
101 20485,20496,20497,20500,20544,20545,20548,20560,20736,20737,
102 20740,20752,20800,21504,21505,21508,21520,21568,21760
105static unsigned char GroupLiterals[163][4] = {
106 {0}, {0}, {1}, {0,1}, {2}, {0,2}, {1,2}, {0,1,2}, {3}, {0,3},
107 {1,3}, {0,1,3}, {2,3}, {0,2,3}, {1,2,3}, {0,1,2,3}, {4}, {0,4},
108 {1,4}, {0,1,4}, {2,4}, {0,2,4}, {1,2,4}, {0,1,2,4}, {3,4},
109 {0,3,4}, {1,3,4}, {0,1,3,4}, {2,3,4}, {0,2,3,4}, {1,2,3,4}, {5},
110 {0,5}, {1,5}, {0,1,5}, {2,5}, {0,2,5}, {1,2,5}, {0,1,2,5}, {3,5},
111 {0,3,5}, {1,3,5}, {0,1,3,5}, {2,3,5}, {0,2,3,5}, {1,2,3,5},
112 {4,5}, {0,4,5}, {1,4,5}, {0,1,4,5}, {2,4,5}, {0,2,4,5},
113 {1,2,4,5}, {3,4,5}, {0,3,4,5}, {1,3,4,5}, {2,3,4,5}, {6}, {0,6},
114 {1,6}, {0,1,6}, {2,6}, {0,2,6}, {1,2,6}, {0,1,2,6}, {3,6},
115 {0,3,6}, {1,3,6}, {0,1,3,6}, {2,3,6}, {0,2,3,6}, {1,2,3,6},
116 {4,6}, {0,4,6}, {1,4,6}, {0,1,4,6}, {2,4,6}, {0,2,4,6},
117 {1,2,4,6}, {3,4,6}, {0,3,4,6}, {1,3,4,6}, {2,3,4,6}, {5,6},
118 {0,5,6}, {1,5,6}, {0,1,5,6}, {2,5,6}, {0,2,5,6}, {1,2,5,6},
119 {3,5,6}, {0,3,5,6}, {1,3,5,6}, {2,3,5,6}, {4,5,6}, {0,4,5,6},
120 {1,4,5,6}, {2,4,5,6}, {3,4,5,6}, {7}, {0,7}, {1,7}, {0,1,7},
121 {2,7}, {0,2,7}, {1,2,7}, {0,1,2,7}, {3,7}, {0,3,7}, {1,3,7},
122 {0,1,3,7}, {2,3,7}, {0,2,3,7}, {1,2,3,7}, {4,7}, {0,4,7},
123 {1,4,7}, {0,1,4,7}, {2,4,7}, {0,2,4,7}, {1,2,4,7}, {3,4,7},
124 {0,3,4,7}, {1,3,4,7}, {2,3,4,7}, {5,7}, {0,5,7}, {1,5,7},
125 {0,1,5,7}, {2,5,7}, {0,2,5,7}, {1,2,5,7}, {3,5,7}, {0,3,5,7},
126 {1,3,5,7}, {2,3,5,7}, {4,5,7}, {0,4,5,7}, {1,4,5,7}, {2,4,5,7},
127 {3,4,5,7}, {6,7}, {0,6,7}, {1,6,7}, {0,1,6,7}, {2,6,7},
128 {0,2,6,7}, {1,2,6,7}, {3,6,7}, {0,3,6,7}, {1,3,6,7}, {2,3,6,7},
129 {4,6,7}, {0,4,6,7}, {1,4,6,7}, {2,4,6,7}, {3,4,6,7}, {5,6,7},
130 {0,5,6,7}, {1,5,6,7}, {2,5,6,7}, {3,5,6,7}, {4,5,6,7}
134#define FULL16BITS 0x10000
135#define MARKNUMBER 200
137static unsigned char BitGroupNumbers[
FULL16BITS];
152 for ( i = 0; i < nLimit; i++ )
154 BitCount[i] = __builtin_popcount( i & 0xffff );
158 for ( k = 0; k < 163; k++ )
159 BitGroupNumbers[ SparseNumbers[k] ] = k;
192 int Value = ((pC->
pCubeDataIn[VarWord(Bit)] >> VarBit(Bit)) & 3);
202 pC->
pCubeDataIn[VarWord(Bit)] ^= ( Val << VarBit(Bit) );
209static int DiffVarCounter, cVars;
210static drow Temp1, Temp2, Temp;
211static drow LastNonZeroWord;
212static int LastNonZeroWordNum;
226 DiffVarCounter += BIT_COUNT(Temp2);
227 if ( DiffVarCounter > 4 )
237 return DiffVarCounter;
253 LastNonZeroWordNum = -1;
263 LastNonZeroWordNum = i;
264 LastNonZeroWord = Temp2;
268 DiffVarCounter += BIT_COUNT(Temp2);
269 if ( DiffVarCounter > 4 )
280 if ( DiffVarCounter == 1 )
282 if ( LastNonZeroWordNum == -1 )
286 Temp = (LastNonZeroWord>>2);
287 for ( i = 0; Temp; Temp>>=2, i++ );
301 return DiffVarCounter;
329 Temp = Temp2 & 0xffff;
334 for ( v = 0; v < cVars; v++ )
337 pDiffVars[ DiffVarCounter++ ] = i*16 + GroupLiterals[ BitGroupNumbers[Temp] ][v];
342 if ( DiffVarCounter > 4 )
351 for ( v = 0; v < cVars; v++ )
354 pDiffVars[ DiffVarCounter++ ] = i*16 + 8 + GroupLiterals[ BitGroupNumbers[Temp] ][v];
359 if ( DiffVarCounter > 4 )
362 return DiffVarCounter;
375 for ( i = 0; i < nVarsIn; i++ )
379 GlobalBit = (pVars[i]<<1);
380 LocalWord = VarWord(GlobalBit);
381 LocalBit = VarBit(GlobalBit);
398 for ( i = 0; i < nVarsIn; i++ )
402 GlobalBit = (pVars[i]<<1);
403 LocalWord = VarWord(GlobalBit);
404 LocalBit = VarBit(GlobalBit);
407 pC->
pCubeDataIn[LocalWord] |= ( pVarValues[i] << LocalBit );
410 pC->
pCubeDataOut[VarWord(Output)] |= ( 1 << VarBit(Output) );
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
int FindDiffVars(int *pDiffVars, Cube *pC1, Cube *pC2)
void PrepareBitSetModule()
FUNCTION DEFINITIONS ///.
void InsertVars(Cube *pC, int *pVars, int nVarsIn, int *pVarValues)
void InsertVarsWithoutClearing(Cube *pC, int *pVars, int nVarsIn, int *pVarValues, int Output)
varvalue GetVar(Cube *pC, int Var)
INLINE FUNCTION DEFINITIONS ///.
void ExorVar(Cube *pC, int Var, varvalue Val)
int GetDistance(Cube *pC1, Cube *pC2)
FUNCTIONS OF THIS MODULE ///.
int GetDistancePlus(Cube *pC1, Cube *pC2)
ABC_NAMESPACE_IMPL_START cinfo g_CoverInfo
GLOBAL VARIABLES ///.
varvalue
VARVALUE and CUBEDIST enum typedefs ///.