Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fast atan2




On Jan 25, 2005, at 4:50 PM, Robert Purves wrote:

Ben Weiss <email@hidden> wrote:
http://www.shellandslate.com/computermath101.html
Ben
Thanks. I tried it, and (after some translation for gcc) found that
the atan2 replacement has good accuracy but is little if any faster
than the library atan2.
Hmm... well, thank you for giving it a try. The benchmarks for this
code were done four years ago, with CodeWarrior under OS9, and it was
tuned for the early G4, which may account for your speed observations.
(Library atan2 has no doubt improved as well.) Are you on G4 or G5, and
single or double precision?
I compared OS X 10.3.6 atan2( y, x ) with the single version of your function atan2r_.
In converting your CW code to gcc, one line caused many cold beers and hot coffees to be consumed:
real32* asbuf = (real32*)(address(atanbuf_) + ind);
before an (int) cast emerged as a correct conversion:
real32* asbuf = (real32*)((int)&atanbuf_ + ind);



It should be noted that this code will break ppc64. Use intptr_t instead:


#include <stdint.h>
 real32* asbuf = (real32*)((intptr_t)&atanbuf_ + ind);

or just convert to uint8_t* and back

 real32* asbuf = (real32*)((uint8_t*)&atanbuf_ + ind);

Ian
_______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Fast atan2 (From: Robert Purves <email@hidden>)
 >Re: Fast atan2 (From: Shaun Wexler <email@hidden>)
 >Re: Fast atan2 (From: Robert Purves <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.