title: Linear interpolation of two 2D arrays
body: <p>In a previous question (<a href="https://stackoverflow.com/questions/43772218/fastest-way-to-use-numpy-interp-on-a-2-d-array">fastest way to use numpy.interp on a 2-D array</a>) someone asked for the fastest way to implement the following:</p>
  
  <pre><code>np.array([np.interp(X[i], x, Y[i]) for i in range(len(X))])
  </code></pre>
  
  <p>assume <code>X</code> and <code>Y</code> are matrices with many rows so the for loop is costly. There is a nice solution in this case that avoids the for loop (see linked answer above).</p>
  
  <hr>
  
  <p>I am faced with a very similar problem, but I am unclear on whether the for loop can be avoided in this case:</p>
  
  <pre><code>np.array([np.interp(x, X[i], Y[i]) for i in range(len(X))])
  </code></pre>
  
  <p>In other words, I want to use linear interpolation to upsample a large number of signals stored in the rows of two matrices <code>X</code> and <code>Y</code>.
  I was hoping to find a function in numpy or scipy (scipy.interpolate.interp1d) that supported this operation via broadcasting semantics but I so far can't seem to find one.</p>
  
  <p><em>Other points:</em></p>
  
  <ul>
  <li><p>If it helps, the rows <code>X[i]</code> and <code>x</code> are pre-sorted in my application. Also, in my case <code>len(x)</code> is quite a bit larger than <code>len(X[i])</code>. </p></li>
  <li><p>The function <a href="https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.signal.resample.html" rel="nofollow noreferrer"><code>scipy.signal.resample</code></a> almost does what I want, but it doesn't use linear interpolation...</p></li>
  </ul>