cpierquet

pythontexgodel

Sep 25th, 2021
813
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. \setcounter{MaxMatrixCols}{20}
  2.  
  3. \begin{pycode}
  4. import numpy as np
  5.  
  6. def Table_Layer(n):
  7.     A=np.zeros((2**n+1,2**n+1))
  8.     for i in range(2**n):
  9.         A[i+1,1]=(i+2)%2**n
  10.     for j in range(2**n):
  11.         A[2**n,j+1]=(j+1)%2**n
  12.     for i in range(2**n+1):
  13.         for j in range(2**n+1):
  14.             if A[i,j]==0:
  15.                 A[i,j]=2**n
  16.     for i in range(2**n+1):
  17.         for j in range(2**n+1):
  18.             if (i<2**n) and (i>0):
  19.                 if j>1:
  20.                     k=int(A[2**n-i,j-1])
  21.                     p=int(A[2**n-i,1])
  22.                     ci=int(2**n-i)
  23.                     A[ci,j]=A[k,p]
  24.     B=np.zeros((2**n,2**n))
  25.     for i in range(2**n):
  26.         for j in range(2**n):
  27.             B[i,j]=int(A[i+1,j+1])
  28.     print(r"\begin{pmatrix}")
  29.     for i in range(2**n) :
  30.         for j in range(2**n -1) :
  31.             print(f"{int(B[i,j])}",'& ',end='')
  32.         print(f"{int(B[i,2**n-1])}",'\\\\')
  33.     print(r"\end{pmatrix}")
  34. \end{pycode}
  35.  
  36. Pour $n=3$ :
  37.  
  38. \[\pyc{Table_Layer(3)}\]
  39.  
  40. Pour $n=4$ :
  41.  
  42. \[\pyc{Table_Layer(4)}\]
RAW Paste Data