title: Efficient way to shift values in one matrix according to the values in another matrix
body: <p>So I want to shift the values in <code>matrix_a</code> according to the values in <code>matrix_b</code>. So if the value in <code>matrix_b</code> at postion <code>0,0</code> is <code>1</code>, then the element in the <code>result_matrix</code> at <code>0,0</code> should be the element that is at <code>1,1</code> in <code>matrix_a</code>. I already have this working using the following code:  </p>
  
  <pre><code>import numpy as np
  
  matrix_a = np.matrix([[1, 2, 3],
                        [4, 5, 6],
                        [7, 8, 9]])
  matrix_b = np.matrix([[1, 1, 0],
                        [0,-1, 0],
                        [0, 0, -1]])
  result_matrix = np.zeros((3,3))
  
  
  for x in range(matrix_b.shape[0]):
    for y in range(matrix_b.shape[1]):
      value = matrix_b.item(x,y)
      result_matrix[x][y]=matrix_a.item(x+value,y+value)
  
  print(result_matrix)
  </code></pre>
  
  <p>which results in: </p>
  
  <pre><code>[[5. 6. 3.]
   [4. 1. 6.]
   [7. 8. 5.]]
  </code></pre>
  
  <p>Right now this is quite slow on large matrices, and I have the feeling that this can be optimized using one of numpy or scipy's functions. Can someone tell me how this can be done more efficiently?</p>