[Numpy-discussion] dot product by 1*n maxtrix multiply it's transform not equal to raw python dot product?

Li Li fancyerii at gmail.com
Fri Feb 21 03:44:56 EST 2014


hi all
   I am porting some python code to java but got different results.
after long time debugging, I found the reason is numpy's result is not
the same as java(even the result of raw python codes)
  one case is:
  vector:[0.446141, 0.10414999999999996](that's not accurate)
  it's binary representation of IEEE754 is:
  0.446141:0011111111011100100011011001001011111011000110011110011100110010
  0.10419..:0011111110111010101010011001001100001011111000001101111011010000

  dot product by java(or raw python) of x1*x1+x2*x2 is:
  0.20988901438..(0011111111001010110111011010010010101010010001110010110101000011)
  but the result of pynum: x*x.T is:
  0011111111001010110111011010010010101010010001110010110101000010
  the last bit of mantissa is one difference.
  I don't floating points always hard to make sure to get same result
in different environment(not only hardware but also software such as
compiler optimizing and reordering)
  But I still want to know why, thanks.
  My environment:

Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.version.version
'1.6.1'



More information about the NumPy-Discussion mailing list