title: Numpy, problem with long arrays
body: <p>I have two arrays (a and b) with n integer elements in the range (0,N).</p>
  
  <p><em>typo: arrays with 2^n integers where the largest integer  takes the value N = 3^n</em></p>
  
  <p>I want to calculate the sum of every combination of elements in a and b (sum_ij_ = a_i_ + b_j_ for all <em>i,j</em>). Then take modulus N (sum_ij_ = sum_ij_ % N), and finally calculate the frequency of the different sums.</p>
  
  <p>In order to do this fast with numpy, without any loops, I tried to use the meshgrid and the bincount function.</p>
  
  <pre><code>A,B = numpy.meshgrid(a,b)
  A = A + B
  A = A % N
  A = numpy.reshape(A,A.size)
  result = numpy.bincount(A)
  </code></pre>
  
  <p>Now, the problem is that my input arrays are long. And meshgrid gives me MemoryError when I use inputs with 2^13 elements. I would like to calculate this for arrays with 2^15-2^20 elements.</p>
  
  <p><em>that is n in the range 15 to 20</em></p>
  
  <p>Is there any clever tricks to do this with numpy?</p>
  
  <p>Any help will be highly appreciated.</p>
  
  <p>-- 
  jon</p>