[Numpy-discussion] Unexplained nans in matrix multiplication

David Cournapeau cournape at gmail.com
Thu Oct 29 09:31:26 EDT 2009


On Thu, Oct 29, 2009 at 10:26 PM, Dag Sverre Seljebotn
<dagss at student.matnat.uio.no> wrote:
> I'm getting (to me( very mysterious NaNs when doing matrix
> multiplication with certain (randomly generated) data:
>
> In [52]: a.shape, b.shape, i, j
> Out[52]: ((22, 1000), (1000, 22), 0, 16)
>
> In [53]: np.dot(a, b)[i,j]
> Out[53]: (31.322778824758661+nan*j)
>
> In [54]: np.dot(a[i,:], b[:,j])
> Out[54]: (31.322778824758657+6.5017268607881213j)
>
> In [55]: np.any(np.isnan(a)), np.any(np.isnan(b))
> Out[55]: (False, False)
>
> In [63]: np.max(np.abs(np.vstack((a.real, a.imag, b.real.T, b.imag.T))))
> Out[63]: 4.0744710639852633
>
> dtype is complex128. Is this a bug? Should I start looking in NumPy,
> ATLAS (Sage-compiled), the C compiler, the Fortran compiler...*shrug*

Most likely an atlas bug. Which version of atlas are you using, on which cpu ?

David



More information about the NumPy-Discussion mailing list