title: numpy 2D-array divide precise lost
body: <p>I got some troubles when did numpy 2d-array divide. 
  I have a 2D numpy array A (shape=(N,N)), then i divide it by row_sum(axis=1) and got 2D-array B, but when i computed the row_sum(axis=1) of B, is not equal to <strong>one</strong> at some rows, the code is followed:
   (python2.7.x)</p>
  
  <pre><code>from __future__ import division
  import numpy as np
  
  A = np.array([[x_11, x_12, ..., x_1N],
                [x_21, x_22, ..., x_2N],
                [...   ...   ...  ... ]
                [x_N1, x_N2, ..., x_NN]]) # x_ij are some np.float64 values
  B = A / np.sum(A, axis=1, keepdims=True)
  </code></pre>
  
  <p>Theoretically result:</p>
  
  <pre><code>np.count_nonzero(np.sum(B, axis=1) != 1)
  # it should be 0
  </code></pre>
  
  <p>Reality result:</p>
  
  <pre><code>np.count_nonzero(np.sum(B, axis=1) != 1)
  # something bigger than 0
  </code></pre>
  
  <p>I believe the reason is <strong>precise lost</strong>, though i use the dtype=np.float64. Because in my project, the A 2D-array (shape=(N, N), N>8000), most of the values is very small(eg. =1.0) and the others are very big(eg. =2000) at the same row.</p>
  
  <p>I have try this: Add the losts</p>
  
  <pre><code>while np.count_nonzero(np.sum(B, axis=1) != 1) != 0
      losts = 1 - B
      B[:, i] += losts # the i may change by some conditions
  </code></pre>
  
  <p>Though, finally it can solve this problems, but is not good for next step in my project.</p>
  
  <p>Could anyone help me? Thanks a lot!!!   </p>