I am working with NumPy arrays.
I have a 2N length vector D and want to reshape part of it into an N x N array C.
Right now this code does what I want, but is a bottleneck for larger N:
```
import numpy as np
M = 1000
t = np.arange(M)
D = np.sin(t) # initial vector is a sin() function
N = M / 2
C = np.zeros((N,N))
for a in xrange(N):
for b in xrange(N):
C[a,b] = D[N + a - b]
```
Once C is made I go ahead and do some matrix arithmetic on it, etc.
This nested loop is pretty slow, but since this operation is essentially a change in indexing I figured that I could use NumPy's builtin reshape (numpy.reshape) to speed this part up.
Unfortunately, I cannot seem to figure out a good way of transforming these indices.
Any help speeding this part up?