0
M = np.zeros((N,L))

The above statement gives a N x L matrix initially filled with 0. I need a similar statement to create a N x L matrix filled with (0,0) tuples. How can I create it?

Ahmad
  • 8,811
  • 11
  • 76
  • 141

1 Answers1

1

How about this solution:

N = 3
L = 3
M = np.zeros((N,L))
res =  np.array(list(zip(M.ravel(),M.ravel())), dtype=('i4,i4')).reshape(M.shape)

# returns
array([[(0, 0), (0, 0), (0, 0)],
       [(0, 0), (0, 0), (0, 0)],
       [(0, 0), (0, 0), (0, 0)]], dtype=[('f0', '<i4'), ('f1', '<i4')])
dubbbdan
  • 2,650
  • 1
  • 25
  • 43