Perform transcendental and trigonometric functions on vectors of any length.
v header file declares a set of trigonometric and transcendental functions in terms of C arrays (
double * or
float *), which can be of any length. Internally, the functions are vectorized for the current architecture.
The functions declared in
v have the customary mathematical names, but with the prefix "vv." Each mathematical function is available in two variants: one for single-precision floating-point data and one for double-precision data. The single-precision forms have the suffix "f," while the double-precision forms have no suffix. For example,
vvcosf is the single-precision cosine function, while
vvcos is the double-precision variant.
All of the vForce.h functions follow a common format:
The return type is
The first parameter points to an array to hold the results. (The only exceptions are
vvsincos(), which have two result arrays that the first two parameters point to.)
One or more parameters point to operand arrays that are the same length as the result array.
The last parameter is the array length.
vForce provides a high-performance alternative to
for loops and map(_:) when applying operations on arrays of floating-point values.
For example, given an arbitrarily sized array,
x, containing single-precision values, the following code uses
map(_:) to create a second array,
y, containing the square root of each array element.
The equivalent functionality implemented in vForce runs significantly faster: