title: Distance matrix over window (by accessing surrounding frames)
body: <p>I'm new to scipy, and recently learnt about <code>cdist</code> where we can pass our own custom function to compute distance. However, <code>cdist</code> only computes distance over individual points (and hence, the custom function must compute distance between two points). This works for most cases, but in my case, the distance is to be computed between a group of points. (You can think it as a sliding window, for example of size 3). An example will make this clear:</p>
  
  <pre><code>def f(*a, **kw):
      print(a, kw)
      return 0
  
  # Consider it a set of points: [p0, p1, p2, ...]
  a = numpy.array([[1,2,3],[10,11,12],[20,21,22],[30,31,32]]) 
  
  # Consider it a set of points: [q0, q1, q2, ...]
  b = numpy.array([[4,5,6],[14,15,16],[24,25,26],[34,35,36],[44,45,46]])
  </code></pre>
  
  <p>Now if I simply do <code>scipy.spatial.distance.cdist(a, b, f)</code>, each time <code>f</code> is called, only 1 entry from each array is passed to <code>f</code>. So the function calls (and passed values) looks something like:</p>
  
  <pre><code>1st call: p0, q0
  2nd call: p0, q1
  3rd call: p0, q2
  4th call: p0, q3
  5th call: p0, q4 &lt;-- 
  6th call: p1, q0
  7th call: p1, q1
  ...and so on...
  </code></pre>
  
  <p>But what I want is something like (for the window of size 3):</p>
  
  <pre><code>1st call: [p0,p1,p2], [q0,q1,q2]
  2nd call: [p0,p1,p2], [q1,q2,q3]
  3rd call: [p0,p1,p2], [q2,q3,q4] &lt;-- only till boundary
  4th call: [p1,p2,p3], [q0,q1,q2]
  5th call: [p1,p2,p3], [q1,q2,q3]
  ...and so on...
  </code></pre>
  
  <p>I've searched a lot, and also tried scipy's <a href="http://docs.scipy.org/doc/scipy/reference/tutorial/ndimage.html#generic-filter-functions" rel="nofollow">generic filter</a> and <a href="http://docs.scipy.org/doc/scipy/reference/tutorial/ndimage.html#correlation-and-convolution" rel="nofollow">correlation functions</a>, but they do not provide that functionality (as far as I understood). Is there <em>any way</em> to compute distance as mentioned above? </p>
  
  <p>Any idea/suggestion is welcome.
  Thanks</p>