Hi, Am 14.08.2008 um 19:48 schrieb Alok Singhal:
> On 14/08/08: 10:20, Keith Goodman wrote: >> A unit test is attached. It contains three tests: >> >> In test1, I construct matrices x and y and then repeatedly >> calculate z >> = calc(x,y). The result z is the same every time. So this test >> passes. >> >> In test2, I construct matrices x and y each time before calculating z >> = calc(x,y). Sometimes z is slightly different. But the x's test to >> be >> equal and so do the y's. This test fails (on Debian Lenny, Core 2 >> Duo, >> with libatlas3gf-sse2 but not with libatlas3gf-sse). >> >> test3 is the same as test2 but I calculate z like this: z = >> calc(100*x,y) / (100 * 100). This test passes. >> >> I get: >> >> = >> ===================================================================== >> FAIL: repeatability #2 >> ---------------------------------------------------------------------- >> Traceback (most recent call last): >> File "/home/[snip]/test/repeat_test.py", line 73, in test_repeat_2 >> self.assert_(result, msg) >> AssertionError: Max difference = 2.04946e-16 > > Could this be because of how the calculations are done? If the > floating point numbers are stored in the cpu registers, in this case > (intel core duo), they are 80-bit values, whereas 'double' precision > is 64-bits. Depending upon gcc's optimization settings, the amount of > automatic variables, etc., it is entirely possible that the numbers > are stored in registers only in some cases, and are in the RAM in > other cases. Thus, in your tests, sometimes some numbers get stored > in the cpu registers, making the calculations with those values > different from the case if they were not stored in the registers. The tests never fail on my CoreDuo 2 on MacOS X, just for the records ;) Holger _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion