If this has been asked and answered before, I will remove it.
I'd like to initialize a collection of m x m matrices in different, distinct groups. Given the parameter n, the first group consists of n-1 matrices, the second one of n-2 and so on. Preferrably, I'd like the matrices to be initialized with each column being an array of type np.linspace(0,1,m). I've considered initializing a 4D numpy array, however, only half of the matrices will be needed then. Is storing the matrices in a list a better option?
import numpy as np
n=2
m=2
M = np.zeros([n,n,m,m])
for i in range(0,n):
for j in range(i,n):
for k in range(0, m):
M[i,j,:,k] = np.linspace(0,1,m)
EDIT1: It is not so important how the elements of the matrices are initialized.
EDIT2: It is not true that only half of the matrices will be needed in the 4D array, since each row of matrices would start on the diagonal to get the correct number of matrices.