mapping a 2d delay vector from a 1d vector in numpy
mapping a 2d delay vector from a 1d vector in numpy I am trying to generate a 2D vector from a 1D vector where the element is shifted along the row by an increment each row. i would like my input to look like this: input: t = [t1, t2, t3, t4, t5] out = [t5, 0, 0, 0, 0] [t4, t5, 0, 0, 0] [t3, t4, t5, 0, 0] [t2, t3, t4, t5, 0] [t1, t2, t3, t4, t5] [ 0, t1, t2, t3, t4] [ 0, 0, t1, t2, t3] [ 0, 0, 0, t1, t2] [ 0, 0, 0, 0, t1] im unaware of a way to do this without using a for loop, and computational efficieny is important for the task im using this for. Is there a way to do this without a for loop? this is my code using a for loop: import numpy as np t = np.linspace(-3, 3, 7) z = np.zeros((2*len(t) - 1, len(t))) diag = np.arange(len(t)) for index, val in enumerate(np.flip(t, 0)): z[diag + index, diag] = val print(z) 3 Answers 3 What you're asking for here is known as a Toeplitz M...