I have matrix two matrixes:
A = [1,2,3,4]
B = np.zeros((4,8))
So, how can I have a matrix C, with a format like this:
C=[[1,2,3,4,0,0,0,0],[0,0,1,2,3,4,0,0],[0,0,0,0,1,2,3,4],[3,4,0,0,0,0,1,2]]
>Solution :
You can use following solution without numpy, but i appreciate if you have smarter version using numpy then feel free to highlight
A = [1, 2, 3, 4, 0, 0, 0, 0]
matrix = [A]
for shift in range(3):
A = A[-2:] + A[:-2]
matrix.append(A)
print(matrix)
[[1, 2, 3, 4, 0, 0, 0, 0], [0, 0, 1, 2, 3, 4, 0, 0], [0, 0, 0, 0, 1,
2, 3, 4], [3, 4, 0, 0, 0, 0, 1, 2]]