[Numpy-discussion] Apparently non-deterministic behaviour of complex array multiplication

kneil magnetotellurics at gmail.com
Mon Dec 5 23:50:37 EST 2011


Hi Nathaniel, 
Thanks for the suggestion.  I more or less implemented it:

        np.save('X',X);
        X2=np.load('X.npy')
        X2=np.asmatrix(X2)
        diffy = (X != X2)
        if diffy.any():
            print X[diffy]    
            print X2[diffy]
            print X[diffy][0].view(np.uint8)
            print X2[diffy][0].view(np.uint8)
        S=X*X.H/k
        S2=X2*X2.H/k      

        nanElts=find(isnan(S))
        if len(nanElts)!=0:  
            print 'WARNING: Nans in S:'+str(find(isnan(S)))
            print 'WARNING: Nans in S2:'+str(find(isnan(S2)))



My ouput, (when I got NaN) mostly indicated that both arrays are numerically
identical, and that they evaluated to have the same nan-value entries.  

For example
>>WARNING: Nans in S:[ 6 16]
>>WARNING: Nans in S2:[ 6 16]

Another time I got as output:

>>WARNING: Nans in S:[ 26  36  46  54  64  72  82  92 100 110 128 138 146
156 166 174 184 192
 202 212 220 230 240 250 260 268 278 279 296 297 306 314 324 334 335 342
 352 360 370 380 388 398 416 426 434 444 454 464 474]
>>WARNING: Nans in S2:[ 26  36  46  54  64  72  82  92 100 110 128 138 146
156 166 174 184 192
 202 212 220 230 240 250 260 268 278 279 296 297 306 314 324 334 335 342
 352 360 370 380 388 398 416 426 434 444 454 464 474]

These were different arrays I think.  At anyrate, those two results appeared
from two runs of the exact same code.  I do not use any random numbers in
the code by the way.  Most of the time the code runs without any nan showing
up at all, so this is an improvement. 

*I am pretty sure that one time there were nan in S, but not in S2, yet
still no difference was observed in the two matrices X and X2.  But, I did
not save that output, so I can't prove it to myself, ... but I am pretty
sure I saw that.

I will try and run memtest tonight.  I am going out of town for a week and
probably wont be able to test until next week.
cheers, 
Karl

I also think What was beyond w:
1. I have many less NaN than I used to, but still get NaN in S, 
but NOT in S2!



Nathaniel Smith wrote:
> 
> If save/load actually makes a reliable difference, then it would be useful
> to do something like this, and see what you see:
> 
> save("X", X)
> X2 = load("X.npy")
> diff = (X == X2)
> # did save/load change anything?
> any(diff)
> # if so, then what changed?
> X[diff]
> X2[diff]
> # any subtle differences in floating point representation?
> X[diff][0].view(np.uint8)
> X2[diff][0].view(np.uint8)
> 
> (You should still run memtest. It's very easy - just install it with your
> package manager, then reboot. Hold down the shift key while booting, and
> you'll get a boot menu. Choose memtest, and then leave it to run
> overnight.)
> 
> - Nathaniel
> On Dec 2, 2011 10:10 PM, "kneil" <magnetotellurics at gmail.com> wrote:
> 
> 

-- 
View this message in context: http://old.nabble.com/Apparently-non-deterministic-behaviour-of-complex-array-multiplication-tp32893004p32922174.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.




More information about the NumPy-Discussion mailing list