Doh! The NaNs strike again. --bb
On Sun, Nov 23, 2008 at 3:40 PM, Tom S <[EMAIL PROTECTED]> wrote: > Don wrote: >> >> bearophile wrote: >>> >>> While writing code that works on matrices I have found something >>> curious... >> >> Here's what I think is going on. AFAIK, D hasn't got any special code for >> initializing jagged arrays. So >> auto A = new double[][](N, N); >> involves N+1 memory allocations. >> As well as being slow, this is going to give horrible locality of >> reference in the memory allocation. You'll suffer cache misses on almost >> every array access! >> >> I don't think this has anything to do with bounds checking. > > Nah, it's about NaNs :) > > Version #1 initializes C to NaN, Version #2 initializes it to 0. The 'init > mats randomly' loop doesn't touch C at all, thus all the latter additions > leave C at NaN, causing lots of FP exceptions. > > We actually had something like this happen in Deadlock a few times in the > animation subsystem. Brought the framerate down to a single digit :D > > > -- > Tomasz Stachowiak > http://h3.team0xf.com/ > h3/h3r3tic on #D freenode >
