title: Using Numpy and while loops to generate all possible addition combinations
body: <p>I am attempting to build an N-dimensional array from 2 base arrays that show all the possible combinations possible for the addition of all values such that:</p>
  
  <pre><code>Array A = [N0, N1, N2, ... , Nn]
  
  Array B = [M0, M1, M2, ..., Mn]
  
  Combinations = [[N0+M0, N0 + M1, ..., N0+Mn],
  
                  [N1+M0, N1 + M1, ..., N1 + Mn],
                  .
                  .
                  .,
                  ]
  </code></pre>
  
  <p>I am aware that I can use the cartesian product to find all possible combinations (I do not care about repetition) however I do not need the product of all values, I need the addition.  I cannot seem to get the while loop I've coded to be able to append the rows as it generates new data (code below).</p>
  
  <pre><code>import numpy as np
  MassFlowOx = np.linspace(0.1,103,150)*10**-3
  MassFlowFuel = np.linspace(0.1,75,150)*10**-3
  size = len(MassFlowFuel)
  size_final=size**2
  MassFlowComb = np.zeros(size)
  temp = np.zeros(size, dtype=float)
  i=0
  j=0
  MassFlowCombArray = np.zeros(size)
  
  # runs all possible combinations for the addition of values in arrays
  while i&lt;size-1:
      temp[i] = MassFlowFuel[i] + MassFlowOx[i]
      while j&lt;size-1:
          MassFlowOx[i] = MassFlowOx[j]
          print MassFlowOx[i]        
          j += 1
      MassFlowComb[i] = temp[i]
  
      MassFlowCombArray[i] = np.append([MassFlowComb[0]], [MassFlowComb[i]], axis = 0)
      i+=1
  
  print MassFlowComb[i]
  </code></pre>
  
  <p>Is there a particular fucntion I can use?  I have not been succesfull in identifying a method that does the addition of all combinations of values in a while loop as it gives sequence error.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Both answers worked. The for loop makes it inN-dimensional and using <code>np.add.outer</code> makes an N dimensional array. For the purposes of this code the latter is more useful.</p>
  
  <p>Thank you for all the responses!</p>