Chris Radek wrote: >On Sat, Dec 13, 2008 at 10:14:04PM -0600, Stuart Stevenson wrote: > > >>Gentlemen, >> which style of computation would run faster in the kinematics file? >> >> > >If they are equivalent (and I sure as heck didn't check that), > I didn't check for correctness either. I did notice one thing that seems like a bad choice, but it may be intentional:
... va2=atan(-bskew1) .... va8=va7*tan(va2) ... since tan(atan(x)) should equal x, it seems you should be able to just use "va8=-va7*bskew1". >it >will make little difference whether you split it up like #1 or have >huge statements like #2. The compiler will do approximately the same >work > I was in the middle of writing a similar statement, with some general instructions on writing a test program, when I decided to just write the test program instead :) I found that the first version runs 1,000,000 loops in about 0.5 seconds (on a 2.2 GHz Core 2 Duo), whereas the second takes about 2 seconds. By making my own "sqr" function, that was cut down to about 1.5 seconds (this surprised me because I would have expected common subexpression elimination to work there, but I suppose gcc can't know if any of the called math functions save some state and may therefore return different values from call to call). >. The only concern is which one you can understand better when >you (or some other unlucky person?) come back to it later. > > That is a big concern, and the code runs pretty fast anyway. Like I said, my 2.2GHz CPU can run the slower version 500,000 to 750,000 times a second, so even a 500 MHz CPU, that's not as well optimized for math, should be able to do it 100,000 times a second (or about 100 times as often as necessary) - Steve ------------------------------------------------------------------------------ SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users