Abhisek92

Matrix of Indices

Oct 23rd, 2018
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. import numpy as np
  2. from itertools import product
  3.  
  4. def gen_index_mat(size=2):
  5.     if isinstance(size, int):
  6.         if size >= 2:
  7.             vec = list(range(size))
  8.             lst = list(product(vec, vec))
  9.             unpacked = np.array(lst, dtype='int, int')
  10.             kernel = unpacked.reshape(size, size)
  11.             return kernel
  12.  
  13.  
  14. print(gen_index_mat(5))
Add Comment
Please, Sign In to add comment