Man Page libmvec.3m
NAME
libmvec - vector versions of some elementary mathematical
functions
SYNOPSIS
cc [ flag ... ] file ... -lmvec [ library ... ]
or
cc [ flag ... ] file ... -lmvec_mt [ library ... ]
void vatan_(int *n, double *x, int *stridex, double *y, int
*stridey);
void vatan2_(int *n, double *y, int *stridey, double *x, int
*stridex, double *z, int *stridez);
void vcos_(int *n, double *x, int *stridex, double *y, int
*stridey);
void vexp_(int *n, double *x, int *stridex, double *y, int
*stridey);
void vhypot_(int *n, double *x, int *stridex, double *y, int
*stridey, double *z, int *stridez);
void vlog_(int *n, double *x, int *stridex, double *y, int
*stridey);
void vpow_(int *n, double *x, int *stridex, double *y, int
*stridey, double *z, int *stridez);
void vrsqrt_(int *n, double *x, int *stridex, double *y, int
*stridey);
void vsin_(int *n, double *x, int *stridex, double *y, int
*stridey);
void vsincos_(int *n, double *x, int *stridex, double *s,
int *strides, double *c, int *stridec);
void vsqrt_(int *n, double *x, int *stridex, double *y, int
*stridey);
void vatanf_(int *n, float *x, int *stridex, float *y, int
*stridey);
void vatan2f_(int *n, float *y, int *stridey, float *x, int
*stridex, float *z, int *stridez);
void vcosf_(int *n, float *x, int *stridex, float *y, int
*stridey);
void vexpf_(int *n, float *x, int *stridex, float *y, int
*stridey);
void vhypotf_(int *n, float *x, int *stridex, float *y, int
*stridey, float *z, int *stridez);
void vlogf_(int *n, float *x, int *stridex, float *y, int
*stridey);
void vpowf_(int *n, float *x, int *stridex, float *y, int
*stridey, float *z, int *stridez);
void vrsqrtf_(int *n, float *x, int *stridex, float *y, int
*stridey);
void vsinf_(int *n, float *x, int *stridex, float *y, int
*stridey);
void vsincosf_(int *n, float *x, int *stridex, float *s, int
*strides, float *c, int *stridec);
void vsqrtf_(int *n, float *x, int *stridex, float *y, int
*stridey);
DESCRIPTION
These routines evaluate common elementary functions for an
entire vector of values at once. The first parameter indi-
cates the number of values to compute. Subsequent parame-
ters specify the argument and result vectors. Each vector
is described by a pointer to the first element and a stride,
which is the increment between successive elements. For
brevity in the descriptions that follow, *stridex will be
denoted sx and similarly for *stridey, *stridez, etc.
vatan_(n, x, stridex, y, stridey) computes y[i*sy] =
atan(x[i*sx]) for each i = 0, 1, ..., *n - 1. Analogous
descriptions apply to vcos_, vexp_, vlog_, vsin_ and vsqrt_.
vatan2_(n, y, stridey, x, stridex, z, stridez) computes
z[i*sz] = atan(y[i*sy] / x[i*sx]) using the signs of both
arguments to determine the quadrant in which the resulting
angle lies.
vhypot_(n, x, stridex, y, stridey, z, stridez) computes
z[i*sz] = sqrt(x[i*sx]**2 + y[i*sy]**2).
vpow_(n, x, stridex, y, stridey, z, stridez) computes
z[i*sz] = x[i*sx]**y[i*sy], i.e., x[i*sx] raised to the
power y[i*sy].
vrsqrt_(n, x, stridex, y, stridey) computes y[i*sy] = 1 /
sqrt(x[i*sx]) for each i = 0, 1, ..., *n - 1.
vsincos_(n, x, stridex, s, strides, c, stridec) simultane-
ously computes s[i*ss] = sin(x[i*sx]) and c[i*sc] =
cos(x[i*sx]).
The functions vatanf_, vatan2f_, vcosf_, vexpf_, vhypotf_,
vlogf_, vpowf_, vrsqrtf_, vsinf_, vsincosf_ and vsqrtf_ are
single precision versions of the double precision functions
listed above.
For each function, the element count *n must be greater than
zero. The strides for the argument and result arrays may be
arbitrary integers, but the arrays themselves must not be
the same or overlap. For example, the results of the code
fragment
double x[100];
int n = 100, s = 1;
/*...*/
vexp_(&n, x, &s, x, &s);
are undefined. Note that a zero stride may be specified,
which effectively collapses the entire vector into a single
element. Thus, for example, one can use vpow_ to compute
values of x[i]**y for a fixed value of y by specifying
*stridey = 0. Finally, note that a stride may be negative,
but the corresponding pointer must still point to the first
element of the vector to be used; if the stride is negative,
this will be the highest-addressed element in memory. (This
convention differs from the Level 1 BLAS, in which array
parameters always refer to the lowest-addressed element in
memory even when negative increments are used.)
ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
_______________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE|
|____________________|_________________|
| Availability | SPROlang |
| Interface Stability| Evolving |
| MT-Level | MT-Safe |
|____________________|_________________|
SEE ALSO
atan(3M), atan2(3M), clibmvec(3M), cos(3M), exp(3M),
hypot(3M), log(3M), pow(3M), sin(3M), trig_sun(3M), attri-
butes(5)
DIAGNOSTICS
The vector functions treat exceptional cases in the spirit
of IEEE 754, producing essentially the same results as the
corresponding scalar functions in Fortran and in C when the
-xlibmieee option is used. (See the manual pages for the
scalar functions for their behavior on exceptional cases.)
Some vector functions may raise the inexact exception even
if all elements of the argument array are such that the
numerical results are exact.
NOTES
The vector functions listed above are provided in each of
two libraries, libmvec.a and libmvec_mt.a. The latter con-
tains parallelized versions of the functions that work in
conjunction with the automatic parallelization provided by
the compiler. To use libmvec_mt.a, you must link with one
of the parallelization options -xparallel, -xexplicitpar, or
-xautopar.
In vector and parallel execution, elements need not be pro-
cessed in the natural order x[0], x[1*sx], x[2*sx], etc.
Therefore, exceptions that occur may not be raised in order.
For example, if exp(x[1]) would raise the overflow excep-
tion, and exp(x[9]) would raise the invalid operation excep-
tion, there is no guarantee that a call to vexp_ will indi-
cate the overflow first.
The vector functions vsqrt_ and vsqrtf_, unlike their scalar
counterpart, may not produce correctly rounded results. How-
ever, the error in each result is less than one unit in the
last place.