Using the scalar library
The MASS scalar library libmass.a contains an accelerated set of frequently used math intrinsic functions that provide improved performance over the corresponding standard system library functions. The MASS scalar functions are used when explicitly linking libmass.a.
If you want to explicitly call the
MASS scalar functions, you can take the following steps:
- Provide the prototypes for the functions by including math.h and mass.h in your source files.
- Link the MASS scalar library with your application. For instructions, see Compiling and linking a program with MASS.
The MASS scalar functions accept double-precision parameters and return a double-precision result, or accept single-precision parameters and return a single-precision result, except sincos which gives 2 double-precision results. They are summarized in Table 1.
Double-precision function | Single-precision function | Description | Double-precision function prototype | Single-precision function prototype |
---|---|---|---|---|
acos | acosf | Returns the arccosine of x | double acos (double x); | float acosf (float x); |
acosh | acoshf | Returns the hyperbolic arccosine of x | double acosh (double x); | float acoshf (float x); |
anint | Returns the rounded integer value of x | float anint (float x); | ||
asin | asinf | Returns the arcsine of x | double asin (double x); | float asinf (float x); |
asinh | asinhf | Returns the hyperbolic arcsine of x | double asinh (double x); | float asinhf (float x); |
atan2 | atan2f | Returns the arctangent of x/y | double atan2 (double x, double y); | float atan2f (float x, float y); |
atan | atanf | Returns the arctangent of x | double atan (double x); | float atanf (float x); |
atanh | atanhf | Returns the hyperbolic arctangent of x | double atanh (double x); | float atanhf (float x); |
cbrt | cbrtf | Returns the cube root of x | double cbrt (double x); | float cbrtf (float x); |
copysign | copysignf | Returns x with the sign of y | double copysign (double x,double y); | float copysignf (float x); |
cos | cosf | Returns the cosine of x | double cos (double x); | float cosf (float x); |
cosh | coshf | Returns the hyperbolic cosine of x | double cosh (double x); | float coshf (float x); |
cosisin | Returns a complex number with the real part the cosine of x and the imaginary part the sine of x. | double_Complex cosisin (double); | ||
dnint | Returns the nearest integer to x (as a double) | double dnint (double x); | ||
erf | erff | Returns the error function of x | double erf (double x); | float erff (float x); |
erfc | erfcf | Returns the complementary error function of x | double erfc (double x); | float erfcf (float x); |
exp | expf | Returns the exponential function of x | double exp (double x); | float expf (float x); |
expm1 | expm1f | Returns (the exponential function of x) - 1 | double expm1 (double x); | float expm1f (float x); |
hypot | hypotf | Returns the square root of x2 + y2 | double hypot (double x, double y); | float hypotf (float x, float y); |
lgamma | lgammaf | Returns the natural logarithm of the absolute value of the Gamma function of x | double lgamma (double x); | float lgammaf (float x); |
log | logf | Returns the natural logarithm of x | double log (double x); | float logf (float x); |
log10 | log10f | Returns the base 10 logarithm of x | double log10 (double x); | float log10f (float x); |
log1p | log1pf | Returns the natural logarithm of (x + 1) | double log1p (double x); | float log1pf (float x); |
pow | powf | Returns x raised to the power y | double pow (double x, double y); | float powf (float x, float y); |
rsqrt | Returns the reciprocal of the square root of x | double rsqrt (double x); | ||
sin | sinf | Returns the sine of x | double sin (double x); | float sinf (float x); |
sincos | Sets *s to the sine of x and *c to the cosine of x | void sincos (double x, double* s, double* c); | ||
sinh | sinhf | Returns the hyperbolic sine of x | double sinh (double x); | float sinhf (float x); |
sqrt | Returns the square root of x | double sqrt (double x); | ||
tan | tanf | Returns the tangent of x | double tan (double x); | float tanf (float x); |
tanh | tanhf | Returns the hyperbolic tangent of x | double tanh (double x); | float tanhf (float x); |
Notes:
- The trigonometric functions (sin, cos, tan) return NaN (Not-a-Number) for large arguments (where the absolute value is greater than 250pi).
- In some cases, the MASS functions are not as accurate as the ones in the libm.a library, and they might handle edge cases differently (sqrt(Inf), for example).
- For accuracy comparisons with libm.a, see Product documentation (manuals) in the Product support content section of the Mathematical Acceleration Subsystem website.