# Untitled

a guest
May 5th, 2023
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. balanced:=function(m);
3. M:=Matrix([[w,0],[1,1]]);
4. T:=M;
5. for i:=1 to m-1 do// This performs the tensor product m times.
6. T:=TensorProduct(T,M);
7. end for;
8. return T;
9. end function;
10.
11. Nebegen:=function(m);
13. T:=balanced(m);
14. B:=T;
15. for i:=1 to 2^m do
16. for j:=1 to 2^m do
17. if Eltseq(T[i,j])[2] ne 0 then //Eltseq[2] tells me the sqrt(2) part.
18. B[i,j]:=w * Eltseq(T[i,j])[2] * w; //Eltseq*w is the number. Then multiplying it by w again makes it rational.
19. end if; //b/c apparently just multiplying it by w is enough to give the rational part.
20. end for;
21. end for;
22. B:=ChangeRing(B, Integers());
23. return B;
24. end function;
25.
26. Nebegram:=function(m);
27. G:=Nebegen(m);
28. G:=G*Transpose(G);
29. return G;
30. end function;
31.
32. Griessgen:=function(m);
34. g:=Nebegen(m);
36. if IsEven(m) then
37. c:=w ^ (-m div 2);
38. end if;
39. if IsOdd(m) then
40. c:=w ^ ((-m-1) div 2);
41. end if;
42. for i:=1 to 2^m do
43. for j:=1 to 2^m do
44. g[i,j]:=c * g[i,j];
45. end for;
46. end for;
47. return g;
48. end function;
49.
50. Griessgram:=function(m); //This one calculates the Gram matrix using the results of the previous function
51. curlym:=Griessgen(m);
52. curlym:=curlym*Transpose(curlym);
53. curlym:=ChangeRing(curlym,Integers());
54. return curlym;
55. end function;
56.
57. Griessgramdirect:=function(m); //This one calculates it directly.
58. G:=ScalarMatrix(2 ^ m,0); //Initializing the Gram matrix.
59. for a:=1 to 2^m do //Looping through the entries of G.
60. for b:=1 to 2^m do
61. i:=a - 1; //I have to do this b/c our formula has indices start at 0.
62. j:=b - 1;
63. s:=0; //This will become the i,jth entry of the Gram matrix.
64. x:=0; //This will be the number of times the binary reps of i and j match in a slot.
65. z:=0; //This will be the number of zeroes in the binary rep of i.
66. Z:=0; //This will be the number of zeroes in the binary rep of j.
67. t:=0; //This will me which equation to use: 0 if i,j even; 1 if i or j odd; 2 if i,j odd.
68. L:=[* *]; //Initializing the binary rep of i.
69. M:=[* *]; //Initializing the binary rep of j.
70. for l:=1 to m do
71. if (i - (2 ^ (m - l))) ge 0 then
72. i:=i - (2 ^ (m - l));
73. L:=Append(L,1);
74. else
75. L:=Append(L,0);
76. end if;
77. if (j - (2 ^ (m - l))) ge 0 then
78. j:=j - (2 ^ (m - l));
79. M:=Append(M,1);
80. else
81. M:=Append(M,0);
82. end if;
83. end for;
84. for l:=1 to (m) do
85. if L[l] eq 0 then
86. z:=z+1;
87. end if;
88. if M[l] eq 0 then
89. Z:=Z+1;
90. end if;
91. if L[l] eq M[l] then
92. x:=x+1;
93. end if;
94. end for;
95. if IsOdd(z) then
96. t:=t+1;
97. end if;
98. if IsOdd(Z) then
99. t:=t+1;
100. end if;
101. if t eq 0 then
102. s:= 2 ^ (x div 2);
103. elif t eq 1 then
104. s:= 2 ^ ((x + 1) div 2);
105. elif t eq 2 then
106. s:= 2 ^ ((x div 2) +1 );
107. end if;
108. G[a,b]:=s;
109. end for;
110. end for;
111. return G;
112. end function;
113.
114. //This function sends a complex number to a 2x2 real matrix.
115. Realify:=function(j);
117. j:=j + (0 * i);
118. M:=Matrix([[Eltseq(j)[1],Eltseq(j)[2]],[-1 * Eltseq(j)[2],Eltseq(j)[1]]]);
119. M:=ChangeRing(M, Integers());
120. return M;
121. end function;
122.
123. //This function sends a complex n x n matrix to a 2n x 2n real matrix.
124. RealifyMatrix:=function(M);
127. R:=ScalarMatrix(2 * NumberOfRows(M), 0); //Initializing the real matrix.
128. l:=-1;
129. k:=-1;
130. for a:=1 to NumberOfRows(M) do //Looping through the rows of the complex matrix
131. L:=l + (2 * a);
132. for b:=1 to NumberOfRows(M) do
133. K:=k + (2 * b);
134. R:=InsertBlock(R,Realify(M[a,b]),L,K);
135. end for;
136. end for;
137. return R;
138. end function;
139.
140. //This function gets the IEEE construction of the Barnes Wall lattice of degree m, via the definition; start with {{1,1},{0,1+i}} and tensor m times.
141. IEEEimaginary:=function(m);
143. M:=Matrix([[1,1],[0,1+i]]);
144. T:=M;
145. for i:=1 to m-1 do
146. T:=TensorProduct(T,M);
147. end for;
148. return T;
149. end function;
150.
151. //This function realifies the complex generator matrix given by the IEEE construction.
152. IEEEreal:=function(m);
154. R:=ChangeRing(RealifyMatrix(IEEEimaginary(m)),Integers());
155. return R;
156. end function;
157.
158. //This function gets the MathOverflow construction of the Barnes Wall lattice of degree m, via the definition; starting with {{1,1},{1,i}} and tensoring m times.
159. Overflowimaginary:=function(m);
161. M:=Matrix([[1,1],[1,i]]);
162. T:=M;
163. for i:=1 to m-1 do
164. T:=TensorProduct(T,M);
165. end for;
166. return T;
167. end function;
168.
169. //This function realifies the complex generator matrix given by the Overflow construction.
170. Overflowreal:=function(m);
172. R:=ChangeRing(RealifyMatrix(Overflowimaginary(m)),Integers());
173. return R;
174. end function;
175.
176.
177. //This gets the Gram matrix of the complex generator matrix given by the IEEE construction.
178. IEEEimaginarygram:=function(m);
179. X:=IEEEimaginary(m);
180. X:=X*Transpose(X);
181. return X;
182. end function;
183.
184. //This gets the Gram matrix of the realified generator matrix given by the IEEE construction.
185. IEEErealgram:=function(m);
186. X:=IEEEreal(m);
187. X:=X*Transpose(X);
188. return X;
189. end function;
190.
191. //The gram matrix of the IEEE realified matrix is NOT the realified version of the complex gram matrix; this will return false
192. RealifyMatrix(IEEEimaginarygram(1)) eq IEEErealgram(1);
193.
194. //This gets the Gram matrix of the realified generator matrix given by the Overflow construction.
195. Overflowrealgram:=function(m);
196. X:=Overflowreal(m);
197. X:=X*Transpose(X);
198. return X;
199. end function;
200.
201. //This gets the Gram matrix of the complex generator matrix given by the Overflow construction.
202. Overflowimaginarygram:=function(m);
203. X:=Overflowimaginary(m);
204. X:=X*Transpose(X);
205. return X;
206. end function;
207.
208. //This directly calculates the complex generator matrix of IEEE's construction. If ever ik=1 and jk=0, that entry is 0. Otherwise, the ij'th entry is (1+i) to the power of the number of times ik=jk=1.
209. Ione:=function(m);
211. G:=ScalarMatrix(2^m,i);
212. for a:=1 to 2^m do
213. for b:=1 to 2^m do
214. z:=a - 1; //z instead of i since i is in use
215. j:=b - 1;
216. s:=1;
217. x:=0;
218. L:=[* *];
219. M:=[* *];
220. for l:=1 to m do
221. if (z - (2 ^ (m - l))) ge 0 then
222. z:=z - (2 ^ (m - l));
223. L:=Append(L,1);
224. else
225. L:=Append(L,0);
226. end if;
227. if (j - (2 ^ (m - l))) ge 0 then
228. j:=j - (2 ^ (m - l));
229. M:=Append(M,1);
230. else
231. M:=Append(M,0);
232. end if;
233. end for;
234. for l:=1 to m do
235. if L[l] eq 1 then
236. if M[l] eq 0 then
237. s:=0;
238. elif M[l] eq 1 then
239. x:=x+1;
240. end if;
241. end if;
242. end for;
243. if s ne 0 then
244. s:=(1 + i) ^ x;
245. end if;
246. G[a,b]:=s;
247. end for;
248. end for;
249. return G;
250. end function;
251.
252. //This directly calculates the complex generator matrix of MathOverflow's construction. The ij'th entry is i to the power of the number of times ik=jk=1.
253. Itwo:=function(m);
255. G:=ScalarMatrix(2^(m),i);
256. for a:=1 to 2^m do
257. for b:=1 to 2^m do
258. z:=a - 1; //z instead of i since i is in use
259. j:=b - 1;
260. x:=0;
261. L:=[* *];
262. M:=[* *];
263. for l:=1 to m do
264. if (z - (2 ^ (m - l))) ge 0 then
265. z:=z - (2 ^ (m - l));
266. L:=Append(L,1);
267. else
268. L:=Append(L,0);
269. end if;
270. if (j - (2 ^ (m - l))) ge 0 then
271. j:=j - (2 ^ (m - l));
272. M:=Append(M,1);
273. else
274. M:=Append(M,0);
275. end if;
276. end for;
277. for l:=1 to m do
278. if L[l] eq 1 then
279. if M[l] eq 1 then
280. x:=x+1;
281. end if;
282. end if;
283. end for;
284. G[a,b]:=i ^ x;
285. end for;
286. end for;
287. return G;
288. end function;
289.
290. //This directly calculates the realifed generator matrix of MathOverflow's construction. Take i^x to the power of the number of times that the binary reps of i and j coincide in all but the last slot, realify it, and then pick the entry of that matrix corresponding to the last slots of the binary reps of i and j.
291. Rtwo:=function(k);
292. m:=k+1;
294. G:=ScalarMatrix(2^(m),i);
295. for a:=1 to 2^(m) do
296. for b:=1 to 2^(m) do
297. z:=a - 1; //z instead of i since i is in use
298. j:=b - 1;
299. s:=0;
300. x:=0;
301. L:=[* *];
302. M:=[* *];
303. for l:=1 to m do
304. if (z - (2 ^ (m - l))) ge 0 then
305. z:=z - (2 ^ (m - l));
306. L:=Append(L,1);
307. else
308. L:=Append(L,0);
309. end if;
310. if (j - (2 ^ (m - l))) ge 0 then
311. j:=j - (2 ^ (m - l));
312. M:=Append(M,1);
313. else
314. M:=Append(M,0);
315. end if;
316. end for;
317. for l:=1 to k do
318. if L[l] eq 1 then
319. if M[l] eq 1 then
320. x:=x+1;
321. end if;
322. end if;
323. end for;
324. s:=i ^ x;
325. S:=Realify(s);
326. G[a,b]:=S[L[m]+1,M[m]+1];
327. end for;
328. end for;
329. G:=ChangeRing(G,Integers());
330. return G;
331. end function;
332.
333. //This directly calculates the realifed generator matrix of IEEE's construction, using a similar method as before.
334. Rone:=function(k);
335. m:=k+1;
337. G:=ScalarMatrix(2^m,i);
338. for a:=1 to 2^m do
339. for b:=1 to 2^m do
340. z:=a - 1; //z instead of i since i is in use
341. j:=b - 1;
342. s:=1;
343. x:=0;
344. L:=[* *];
345. M:=[* *];
346. for l:=1 to m do
347. if (z - (2 ^ (m - l))) ge 0 then
348. z:=z - (2 ^ (m - l));
349. L:=Append(L,1);
350. else
351. L:=Append(L,0);
352. end if;
353. if (j - (2 ^ (m - l))) ge 0 then
354. j:=j - (2 ^ (m - l));
355. M:=Append(M,1);
356. else
357. M:=Append(M,0);
358. end if;
359. end for;
360. for l:=1 to k do
361. if L[l] eq 1 then
362. if M[l] eq 0 then
363. s:=0;
364. elif M[l] eq 1 then
365. x:=x+1;
366. end if;
367. end if;
368. end for;
369. if s ne 0 then
370. s:=(1 + i) ^ x;
371. end if;
372. S:=Realify(s);
373. G[a,b]:=S[L[m]+1,M[m]+1];
374. end for;
375. end for;
376. G:=ChangeRing(G,Integers());
377. return G;
378. end function;
379.
380. //This function checks if the formulas used to directly calculate the matrices (looking at binary reps) match the matrices given by the definition (tensoring then realifying). All of them will be true for any m.
381. checkformulaswork:=function(m);
382. Ione(m) eq IEEEimaginary(m);
383. Itwo(m) eq Overflowimaginary(m);
384. Rone(m) eq IEEEreal(m);
385. Rtwo(m) eq Overflowreal(m);
386. return "";
387. end function;
388.
389. //This function checks if the lattices generated by the realified generator matrices of the IEEE construction and Overflow construction match. It will return true for any m.
390. checklatticessame:=function(m);
391. return Lattice(Rone(m)) eq Lattice(Rtwo(m));
392. end function;
393.
394. //This directly calculates the matrix that relates the complex generating matrices given by IEEE and Overflow's constructions.
395. ImaginaryRelatingMatrix:=function(m);
396. return Ione(m)*Itwo(m)^-1;
397. end function;
398.
399. //This calculates the matrix that relates them via starting with the matrix for m=1, and tensoring m times.
400. ImaginaryRelatingMatrixTensor:=function(m);
401. M:=ImaginaryRelatingMatrix(1);
402. T:=M;
403. for i:=1 to m-1 do
404. T:=TensorProduct(T,M);
405. end for;
406. return T;
407. end function;
408.
409. //This verifies that the above two functions give the same matrix
410. ImaginaryRelatingMatricesSame:=function(m);
411. return ImaginaryRelatingMatrix(m) eq ImaginaryRelatingMatrixTensor(m);
412. end function;
413.
414. //This realifies the matrix that relates the complex generating matrix. As of this moment in time, we have no idea if the output of this is the matrix that relates the realified generating matrices, but it will turn out to be.
415. RealifyImaginaryRelatingMatrix:=function(m);
416. return RealifyMatrix(ImaginaryRelatingMatrixTensor(m));
417. end function;
418.
419. //This directly calculates the matrix that relates the realified generating matrices.
420. RealRelatingMatrix:=function(m);
421. return Rone(m)*ChangeRing(Rtwo(m),RationalField())^-1;
422. end function;
423.
424. //This checks to see if the matrices given by the above two functions are the same.
425. RelatingMatricesSame:=function(m)
426. return RealRelatingMatrix(m) eq RealifyImaginaryRelatingMatrix(m);
427. end function;
428.
429. //For the IEEE and Overflow realified generating matrices to generate the same Z-lattice, their relating matrix has to be unimodular. This checks that. It will always return Integer Ring,1.
430. IsRelatingMatrixUnimodular:=function(m);
431. I:=RealifyImaginaryRelatingMatrix(1);
432. return BaseRing(I),Determinant(I);
433. end function;
434.
435. //Basically what I've determined here is that IEEE and Overflow have the same realified Gram matrices, and they do generate the same realified lattice; the unimodular matrix that transforms one into the other is {{1,0},{i,-i}} tensored with itself m times and then realified.
436.
437. SplitMatrix:=function(M);
439. R:=ScalarMatrix(NumberOfRows(M), 0);
440. I:=ScalarMatrix(NumberOfRows(M), 0);
441. for i:=1 to NumberOfRows(M) do
442. for j:=1 to NumberOfColumns(M) do
443. R[i,j]:=Eltseq(M[i,j])[1];
444. I[i,j]:=Eltseq(M[i,j])[2];
445. end for;
446. end for;
447. return <R,I>;
448. end function;
449.
450. OtherRealifyMatrix:=function(M);
452. L:=ScalarMatrix(2 * NumberOfRows(M),0);
453. R:=SplitMatrix(M)[1];
454. I:=SplitMatrix(M)[2];
455. L:=InsertBlock(L,R,1,1);
456. L:=InsertBlock(L,I,1,NumberOfRows(M)+1);
457. L:=InsertBlock(L,-1*I,NumberOfColumns(M)+1,1);
458. L:=InsertBlock(L,R,NumberOfRows(M)+1,NumberOfRows(M)+1);
459. return L;
460. end function;
461.
462. IEEEconstant:=function(m);
464. if IsOdd(m) then
465. l:=(m-1) / 4;
466. else
467. l:=(m-2) / 4;
468. end if;
469. if IsCoercible(Integers(),l) then
470. c:=2^(-(Integers() ! l));
471. else
472. k:=Integers() ! (l-1/2);
473. c:=2^(-k) * 1/w;
474. end if;
475. return c;
476. end function;
477.
478. CheckIsometric:=function(m);
479. G:=Griessgram(m);
480. if m eq 1 then
481. I:=Matrix([[1,0],[0,1]]);
482. else
483. I:=IEEEreal(m-1);
484. end if;
485. c:=IEEEconstant(m);
486. J:=c*I;
487. H:=J*Transpose(J);
488. H:=ChangeRing(H,Integers());
489. return IsIsometric(LatticeWithGram(G),LatticeWithGram(H));
490. end function;