Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
d01c0807
Commit
d01c0807
authored
Aug 08, 2012
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New semi-canonical form computation package.
parent
bf35ed1b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
0 deletions
+94
-0
src/bool/lucky/lucky.c
+94
-0
No files found.
src/bool/lucky/lucky.c
View file @
d01c0807
...
@@ -431,6 +431,10 @@ inline void swapInfoAdjacentVars(int iVar, char * pCanonPerm, unsigned* p_uCanon
...
@@ -431,6 +431,10 @@ inline void swapInfoAdjacentVars(int iVar, char * pCanonPerm, unsigned* p_uCanon
// keeps smaller.
// keeps smaller.
// same for all vars in F.
// same for all vars in F.
// returns: if pInOnt changed(minimized) by function return 1 if not 0
// returns: if pInOnt changed(minimized) by function return 1 if not 0
/*
// this version is buggy and is fixed below
inline int minimalSwap(word* pInOut, word* pMinimal, word* PDuplicat, int nVars, char * pCanonPerm, char * tempArray, unsigned* p_uCanonPhase)
inline int minimalSwap(word* pInOut, word* pMinimal, word* PDuplicat, int nVars, char * pCanonPerm, char * tempArray, unsigned* p_uCanonPhase)
{
{
int i;
int i;
...
@@ -466,6 +470,96 @@ inline int minimalSwap(word* pInOut, word* pMinimal, word* PDuplicat, int nVars
...
@@ -466,6 +470,96 @@ inline int minimalSwap(word* pInOut, word* pMinimal, word* PDuplicat, int nVars
else
else
return 1;
return 1;
}
}
*/
inline
int
minimalSwap
(
word
*
pInOut
,
word
*
pMinimal
,
word
*
PDuplicat
,
int
nVars
,
char
*
pCanonPerm
,
char
*
tempArray
,
unsigned
*
p_uCanonPhase
)
{
int
i
;
int
blockSizeWord
=
Kit_TruthWordNum_64bit
(
nVars
)
*
sizeof
(
word
);
int
blockSizeChar
=
nVars
*
sizeof
(
char
);
unsigned
TempuCanonPhase
=
*
p_uCanonPhase
;
memcpy
(
pMinimal
,
pInOut
,
blockSizeWord
);
memcpy
(
PDuplicat
,
pInOut
,
blockSizeWord
);
memcpy
(
tempArray
,
pCanonPerm
,
blockSizeChar
);
Kit_TruthSwapAdjacentVars_64bit
(
pInOut
,
nVars
,
0
);
swapInfoAdjacentVars
(
0
,
pCanonPerm
,
p_uCanonPhase
);
for
(
i
=
1
;
i
<
nVars
-
1
;
i
++
)
{
if
(
memCompare
(
pMinimal
,
pInOut
,
nVars
)
==
1
)
{
memcpy
(
pMinimal
,
pInOut
,
blockSizeWord
);
memcpy
(
tempArray
,
pCanonPerm
,
blockSizeChar
);
TempuCanonPhase
=
*
p_uCanonPhase
;
}
else
{
memcpy
(
pInOut
,
pMinimal
,
blockSizeWord
);
memcpy
(
pCanonPerm
,
tempArray
,
blockSizeChar
);
*
p_uCanonPhase
=
TempuCanonPhase
;
}
Kit_TruthSwapAdjacentVars_64bit
(
pInOut
,
nVars
,
i
);
swapInfoAdjacentVars
(
i
,
pCanonPerm
,
p_uCanonPhase
);
}
if
(
memCompare
(
pMinimal
,
pInOut
,
nVars
)
==
-
1
)
{
memcpy
(
pInOut
,
pMinimal
,
blockSizeWord
);
memcpy
(
pCanonPerm
,
tempArray
,
blockSizeChar
);
*
p_uCanonPhase
=
TempuCanonPhase
;
}
if
(
memcmp
(
pInOut
,
PDuplicat
,
blockSizeWord
)
==
0
)
return
0
;
else
return
1
;
}
//////////////// functions below just for Alan if he want to double check my program//////////////////////////////////
/////////////////You need swap_ij function or analogical one//////////////////////////////////////////////////////////
/*
void swapAndFlip(word* pAfter, int nVars, int iVarInPosition, int jVar, char * pCanonPerm, unsigned* pUCanonPhase)
{
int Temp;
swap_ij(pAfter, nVars, iVarInPosition, jVar);
Temp = pCanonPerm[iVarInPosition];
pCanonPerm[iVarInPosition] = pCanonPerm[jVar];
pCanonPerm[jVar] = Temp;
if ( ((*pUCanonPhase & (1 << iVarInPosition)) > 0) != ((*pUCanonPhase & (1 << jVar)) > 0) )
{
*pUCanonPhase ^= (1 << iVarInPosition);
*pUCanonPhase ^= (1 << jVar);
}
if(*pUCanonPhase>>iVarInPosition & (unsigned)1 == 1)
Kit_TruthChangePhase_64bit( pAfter, nVars, iVarInPosition );
}
int luckyCheck(word* pAfter, word* pBefore, int nVars, char * pCanonPerm, unsigned uCanonPhase)
{
int i,j;
char tempChar;
for(j=0;j<nVars;j++)
{
tempChar = 'a'+ j;
for(i=j;i<nVars;i++)
{
if(tempChar != pCanonPerm[i])
continue;
swapAndFlip(pAfter , nVars, j, i, pCanonPerm, &uCanonPhase);
break;
}
}
if(uCanonPhase>>nVars & (unsigned)1 == 1)
Kit_TruthNot_64bit(pAfter, nVars );
if(memcmp(pAfter, pBefore, Kit_TruthWordNum_64bit( nVars )*sizeof(word)) == 0)
return 0;
else
return 1;
}
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline
void
luckyCanonicizer
(
word
*
pInOut
,
word
*
pAux
,
word
*
pAux1
,
int
nVars
,
char
*
pCanonPerm
,
char
*
tempArray
,
unsigned
*
p_uCanonPhase
)
inline
void
luckyCanonicizer
(
word
*
pInOut
,
word
*
pAux
,
word
*
pAux1
,
int
nVars
,
char
*
pCanonPerm
,
char
*
tempArray
,
unsigned
*
p_uCanonPhase
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment