I am coding a function to create generator matrix using Reed-Solomon encoding in Python. it is currently using for loops but i was wondering if there is a more efficient way to this. My code is:
def ReedSolomon(k,p):
M = np.zeros((k,p))
for i in range(k):
for j in range(p):
M[i][j] = j**i
return M
I believe my function works but may not scale well to large p and k

The generalized equation for an element at index
r, cin your matrix isc**r.For a matrix of shape
k, p, you can create twoaranges -- a row vector from0top-1, and a column vector from0tok-1, and have numpy automatically broadcast the shapes:Calling this function with e.g.
k=5, p=3gives: