Skip to content

Commit 6c03d44

Browse files
Fix an 32 bit truncation on linkRep.
1 parent 5502092 commit 6c03d44

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

models/starComplexity.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ struct EvalStack
171171
auto recipeSize=2*numStars-1;
172172

173173
// suitable up to 10 node networks
174-
constexpr unsigned maxNodes=10, maxStars=2*maxNodes-1;
174+
constexpr unsigned maxNodes=11, maxStars=2*maxNodes-1;
175+
static_assert(sizeof(linkRep)*8 > (maxNodes*(maxNodes-1))/2);
175176
assert(nodes<=maxNodes);
176177
auto elemStars=&data.elemStars[0];
177178
auto pos=&data.pos[0];
@@ -447,9 +448,9 @@ linkRep toLinkRep(const NautyRep& g)
447448
if (g(i,j))
448449
{
449450
if (j<i)
450-
l|=1<<(i*(i-1)/2+j);
451+
l|=linkRep(1)<<(i*(i-1)/2+j);
451452
else if (i<j)
452-
l|=1<<(j*(j-1)/2+i);
453+
l|=linkRep(1)<<(j*(j-1)/2+i);
453454
}
454455
// else ignore self-links
455456
return l;

models/starComplexity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using linkRep=unsigned;
1+
using linkRep=unsigned long long;
22

33
#include <map>
44
#include <unordered_map>

models/starComplexity.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#print(ecolab.device())
33

44
from starComplexity import starC
5-
nodes=8
5+
nodes=11
66
# computed from max_{l\in[0,L]}min(n+L-l,2l) where L=n(n-1)/2
77
maxStars=0
88
L=int(0.5*nodes*(nodes-1))
@@ -11,7 +11,8 @@
1111
maxStars=max(maxStars,v)
1212

1313
print('maxStars=',maxStars)
14-
maxStars=8
14+
#maxStars=9
15+
maxStars=7
1516

1617
#starC.blockSize(256)
1718
#starC.blockSize(4096)
@@ -22,7 +23,8 @@
2223
starC.fillStarMap(maxStars)
2324
starC.canonicaliseStarMap()
2425

26+
print('g','links','*','C','C*','omega(g)','omega(g\')',sep=',')
2527
for i in starC.starMap.keys():
2628
c=starC.complexity(i)
27-
print(i,starC.symmStar(i),c.complexity(),c.starComplexity(),starC.counts[i],starC.counts[starC.complement(i)])
29+
print(i,bin(i).count('1'),starC.symmStar(i),c.complexity(),c.starComplexity(),starC.counts[i],starC.counts[starC.complement(i)],sep=',')
2830

0 commit comments

Comments
 (0)