/* CountDelta.cpp This programme enumerates labelled delta-matroids of size <= cSizeMax <= 5. It is assumed that the unsigned int type can hold 32 bit positive integers. The lines sprintf(cFilename[i][0],"C://Users//steven//Documents//deltamatroids//alldelta%d.txt",i); sprintf(cFilename[i][1],"C://Users//steven//Documents//deltamatroids//isodetails%d.txt",i); should be amended to reflect where the lists of all delta-matroids and delta-matroids up to equivalence are to be stored. The parameter cSizeMax in line 8 can be changed to anything up to 5, but as the program runs in a few seconds, it is not really worth changing. To simplify certain parts of the coding, the numbers of labelled delta-matroids and inequivalent delta-matroids up to isomorphism and twists is hard-coded. When the program has computed all the delta-matroids of a particular size it checks that the number found tallies with the values hard-coded into the program. The program counts the number of delta-matroids with element set {1,...,n} by considering all pairs (D,D') comprising delta-matroids with element set {1,...,n-1}. It checks to see whether the set system D'' defined so that D''//{n}=D and D''\\{n}=D' is a delta-matroid. A set system is a delta-matroid if and only if all single element minors are delta-matroids and every pair of antipodal feasible sets satisfies the symmetric exchange axiom. When n>4, a set system D is a delta-matroid if and only if all single element minors are delta-matroids and D does not comprise two antipodal feasible sets. Within the program and in the output, a delta-matroid is represented by an integer. Suppose that this integer is expressed in binary as a_k...a_0. The bit a_j records the feasibility of the jth subset of {1,...,i} in the colex ordering. For example when i=3, each delta-matroid is recorded as an integer between 0 and 255. If D is the delta-matroid recorded as the integer with binary expansion a_7...a_0 then a_0 denotes the feasibility of the empty set. a_1 denotes the feasibility of {1}. a_2 denotes the feasibility of {2}. a_3 denotes the feasibility of {1,2}. a_4 denotes the feasibility of {3}. a_5 denotes the feasibility of {1,3}. a_6 denotes the feasibility of {2,3}. a_7 denotes the feasibility of {1,2,3}. The output of the program is as follows. C://Users//steven//Documents//deltamatroids//alldeltai.txt contains a line for each labelled delta-matroid with elements {1,...,i}. Each line contains the integer representation of a labelled delta-matroid and the integer representation of its minimal equivalent delta-matroid under isomorphism and twists. C://Users//steven//Documents//deltamatroids//isodetailsi.txt contains a line for each labelled delta-matroid with elements {1,...,i} that has the smallest integer representation in its equivalence class under isomorphism and twists. Each line contains the integer representation of a labelled delta-matroid and the number of labelled delta-matroids to which it is equivalent under isomorphism and twists. */ #include #include #include #include using namespace std; const char cSizeMax = 5; const int nMax[] = {2,4,16,256,65536}; const int nTwoton[] = {1,2,4,8,16,32}; const char cTwoton[] = {1,2,4,8,16,32}; const int nFact[] = {1,1,2,6,24,120}; const int nMask[] = {1,3,15,255,65535}; const int nCount[] = {2,4,16,156,5960,4980260}; const int nTwistCount[] = {2,3,6,17,91,2903}; unsigned int nBadGuys5[16]; char** cIndicator; char isminordelta(unsigned int nDelta, char cSize, int nCount, unsigned int* nDeltalist); int find(unsigned int nDelta, char cSize, int nCount, unsigned int *nDeltaList); unsigned int minor(unsigned int nDelta, char cSize, char cElement, char cContract); char isdeltacheck(char cSize, char *cFeasible, char cSet); unsigned int deltaperm(unsigned int nDelta,int nPerm,char cSize); unsigned int deltatwist(unsigned int nDelta,char nTwist,char cSize); void deltainttofeasible(unsigned int nDelta,char *cFeasible, char cSize); unsigned int feasibletoint(char *cFeasible, char cSize); char indicatortofeasible(char *cSet1,char cSize); void deltaprint(char *cFeasible, char cSize); void deltaprintint(unsigned int nDelta, char cSize); void deltaprintinttofile(unsigned int nDelta, char cSize, ofstream &vfsafefile); void deltaprinttofile(char *cFeasible, char cSize, ofstream &vfsafefile); void setupindicator(); int main() { ofstream deltafile[cSizeMax+1][2]; char cFilename[cSizeMax+1][2][100]; for (int i=0;i<=cSizeMax;i++) { sprintf(cFilename[i][0],"C://Users//steven//Documents//deltamatroids//alldelta%d.txt",i); deltafile[i][0].open(cFilename[i][0]); sprintf(cFilename[i][1],"C://Users//steven//Documents//deltamatroids//isodetails%d.txt",i); deltafile[i][1].open(cFilename[i][1]); } int start=clock(); int nCount1[cSizeMax+1],nCountIso[cSizeMax+1],nCountTwist[cSizeMax+1]; for (char i=0;i<=cSizeMax;i++) nCountIso[i]=nCountTwist[i]=0; cIndicator = new char*[nTwoton[cSizeMax]]; for (int i=0;i nMin+1) { nMiddle = (nMax + nMin)/2; if (nDeltaList[nMiddle] == nDelta) return nMiddle; else if (nDeltaList[nMiddle] > nDelta) nMax = nMiddle; else nMin = nMiddle; } if (nMax < nCount && nDeltaList[nMax] == nDelta) return nMax; if (nDeltaList[nMin] == nDelta) return nMin; return -1; } unsigned int minor(unsigned int nDelta, char cSize, char cElement, char cContract) { unsigned int nAnswer=0, nMultiplier=1; unsigned int nBlocks = nTwoton[cSize]/nTwoton[cElement+1]; int nShift = nTwoton[cElement]; if (cContract) nDelta = nDelta >> nShift; for (unsigned int i=0;i> 2*nShift; } return nAnswer; } char isdeltacheck(char cSize, char *cFeasible, char i) { char cSet1[cSizeMax], bProblem=0, cComplement=cTwoton[cSizeMax]-i-1; memcpy(cSet1,cIndicator[i],cSizeMax); for (char k=0;k=0;i--) for (int j=i+1;j= cPerm[i]) cPerm[j]++; char cFeasible[32]; deltainttofeasible(nDelta,cFeasible,cSize); char cFeasible1[32]; for (char i=0;i #include #include #include #include #include using namespace std; const char cSize = 6; const unsigned long long nBig5 = 4294967296; const int nOldCount = 4980260; const int nOldIsoCount = 2903; const int nTwoton[] = {1,2,4,8,16,32,64}; const char cTwoton[] = {1,2,4,8,16,32,64}; const unsigned int nMask[] = {1,3,15,255,65535,4294967295}; unsigned long long nBadGuys6[32]; char** cIndicator; unsigned int *deltalist = new unsigned int [nOldCount]; unsigned int *isolist = new unsigned int [nOldIsoCount]; unsigned int *isocount = new unsigned int [nOldIsoCount]; char isminordelta(unsigned long long nDelta); int find(unsigned int nDelta); unsigned int minor(unsigned long long nDelta, char cElement, char cContract); void setupindicator(); int main() { char cFilename[2][100]; strcpy(cFilename[0],"C://Users//steven//Documents//Deltamatroids//alldelta5.txt"); strcpy(cFilename[1],"C://Users//steven//Documents//Deltamatroids//isodetails5.txt"); fstream deltafile[2]; deltafile[0].open(cFilename[0]); deltafile[1].open(cFilename[1]); int start=clock(); cIndicator = new char*[nTwoton[cSize]]; for (int i=0;i> deltalist[i] >> temp; for (int i=0;i> isolist[i] >> isocount[i]; unsigned long long nNewCount = 0; for(int it1=0;it1 nMin+1) { nMiddle = (nMax + nMin)/2; if (deltalist[nMiddle] == nDelta) return nMiddle; else if (deltalist[nMiddle] > nDelta) nMax = nMiddle; else nMin = nMiddle; } if (nMax < nOldCount && deltalist[nMax] == nDelta) return nMax; if (deltalist[nMin] == nDelta) return nMin; return -1; } unsigned int minor(unsigned long long nDelta, char cElement, char cContract) { unsigned int nAnswer=0, nMultiplier=1; unsigned int nBlocks = nTwoton[cSize]/nTwoton[cElement+1]; int nShift = nTwoton[cElement]; if (cContract) nDelta = nDelta >> nShift; for (unsigned int i=0;i> 2*nShift; } return nAnswer; } void setupindicator() { char j; for (char i=0;i