Cross-Ratio Reversible Lattice Layer / path_check.py
Mechanism confirmed, baseline not beaten
1import json
2import numpy as np
3from cross_ratio_lattice import complete_c, residual
4
5# Same boundary data, two valid local completion orders for z[2,2].
6rng = np.random.default_rng(77)
7boundary = rng.normal(size=5) + 1j*rng.normal(size=5)
8left = rng.normal(size=5) + 1j*rng.normal(size=5)
9left[0] = boundary[0]
10
11def path(order):
12 z = np.zeros((3,3), dtype=np.complex128)
13 z[0,:] = boundary[:3]
14 z[:,0] = left[:3]
15 for i,j in order:
16 z[i+1,j+1], _ = complete_c(z[i,j], z[i+1,j], z[i,j+1])
17 return z
18# Both orders compute all cells, but choose different intermediate staircase.
19row = path([(0,0),(0,1),(1,0),(1,1)])
20col = path([(0,0),(1,0),(0,1),(1,1)])
21result = {
22 'z22_path_disagreement': float(abs(row[2,2]-col[2,2])),
23 'row_residual_max': float(np.nanmax(residual(row[:-1,:-1],row[1:,:-1],row[1:,1:],row[:-1,1:]))),
24 'col_residual_max': float(np.nanmax(residual(col[:-1,:-1],col[1:,:-1],col[1:,1:],col[:-1,1:])))
25}
26print(json.dumps(result, indent=2))
27with open('path_results.json','w') as f: json.dump(result,f,indent=2)