Skip to content

Commit

Permalink
Updating newtools
Browse files Browse the repository at this point in the history
  • Loading branch information
dhothem committed Sep 30, 2024
1 parent 15574bf commit c83a606
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pygsti/extras/ml/newtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@
from tensorflow import unique
import tensorflow as _tf

def grid_adj_matrix(grid_width: int):
num_qubits = grid_width**2
adj_matrix = _np.zeros((num_qubits, num_qubits))
for i in range(num_qubits):
if i % grid_width == grid_width - 1 and i != grid_width*grid_width - 1:
# far right column, not the bottom left corner
# print(i)
# print('first')
adj_matrix[i, i+grid_width] = 1
elif i // grid_width == grid_width - 1 and i != grid_width*grid_width - 1:
# bottom row, not the bottom left corner
adj_matrix[i, i+1] = 1
elif i != num_qubits - 1:
# print(i)
# print('third')
# not the bottom right corner
adj_matrix[i, i+grid_width] = 1
adj_matrix[i, i+1] = 1
adj_matrix = adj_matrix + adj_matrix.T
return adj_matrix

def ring_adj_matrix(num_qubits: int):
adj_matrix = _np.zeros((num_qubits, num_qubits))
Expand Down

0 comments on commit c83a606

Please sign in to comment.