I want to create a square matrix like this one where its element is a square matrix either the B square matrix or the negative identity matrix or zeros. I have created the B matrix as well as the -I and also I have created a Z matrix of zeros. B, I and Z squares matrices with same n1*n1 (or n2 * n2) dimensions and the final matrix I want to have n*n dimensions where n = n1 * n2
If for example B, I and Z are 4*4 the final will be 16*16
I know how to concatenate and stack matrices but I don't know how to implement this better since need to make the below process 64! times.
for iter in range(64):
if iter == 0:
temp = B
temp = np.hstack((temp, I))
temp = np.hstack((temp, Z))
temp = np.hstack((temp, Z))
if iter == 1:
temp2 = I
temp2 = np.hstack((temp2, B))
temp2 = np.hstack((temp2, I))
temp2 = np.hstack((temp2, Z))
if iter == 2:
temp3 = Z
temp3 = np.hstack((temp3, I))
temp3 = np.hstack((temp3, B))
temp3 = np.hstack((temp3, I))
if iter == 3:
temp4 = Z
temp4 = np.hstack((temp4, Z))
temp4 = np.hstack((temp4, I))
temp4 = np.hstack((temp4, B))
.......
........
........
st1 = np.vstack((temp, temp2))
st2 = np.vstack((st1, temp3))
.......
Can I save n*n matrices into array elements and then concatenate or stack them?