35 static inline void Abc_StatePerm(
char * pState,
char *
pPerm,
char * pRes ) {
int i;
for ( i = 0; i < 24; i++ ) pRes[i] = pState[(
int)pPerm[i]]; }
36 static inline void Abc_StatePrint(
char * pState ) {
int i;
for ( i = 0; i < 24; i++ ) printf(
" %2d", pState[i]); printf(
"\n" ); }
56 { {3, 5}, {3,17}, {3,15}, {1, 6}, {1,16}, {1,14}, {2, 4}, {2,18}, {2,13} },
57 { {2,14}, {2,24}, {2,12}, {3,13}, {3,23}, {3,10}, {1,15}, {1,22}, {1,11} },
58 { {1,10}, {1, 7}, {1, 4}, {3,12}, {3, 9}, {3, 6}, {2,11}, {2, 8}, {2, 5} } };
62 int i, k, v, RetValue, Beg, End,
Counter = 0;
63 char pStart[24], pFirst[9][24];
65 printf(
"Enumerating states of 2x2x2 cube.\n" );
67 for ( v = 0; v < 24; v++ )
71 assert( RetValue == Counter );
74 for ( i = 0; i < 3; i++ )
76 memcpy( pFirst[i], pStart, 24 );
77 for ( v = 0; v < 9; v++ )
78 ABC_SWAP(
char, pFirst[i][pXYZ[i][v][0]-1], pFirst[i][pXYZ[i][v][1]-1] );
81 assert( RetValue == Counter );
85 memcpy( pFirst[3+i], pFirst[i], 24 );
86 for ( v = 0; v < 9; v++ )
87 ABC_SWAP(
char, pFirst[3+i][pXYZ[i][v][0]-1], pFirst[3+i][pXYZ[i][v][1]-1] );
90 assert( RetValue == Counter );
94 memcpy( pFirst[6+i], pFirst[3+i], 24 );
95 for ( v = 0; v < 9; v++ )
96 ABC_SWAP(
char, pFirst[6+i][pXYZ[i][v][0]-1], pFirst[6+i][pXYZ[i][v][1]-1] );
99 assert( RetValue == Counter );
103 printf(
"Iter %2d -> %8d ", 0, 1 );
105 printf(
"Iter %2d -> %8d ", 1, Counter );
108 for ( i = 2; i <= 100; i++ )
112 for ( k = Beg; k < End; k++ )
113 for ( v = 0; v < 9; v++ )
117 if ( RetValue == Counter )
119 if ( Counter == (1<<22) )
121 printf(
"Did not converge. " );
127 printf(
"Iter %2d -> %8d ", i, Counter );
168 static int Var2Cor[24] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, -1, -1, -1, 6, 6, 6 };
169 static int Var2Per[24] = { 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, -1, -1, -1, 0, 1, 2 };
171 Res =
Abc_DataXorCube( Res, 0, (Var2Cor[(
int)pState[ 0]] << 2) | Var2Per[(
int)pState[ 0]] );
172 Res =
Abc_DataXorCube( Res, 1, (Var2Cor[(
int)pState[ 3]] << 2) | Var2Per[(
int)pState[ 3]] );
173 Res =
Abc_DataXorCube( Res, 2, (Var2Cor[(
int)pState[ 6]] << 2) | Var2Per[(
int)pState[ 6]] );
174 Res =
Abc_DataXorCube( Res, 3, (Var2Cor[(
int)pState[ 9]] << 2) | Var2Per[(
int)pState[ 9]] );
175 Res =
Abc_DataXorCube( Res, 4, (Var2Cor[(
int)pState[12]] << 2) | Var2Per[(
int)pState[12]] );
176 Res =
Abc_DataXorCube( Res, 5, (Var2Cor[(
int)pState[15]] << 2) | Var2Per[(
int)pState[15]] );
177 Res =
Abc_DataXorCube( Res, 6, (Var2Cor[(
int)pState[21]] << 2) | Var2Per[(
int)pState[21]] );
194 int pXYZ[3][9][2] = {
195 { {3, 5}, {3,17}, {3,15}, {1, 6}, {1,16}, {1,14}, {2, 4}, {2,18}, {2,13} },
196 { {2,14}, {2,24}, {2,12}, {3,13}, {3,23}, {3,10}, {1,15}, {1,22}, {1,11} },
197 { {1,10}, {1, 7}, {1, 4}, {3,12}, {3, 9}, {3, 6}, {2,11}, {2, 8}, {2, 5} } };
201 int i, k, v, Beg, End,
Counter = 0;
202 char * pPrev, * pState, pStart[24], pFirst[9][24];
204 printf(
"Enumerating states of 2x2x2 cube.\n" );
206 for ( v = 0; v < 24; v++ )
212 for ( i = 0; i < 3; i++ )
214 memcpy( pFirst[i], pStart, 24 );
215 for ( v = 0; v < 9; v++ )
216 ABC_SWAP(
char, pFirst[i][pXYZ[i][v][0]-1], pFirst[i][pXYZ[i][v][1]-1] );
222 memcpy( pFirst[3+i], pFirst[i], 24 );
223 for ( v = 0; v < 9; v++ )
224 ABC_SWAP(
char, pFirst[3+i][pXYZ[i][v][0]-1], pFirst[3+i][pXYZ[i][v][1]-1] );
230 memcpy( pFirst[6+i], pFirst[3+i], 24 );
231 for ( v = 0; v < 9; v++ )
232 ABC_SWAP(
char, pFirst[6+i][pXYZ[i][v][0]-1], pFirst[6+i][pXYZ[i][v][1]-1] );
238 printf(
"Iter %2d -> %8d ", 0, 1 );
240 printf(
"Iter %2d -> %8d ", 1, Counter );
243 for ( i = 2; i <= 100; i++ )
247 for ( k = Beg; k < End; k++ )
250 for ( v = 0; v < 9; v++ )
257 if ( Counter == (1<<22) )
259 printf(
"Did not converge. " );
266 printf(
"Iter %2d -> %8d ", i, Counter );
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static abctime Abc_Clock()
#define ABC_SWAP(Type, a, b)
static void Abc_PrintTime(int level, const char *pStr, abctime time)
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
static Vec_Int_t * Vec_IntStart(int nSize)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
static void Hsh_IntManStop(Hsh_IntMan_t *p)
#define ABC_NAMESPACE_IMPL_START
static int Hsh_IntManAdd(Hsh_IntMan_t *p, int iData)
#define ABC_CALLOC(type, num)
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
static void Vec_IntFree(Vec_Int_t *p)
static Hsh_IntMan_t * Hsh_IntManStart(Vec_Int_t *vData, int nSize, int nEntries)
FUNCTION DEFINITIONS ///.