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




Ian Ollman wrote:

It probably should be mentioned at this point (before the inquest
starts) that the reason why libm is the way it is is several fold:

1) libm is required to deliver correct results (not sorta correct)
including edge cases, with the correct rounding mode, exceptions, etc.
This is expensive because it involves configuring the FPSCR
and often quite a bit of branching to deal with edge cases not covered
by the general purpose algorithm.

And how! The Darwin source libm-test.c includes the torture tests that the libm/libmx atan2 has presumably passed. Here's a small extract:


  /* atan2 (0,x) == 0 for x > 0.  */
  check_float ("atan2 (0, 1) == 0",  FUNC(atan2) (0, 1), 0, 0, 0, 0);

/* atan2 (-0,x) == -0 for x > 0. */
check_float ("atan2 (-0, 1) == -0", FUNC(atan2) (minus_zero, 1), minus_zero, 0, 0, 0);


check_float ("atan2 (0, 0) == 0", FUNC(atan2) (0, 0), 0, 0, 0, 0);
check_float ("atan2 (-0, 0) == -0", FUNC(atan2) (minus_zero, 0), minus_zero, 0, 0, 0);


/* atan2 (+0,x) == +pi for x < 0. */
check_float ("atan2 (0, -1) == pi", FUNC(atan2) (0, -1), M_PIl, 0, 0, 0);


/* atan2 (-0,x) == -pi for x < 0. */
check_float ("atan2 (-0, -1) == -pi", FUNC(atan2) (minus_zero, -1), -M_PIl, 0, 0, 0);


There's also a delightful disclaimer:

   Beware: The tests might fail for any of the following reasons:
   - Tests are wrong
   - Functions are wrong
   - Floating Point Unit not working properly
   - Compiler has errors

Robert P.

_______________________________________________
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


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.