<p dir="auto">I have a very strange behavior with the np.dot() function. When computing:<br>
np.dot(vector, vector)<br>
I get a negative value, -3.68935e+19, with the array below:<br>
[-0.95558429 -0.79491568 -0.34074336 -0.31960416 -0.50112027 -0.14804825<br>
0.83092237 -1.04872239 -0.06821966  0.95099533  0.23211323 -0.08363034<br>
-0.84720689  0.53866994  0.33275896  0.18167147  0.42636991 -0.90105802<br>
1.03073204  0.35682318  0.753968   -1.25347698 -0.15214275  0.01669976<br>
0.61865449  0.5806967   1.33312941  0.20144169  0.11802452 -0.29711285<br>
-0.29448548  1.11324942  0.1951234  -0.20648302 -0.28658506  1.09960926<br>
-0.36813557 -0.78195006  0.57407916  0.15383098  0.30026323  1.03336143<br>
0.67244434  0.00452838  0.80118829 -0.23254229  0.66596371  0.15719646<br>
0.40883717  0.40989453 -1.20930338  0.94520253  0.79906452 -0.22432771<br>
0.97588438 -1.72914338  0.05262739 -0.54656118  0.30642688  1.95097971<br>
0.31468016 -0.37122983 -0.77826643  0.06892334 -1.80932391 -0.50851583<br>
-0.37202829 -1.51686203  0.74873447  0.01304383 -0.19901061 -1.07052517<br>
0.75449711 -0.21430047  0.67405069  0.30016151 -0.54680014  1.19146216<br>
0.36444184  0.03734953 -0.32377601  0.56825429  0.81616706 -0.8266384<br>
1.17172229 -0.30052993  1.3422761  -0.33125407  1.96316791 -0.7671603<br>
-0.51845783 -1.07401311  0.47158152 -0.20735571  0.62432927  0.3078284<br>
0.11610977 -1.04085588 -0.97068292  1.1042937 ]</p>
<p dir="auto">I am using the latest version of Anaconda3 (5.0.1) on macOS 10.13.1<br>
The dtype of the array is float32. The problem disappears when converting it to float or np.float64.</p>
<p dir="auto">I've found a very strange bug. Under certain circumstances, a small number of the entries in the dot product of two 2D arrays will be wrong:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np
nrow, ncol = 2, 69900
rows = np.random.normal(size=(nrow, 1)).astype(np.float32)
columns = np.random.normal(size=(1, ncol)).astype(np.float32)
np_outer = rows.dot(columns)
ind0, ind1 = 0, 69818
print(np_outer[ind0, ind1], rows[ind0, 0]*columns[0, ind1])"><pre class="notranslate"><code class="notranslate">import numpy as np
nrow, ncol = 2, 69900
rows = np.random.normal(size=(nrow, 1)).astype(np.float32)
columns = np.random.normal(size=(1, ncol)).astype(np.float32)
np_outer = rows.dot(columns)
ind0, ind1 = 0, 69818
print(np_outer[ind0, ind1], rows[ind0, 0]*columns[0, ind1])
</code></pre></div>
<p dir="auto">Most entries are fine. In this example, only columns 69818-69899 in the product are wrong.</p>
<p dir="auto">This issue remains the same using <code class="notranslate">np.matmul(rows,columns)</code> and for different values of <code class="notranslate">nrow</code>. However it doesn't appear for an arbitrary values of <code class="notranslate">ncol</code>. There's a band of values around 69900 where errors appear, but there are none at 60000 or 70000. It's also not always the case that the last columns are the ones affected. For some values of <code class="notranslate">ncol</code>, there will be multiple bands of columns affected.</p>
<p dir="auto">I have not seen this behavior with float64 arrays. It also disappears if you do the dot product in transposed order:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" np_outer_t = columns.T.dot(rows.T).T
 print(np_outer_t[ind0, ind1], rows[ind0, 0]*columns[0, ind1])"><pre class="notranslate"><code class="notranslate"> np_outer_t = columns.T.dot(rows.T).T
 print(np_outer_t[ind0, ind1], rows[ind0, 0]*columns[0, ind1])
</code></pre></div>
<p dir="auto">System info: numpy 1.12.1, python 3.6.1, Macbook Pro, OS 10.6.1</p>