50 assert( nCols > 0 && nRows > 0 && Size > 0 );
51 pBuffer =
ABC_ALLOC(
char, nCols * (
sizeof(
void *) + nRows * Size) );
52 pRes = (
char **)pBuffer;
53 pRes[0] = pBuffer + nCols *
sizeof(
void *);
54 for ( i = 1; i < nCols; i++ )
55 pRes[i] = pRes[0] + i * nRows * Size;
73 for ( i = 1; i <= n; i++ )
93 int iTemp, iCur, iLast, k;
97 pRes[0][0] = Array[0];
102 nFactNext = nFact / n;
106 for ( iCur = 0; iCur < n; iCur++ )
110 Array[iCur] = Array[iLast];
111 Array[iLast] = iTemp;
114 pNext = pRes + (n - 1 - iCur) * nFactNext;
117 for ( k = 0; k < nFactNext; k++ )
118 pNext[k][iLast] = Array[iLast];
125 Array[iCur] = Array[iLast];
126 Array[iLast] = iTemp;
153 for ( i = 0; i < n; i++ )
187 memset( pMintsP, 0,
sizeof(
int) * nMints );
189 for ( m = 0; m < nMints; m++ )
190 for ( v = 0; v < nVars; v++ )
191 if ( pMints[m] & (1 << v) )
192 pMintsP[m] |= (1 << pPerm[v]);
215 nMints = (1 << nVars);
218 for ( i = 0; i < nMints; i++ )
226 for ( m = 0; m < nMints; m++ )
227 if ( Truth & (1 << pMintsP[m]) )
232 for ( m = 0; m < nMints; m++ )
233 if ( Truth & (1 << m) )
234 Result |= (1 << pMintsP[m]);
257 static unsigned Signs[5] = {
264 unsigned uTruthRes, uCof0, uCof1;
265 int nMints, Shift, v;
267 nMints = (1 << nVars);
269 for ( v = 0; v < nVars; v++ )
270 if ( Polarity & (1 << v) )
272 uCof0 = uTruth & ~Signs[v];
273 uCof1 = uTruth & Signs[v];
277 uTruth = uCof0 | uCof1;
293 void Dar_Truth4VarNPN(
unsigned short ** puCanons,
char ** puPhases,
char ** puPerms,
unsigned char ** puMap )
295 unsigned short * uCanons;
296 unsigned char * uMap;
297 unsigned uTruth, uPhase, uPerm;
298 char ** pPerms4, * uPhases, * uPerms;
299 int nFuncs, nClasses;
303 uCanons =
ABC_CALLOC(
unsigned short, nFuncs );
311 for ( uTruth = 1; uTruth < (unsigned)nFuncs; uTruth++ )
314 if ( uCanons[uTruth] )
316 assert( uTruth > uCanons[uTruth] );
317 uMap[~uTruth & 0xFFFF] = uMap[uTruth] = uMap[uCanons[uTruth]];
320 uMap[uTruth] = nClasses++;
321 for ( i = 0; i < 16; i++ )
324 for ( k = 0; k < 24; k++ )
327 if ( uCanons[uPerm] == 0 )
329 uCanons[uPerm] = uTruth;
332 uMap[uPerm] = uMap[uTruth];
334 uPerm = ~uPerm & 0xFFFF;
335 uCanons[uPerm] = uTruth;
336 uPhases[uPerm] = i | 16;
338 uMap[uPerm] = uMap[uTruth];
341 assert( uCanons[uPerm] == uTruth );
344 for ( k = 0; k < 24; k++ )
347 if ( uCanons[uPerm] == 0 )
349 uCanons[uPerm] = uTruth;
352 uMap[uPerm] = uMap[uTruth];
354 uPerm = ~uPerm & 0xFFFF;
355 uCanons[uPerm] = uTruth;
356 uPhases[uPerm] = i | 16;
358 uMap[uPerm] = uMap[uTruth];
361 assert( uCanons[uPerm] == uTruth );
365 for ( uTruth = 1; uTruth < 0xffff; uTruth++ )
366 assert( uMap[uTruth] != 0 );
367 uPhases[(1<<16)-1] = 16;
368 assert( nClasses == 222 );
ABC_NAMESPACE_IMPL_START char ** Dar_ArrayAlloc(int nCols, int nRows, int Size)
DECLARATIONS ///.
#define ABC_ALLOC(type, num)
unsigned Dar_TruthPolarize(unsigned uTruth, int Polarity, int nVars)
void Dar_Permutations_rec(char **pRes, int nFact, int n, char Array[])
unsigned Dar_TruthPermute(unsigned Truth, char *pPerms, int nVars, int fReverse)
#define ABC_NAMESPACE_IMPL_END
#define ABC_NAMESPACE_IMPL_START
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
void Dar_Truth4VarNPN(unsigned short **puCanons, char **puPhases, char **puPerms, unsigned char **puMap)
#define ABC_CALLOC(type, num)
char ** Dar_Permutations(int n)
void Dar_TruthPermute_int(int *pMints, int nMints, char *pPerm, int nVars, int *pMintsP)