Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Fast exp()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fast exp()




Ian Ollmann wrote:


Accelerate.framework provides vector log and exp functionality. See vfp.h.


I just noticed that vecLib/vfp.h is a cornucopia of mathematical functions, not just exp and log. For example, the first three are


 vdivf      C = A ÷ B
 vsqrtf     B = √A
 vrsqrtf    B = 1/√A

In an earlier thread "Fast atan2" I sought, with partial success, a version of atan2 to meet certain speed and accuracy reqirements. Nobody mentioned vfp.h, but a look at that header file reveals a full suite of trig and inverse functions, including

 vatan2f  Computes the arc tangent of y/x in [-pi,pi] using
          the sign of both arguments to determine the
          quadrant of the computed value.

A good first step when looking for AltiVec math functions would be to read vecLib/vfp.h. All functions are AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER. You can even call them from a CFM application merely by linking to vecLib.



New for Tiger is a faster one that operates on long arrays, part of vForce.


vForce could use some better advertising, too :-)

In OS X 10.4 vecLib/vForce.h is a well-chosen set of math array functions, each being supplied in float and double forms. AltiVec is used internally by the float forms. The functions are array versions of the "the top 20 singles" from fp.h, with a few handy extras. A sample:

/* Set z[i] to y[i]/x[i], for i=0,..,n-1 */
void vvdivf (...);
void vvdiv  (...);

/* Set y[i] to the exponential function of x[i], for i=0,..,n-1 */
void vvexpf (...);
void vvexp  (...);

/* Set z[i] to the arctangent of y[i]/x[i], for i=0,..,n-1 */
void vvatan2f (...);
void vvatan2  (...);


Neither vatan2f nor vvatan2f can be found in Documentation API searches in Xcode 2, hence the need for more publicity...


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: 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 © 2011 Apple Inc. All rights reserved.