[Numpy-discussion] Unexplained nans in matrix multiplication

Dag Sverre Seljebotn dagss@student.matnat.uio...
Thu Oct 29 08:39:44 CDT 2009


David Cournapeau wrote:
> On Thu, Oct 29, 2009 at 10:26 PM, Dag Sverre Seljebotn
> <dagss@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 ?
>   
Thanks.

Sage reports atlas-3.8.3.p7. Intel(R) Xeon(TM) CPU 3.20GHz, 64-bit 
RedHat Linux.

Dag Sverre


More information about the NumPy-Discussion mailing list