Using the scalar library

The MASS scalar library, libmass.a1, contains an accelerated set of frequently used math intrinsic functions in the Linux math library. When you compile programs with any of the following options:

the compiler automatically uses the faster MASS functions for all math library functions (with the exception of atan2, dnint, sqrt, rsqrt). In fact, the compiler first tries to "vectorize" calls to math library functions by replacing them with the equivalent MASS vector functions; if it cannot do so, it uses the MASS scalar functions. When the compiler performs this automatic replacement of math library functions, it uses versions of the MASS functions contained in the system library libxlopt.a; you do not need to add any special calls to the MASS functions in your code, or to link to the libxlopt library.
Notes:
  1. On Linux, 32-bit and 64-bit objects cannot be combined in the same library, so two versions of the scalar library are shipped with the compiler: libmass.a for 32-bit applications, and libmass_64.a for 64-bit applications.

If you are not using any of the optimization options listed above, and/or want to explicitly call the MASS scalar functions, you can do so by:

  1. Providing the prototypes for the functions (except dnint and rsqrt), by including math.h in your source files.
  2. Providing the prototypes for dnint and rsqrt, by including mass.h in your source files.
  3. Linking the MASS scalar library libmass.a (or the 64-bit version, libmass_64.a) 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, and are summarized in Table 16.

Table 16. MASS scalar functions
Function Description Prototype
sqrt Returns the square root of x double sqrt (double x);
rsqrt Returns the reciprocal of the square root of x double rsqrt (double x);
exp Returns the exponential function of x double exp (double x);
expm1 Returns (the exponential function of x) - 1 double expm1 (double x);
log Returns the natural logarithm of x double log (double x);
log1p Returns the natural logarithm of (x + 1) double log1p (double x);
sin Returns the sine of x double sin (double x);
cos Returns the cosine of x double cos (double x);
tan Returns the tangent of x double tan (double x);
atan Returns the arctangent of x double atan (double x);
atan2 Returns the arctangent of x/y double atan2 (double x, double y);
sinh Returns the hyperbolic sine of x double sinh (double x);
cosh Returns the hyperbolic cosine of x double cosh (double x);
tanh Returns the hyperbolic tangent of x double tanh (double x);
dnint Returns the nearest integer to x (as a double) double dnint (double x);
pow Returns x raised to the power y double pow (double x, double y);

The trigonometric functions (sin, cos, tan) return NaN (Not-a-Number) for large arguments (abs(x)>2**50*pi).

Note:
In some cases the MASS functions are not as accurate as the libm.a library, and they might handle edge cases differently (sqrt(Inf), for example).