I want to shift each row by its row-number and be relative to my desired output shape. An example:
array([[0, 1, 2], array([[0, 1, 2], array([[0, 1, 2, 0, 0],
[1, 2, 3], -> [1, 2, 3], -> [0, 1, 2, 3, 0],
[2, 3, 4]]) [2, 3, 4]]) [0, 0, 2, 3, 4])
The array to furthest left is my input and the array to the furthest right is my desired output. This can be generalized to bigger arrays, for example a 10x10
array.
Is there a nice way of doing this?
What I have is:
A = np.array([[1, 2, 3],
[2, 3, 4],
[3, 4, 5]], dtype=np.float32)
out = np.zeros((A.shape[0], A.shape[1]*2-1))
out[[np.r_[:3]], [np.r_[:3] + np.r_[:3][:,None]]] = A