vecLib Reference

Framework
Declared in
vForce.h
vecLibTypes.h
vfp.h

Overview

The vecLib framework contains nine C header files (not counting vecLib.h which merely includes the others). Two of them, vDSP.h and vDSP_translate.h, are covered in vDSP Programming Guide and vDSP Reference.

Three of the header files are Apple’s versions of well-known libraries which are described in detail in external references:

This document describes the functions declared in the remaining header files: vecLibTypes.h, vfp.h, vForce.h, vBasicOps.h, vectorOps.h, and vBigNum.h. These files support the vector mathematical functions library (also called “vMathLib”), which runs on vector processing hardware (Altivec or SSE3) if available.

This library abstracts the vector processing capability so that code written for it will execute appropriate instructions for the processor available at runtime. For this reason, unless you are writing specialized code that targets a single CPU, you should generally use these functions rather than directly using vector instructions. By using these functions, your code does not have to deal with subtle differences in vector instruction availability between different microarchitectures, freeing you to focus on the problem you are trying to solve. Also, code written using vecLib tends to be easier to port to different CPU architectures (porting your core libraries to ARM on iOS, for example).

vecLibTypes.h

The vecLibTypes.h header file defines a set of vector data types (vFloat, vUInt32, etc.), which represent 128-bit vectors containing values of type float, UInt32, etc. The vBasicOps.h and vfp.h headers make use of these types.

The type names all begin with the letter “v,” followed by a mnemonic for the scalar data type used for elements of the vector. For example, vUInt32, vSInt16, vFloat, etc.

vBasicOps.h

vBasicOps.h declares a set of basic arithmetic and logical functions on 128-bit vectors, using the integer types from vecLibTypes.h.

The function names begin with “v,” followed by a mnemonic for the type of operation, e.g. “S” or “U” for signed or unsigned, then the width of the operation, then the name of the operation. For example, vS8Divide performs division of signed 8-bit values packed into 128-bit vectors.

vfp.h

vfp.h declares a set of floating-point arithmetic, transcendental and trigonometric functions, on 128-bit vectors, using the floating-point types from vecLibTypes.h.

These functions are named with their customary mathematical names, prefixed with the letter “v”, and all except vtablelookup() have the suffix “f” to indicate that they work with single-precision floating-point data. For example, vcosf is the single-precision cosine function.

vForce.h

vForce.h declares a set of trigonometric and transcendental functions in terms of C arrays (double * or float *), which can be of any desired length. Internally, the C arrays are converted piecewise into collections of 128-bit vectors, if appropriate for the current architecture.

The functions declared in vForce.h are named with 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 void.

  • The first parameter points to an array to hold the results. (The only exceptions are vvsincosf() and vvsincos(), which have two result arrays pointed to by the first two parameters.)

  • One or more parameters point to operand arrays, the same length as the result array.

  • The last parameter is the array length.

vectorOps.h

vectorOps.h declares a set of vector and matrix BLAS functions on arrays of 128-bit vectors containing single-precision floating-point values. The arrays can be of any desired length, but the number of float elements must be a multiple of 4.

vBigNum.h

vBigNum.h provides arithmetic and logical operations on large integers, which may be 128, 256, 512, or 1024 bits in length. It defines types for these values, and internally processes them as collections of 128-bit vectors.

vBigNum.h defines its own set of data types to represent large integer quantities, such as vS128 for a signed, 128-bit integer or vU1024 for an unsigned, 1024-bit integer. The function names begin with the data type name, followed by the name of the operation. For example, vS512Add performs addition of two 128-bit signed integers.

The functions perform logical and arithmetic operations on scalar values that may be 128, 256, 512, or 1024 bits in width. These values are implemented as structures of one, two, four, or eight 128-bit vectors, and the operations execute on the available vector-processing hardware if possible.

The functions have names that are compatible with those in vBasicOps.h.

Threading Model

In versions of vecLib prior to OS X v10.7, many vecLib routines used multiple POSIX threads to improve performance. In some cases, this could cause performance problems in applications that use large numbers of POSIX threads.

An application can limit the number of threads used by vecLib by setting the environment variable VECLIB_MAXIMUM_THREADS as follows:

 
    #include <stdlib.h>
 
    setenv("VECLIB_MAXIMUM_THREADS", "1", true);

To remove the limit, you can unset the environment variable as follows:

    unsetenv("VECLIB_MAXIMUM_THREADS");

In OS X v10.7, these routines use Grand Central Dispatch, so the use of this environment variable should no longer be necessary.

For More Information

For information about membership in Apple’s developer program, go to this URL:

http://developer.apple.com/membership/

For information about the Velocity Engine, go to this URL:

http://developer.apple.com/hardwaredrivers/ve/index.html

For general technical support from Apple, go to this URL:

http://developer.apple.com/technicalsupport/index.html

Functions by Task

Floating-Point Arithmetic and Auxiliary Functions (from vfp.h)

Exponential and Logarithmic Functions (from vfp.h)

Trigonometric Functions (from vfp.h)

Hyperbolic Functions (from vfp.h)

Power Functions (from vfp.h)

Remainder Functions (from vfp.h)

Inquiry Functions (from vfp.h)

Array-Oriented Arithmetic and Auxiliary Functions (from vForce.h)

Array-Oriented Exponential and Logarithmic Functions (from vForce.h)

Array-Oriented Power Functions (from vForce.h)

Array-Oriented Trigonometric Functions (from vForce.h)

Array-Oriented Hyperbolic Functions (from vForce.h)

Functions

vacosf

For each vector element, calculates the arccosine. Results are in the interval [0, pi].

vFloat vacosf (
   vFloat arg
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vacoshf

For each vector element, calculates the inverse hyperbolic cosine of X.

vFloat vacoshf (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vasinf

For each vector element, calculates the arcsine. Results are in the interval [-pi/2, pi/2].

vFloat vasinf (
   vFloat arg
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vasinhf

For each vector element, calculates the inverse hyperbolic sine of X.

vFloat vasinhf (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vatan2f

For each vector element, calculates the arctangent of arg2/arg1 in the interval [-pi,pi] using the sign of both arguments to determine the quadrant of the computed value.

vFloat vatan2f (
   vFloat arg1,
   vFloat arg2
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vatanf

For each vector element, calculates the arctangent. Results are in the interval [-pi/2, pi/2].

vFloat vatanf (
   vFloat arg
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vatanhf

For each vector element, calculates the inverse hyperbolic tangent of X.

vFloat vatanhf (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vceilf

Computes the ceiling of values in a vector of floating-point values.

vFloat vceilf (
   vFloat A
);
Parameters
A

The input vector.

Return Value

Returns a vector of floating-point values, each of which is the ceiling of the corresponding value in A.

Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vclassifyf

For each vector element, returns the class of the argument (one of the FP_ ... constants defined in math.h).

vUInt32 vclassifyf (
   vFloat arg
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vcopysignf

For each vector element, produces a value with the magnitude of arg2 and sign arg1. Note that the order of the arguments matches the recommendation of the IEEE 754 floating-point standard, which is opposite from the SANE copysign function.

vFloat vcopysignf (
   vFloat arg2,
   vFloat arg1
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vcosf

For each vector element, calculates the cosine.

vFloat vcosf (
   vFloat arg
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vcoshf

For each vector element, calculates the hyperbolic cosine of X.

vFloat vcoshf (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vdivf

For each vector element, calculates A/B.

vFloat vdivf (
   vFloat A,
   vFloat B
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vexpf

For each vector element, calculates the exponential of X.

vFloat vexpf (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vexpm1f

For each vector element, calculates ExpM1(x) = Exp(x) - 1. But, for small enough arguments, ExpM1(x) is expected to be more accurate than Exp(x) - 1.

vFloat vexpm1f (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vfloorf

Computes the floor of values in a vector of floating-point values.

vFloat vfloorf (
   vFloat A
);
Parameters
A

The input vector.

Return Value

Returns a vector of floating-point values, each of which is the floor of the corresponding value in A.

Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vfmodf

For each vector element, calculates X modulo Y.

vFloat vfmodf (
   vFloat X,
   vFloat Y
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vipowf

For each vector element, calculates X to the integer power of Y.

vFloat vipowf (
   vFloat X,
   vSInt32 Y
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vlog10f

Computes the base-10 logarithm of values in a vector.

vFloat vlog10f (
   vFloat X
);
Parameters
X

The source vector.

Return Value

Returns a vector of floating point values, each of which is the base-10 logarithm of the corresponding value in the source vector.

Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vlog1pf

For each vector element, calculates Log1P = Log(1 + x). But, for small enough arguments, Log1P is expected to be more accurate than Log(1 + x).

vFloat vlog1pf (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vlogbf

For each vector element, extracts the exponent of X, as a signed integral value. A subnormal argument is treated as though it were first normalized. Thus: 1 <= x * 2^(-logb(x)) < 2.

vFloat vlogbf (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vlogf

For each vector element, calculates the natural logarithm of X.

vFloat vlogf (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vnextafterf

For each vector element, calculates the next representable value after x in the direction of y. If x is equal to y, then y is returned.

vFloat vnextafterf (
   vFloat x,
   vFloat y
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vnintf

Rounds to the nearest integer (nearest even for ties).

vFloat vnintf (
   vFloat A
);
Parameters
A

The input vector.

Return Value

Returns a vector of floating-point values, each of which is the result of rounding the corresponding value in A to the nearest integer, with ties rounded to the nearest even integer.

Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vpowf

For each vector element, calculates X to the floating-point power of Y. The result is more accurate than using exp(log(X)*Y).

vFloat vpowf (
   vFloat X,
   vFloat Y
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vrecf

Computes the reciprocal of values in a vector.

vFloat vrecf (
   vFloat A
);
Parameters
A

The source vector

Return Value

Returns a vector containing the reciprocals of the values in the source vector.

Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vremainderf

For each vector element, calculates the remainder of X/Y, according to the IEEE 754 floating-point standard.

vFloat vremainderf (
   vFloat X,
   vFloat Y
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vremquof

For each vector element, calculates the remainder of X/Y, according to the SANE standard. It stores into QUO the 7 low-order bits of the integer quotient, such that -127 <= QUO <= 127.

vFloat vremquof (
   vFloat X,
   vFloat Y,
   vUInt32 *QUO
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vrsqrtf

For each vector element, calculates the inverse of the square root of X.

vFloat vrsqrtf (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vscalbf

For each vector element, calculates x * 2^n efficiently. This is not normally done by computing 2^n explicitly.

vFloat vscalbf (
   vFloat X,
   vSInt32 n
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vsignbitf

For each vector element, returns a non-zero value if and only if the sign of arg is negative. This includes NaNs, infinities and zeros.

vUInt32 vsignbitf (
   vFloat arg
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vsincosf

Simultaneously computes sine and cosine of values in a vector.

vFloat vsincosf (
   vFloat arg,
   vFloat *sine_result
);
Parameters
arg

The source vector.

sine_result

An output vector. On return, this contains the result of sin(x) for each value (x) in the source vector.

Return Value

Returns a vector that contains the result of cos(x) for each value (x) in the source vector.

Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vsinf

For each vector element, calculates the sine.

vFloat vsinf (
   vFloat arg
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vsinhf

For each vector element, calculates the hyperbolic sine of X.

vFloat vsinhf (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vsqrtf

For each vector element, calculates the square root of X.

vFloat vsqrtf (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vtablelookup

For each vector element of Index_Vect, returns the corresponding value from Table.

vUInt32 vtablelookup (
   vSInt32 Index_Vect,
   uint32_t *Table
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vtanf

For each vector element, calculates the tangent.

vFloat vtanf (
   vFloat arg
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vtanhf

For each vector element, calculates the hyperbolic tangent of X.

vFloat vtanhf (
   vFloat X
);
Availability
  • Available in iOS 6.0 and later.
Declared In
vfp.h

vvacos

For each double-precision array element, sets y to the arccosine of x.

void vvacos (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvacosf

For each single-precision array element, sets y to the arccosine of x.

void vvacosf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvacosh

For each double-precision array element, sets y to the inverse hyperbolic cosine of x.

void vvacosh (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvacoshf

For each single-precision array element, sets y to the inverse hyperbolic cosine of x.

void vvacoshf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvasin

For each double-precision array element, sets y to the arcsine of x.

void vvasin (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvasinf

For each single-precision array element, sets y to the arcsine of x.

void vvasinf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvasinh

For each double-precision array element, sets y to the inverse hyperbolic sine of x.

void vvasinh (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvasinhf

For each single-precision array element, sets y to the inverse hyperbolic sine of x.

void vvasinhf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvatan

For each double-precision array element, sets y to the arctangent of x.

void vvatan (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvatan2

For each double-precision array element, sets z to the arctangent of y/x.

void vvatan2 (
   double *,
   const double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvatan2f

For each single-precision array element, sets z to the arctangent of y/x.

void vvatan2f (
   float *,
   const float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvatanf

For each single-precision array element, sets y to the arctangent of x.

void vvatanf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvatanh

For each double-precision array element, sets y to the inverse hyperbolic tangent of x.

void vvatanh (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvatanhf

For each single-precision array element, sets y to the inverse hyperbolic tangent of x.

void vvatanhf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvceil

For each double-precision array element, sets y to the ceiling of x.

void vvceil (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvceilf

For each single-precision array element, sets y to the ceiling of x.

void vvceilf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvcopysign

Copies an array, setting the sign of each value based on a second array.

void vvcopysign (
   double *,
   double *,
   const double *,
   const int *
);
Parameters
z

The output array.

y

The magnitude input array.

x

The sign input array.

n

The address of an integer containing the number of elements to copy.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvcopysignf

Copies an array, setting the sign of each value based on a second array.

void vvcopysignf (
   float *,
   const float *,
   const float *,
   const int *
);
Parameters
result

Storage for the result. Modified on return.

signs

Array containing values with the desired signs.

float

Array containing values with the desired values.

int

The length of the arrays.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvcos

For each double-precision array element, sets y to the cosine of x.

void vvcos (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvcosf

For each single-precision array element, sets y to the cosine of x.

void vvcosf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvcosh

For each double-precision array element, sets y to the hyperbolic cosine of x.

void vvcosh (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvcoshf

For each single-precision array element, sets y to the hyperbolic cosine of x.

void vvcoshf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvcosisin

For each double-precision array element, sets the real part of C to the sine of x and the imaginary part of C to the cosine of x.

void vvcosisin (
   __double_complex_t *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvcosisinf

For each single-precision array element, sets the real part of C to the cosine of x and the imaginary part of C to the sine of x.

void vvcosisinf (
   __float_complex_t *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvcospi

Sets each element y[i] to the sin(pi * x[i]) for i in 0..n-1.

void vvcospi (
   double *,
   const double *,
   const int *
);
Parameters
y

An input array of double-precision floating point numbers

x

An output array of double-precision floating point numbers.

n

A pointer to an integer containing the number of floating point elements to set.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvcospif

Sets each element y[i] to the sin(pi * x[i]) for i in 0..n-1.

void vvcospif (
   float *,
   const float *,
   const int *
);
Parameters
y

An input array of single-precision floating point values.

x

An output array of single-precision floating point values.

n

A pointer to an integer containing the number of floating point elements to set.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvdiv

For each double-precision array element, sets z to y/x.

void vvdiv (
   double *,
   const double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvdivf

For each single-precision array element, sets z to y/x.

void vvdivf (
   float *,
   const float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvexp

For each double-precision array element, sets y to the exponential of x.

void vvexp (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvexp2

Sets each element y[i] to 2 raised to (x[i]) for i in 0..n-1.

void vvexp2 (
   double *,
   const double *,
   const int *
);
Parameters
y

An input array of double-precision floating point numbers

x

An output array of double-precision floating point numbers.

n

A pointer to an integer containing the number of floating point elements to set.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvexp2f

Sets each element y[i] to 2 raised to (x[i]) for i in 0..n-1.

void vvexp2f (
   float *,
   const float *,
   const int *
);
Parameters
y

An input array of single-precision floating point values.

x

An output array of single-precision floating point values.

n

A pointer to an integer containing the number of floating point elements to set.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvexpf

For each single-precision array element, sets y to the exponential of x.

void vvexpf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvexpm1

Returns (e^x)-1 for each element y[i].

void vvexpm1 (
   double *,
   const double *,
   const int *
);
Parameters
y

An input array of double-precision floating point numbers

x

An output array of double-precision floating point numbers.

n

A pointer to an integer containing the number of floating point elements to set.

Discussion

This is accurate for very small values of x[i].

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvexpm1f

Computes (e^x)-1 for each element in an array.

void vvexpm1f (
   float *,
   const float *,
   const int *
);
Parameters
result

An array, modified on return, where the results are stored.

src

The input array.

count

The number of values in the input and result arrays.

Discussion

Provides additional accuracy for values of x near -1.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvfabs

Sets each element y[i] to abs(x[i]-1) for i in 0..n-1.

void vvfabs (
   double *,
   const double *,
   const int *
);
Parameters
y

An input array of double-precision floating point numbers

x

An output array of double-precision floating point numbers.

n

A pointer to an integer containing the number of floating point elements to set.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvfabsf

Sets each element y[i] to abs(x[i]-1) for i in 0..n-1.

void vvfabsf (
   float *,
   const float *,
   const int *
);
Parameters
y

An input array of single-precision floating point values.

x

An output array of single-precision floating point values.

n

A pointer to an integer containing the number of floating point elements to set.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvfloor

For each double-precision array element, sets y to the floor of x.

void vvfloor (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvfloorf

For each single-precision array element, sets y to the floor of x.

void vvfloorf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvfmod

Sets each element y[i] to the floating point remainder of (y[i]/x[i]) for i in 0..n-1.

void vvfmod (
   double *,
   double *,
   const double *,
   const int *
);
Parameters
z

An output array of double-precision floating point numbers.

y

Numerator input array of double-precision floating point numbers.

x

Denominator input array of double-precision floating point numbers.

n

A pointer to an integer containing the number of floating point elements to set.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvfmodf

Computes the remainders after dividing values in a pair of arrays.

void vvfmodf (
   float *,
   const float *,
   const float *,
   const int *
);
Parameters
result

An array, modified on return, where the results are stored.

divisors

An array of divisors.

dividends

An array of dividends.

count

The number of values in the input and result arrays.

Discussion

On return, the result array contains the remainders after calculating dividend[i] / divisor[i] for each value of i from 0 through count-1.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvint

For each double-precision array element, sets y to the integer truncation of x.

void vvint (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvintf

For each single-precision array element, sets y to the integer truncation of x.

void vvintf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvlog

For each double-precision array element, sets y to the natural logarithm of x.

void vvlog (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvlog10

For each double-precision array element, sets y to the base 10 logarithm of x.

void vvlog10 (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvlog10f

For each single-precision array element, sets y to the base 10 logarithm of x.

void vvlog10f (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvlog1p

Sets each element y[i] to log(1+x[i]) for i in 0..n-1.

void vvlog1p (
   double *,
   const double *,
   const int *
);
Parameters
y

An output array of double-precision floating point numbers.

x

An input array of double-precision floating point numbers.

n

A pointer to an integer containing the number of floating point elements to set.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvlog1pf

Computes the natural logarithm of a value plus 1.

void vvlog1pf (
   float *,
   const float *,
   const int *
);
Parameters
results

An array where results are stored on return.

values

The source array.

count

A pointer to an integer containing the number of elements to process.

Discussion

This algorithm computes

log(1+x)

for each element x in the source array.

This algorithm is tuned to provide increased accuracy for values of x near 1.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvlog2

Sets each element y[i] to the base-2 logarithm of x[i] for i in 0..n-1.

void vvlog2 (
   double *,
   const double *,
   const int *
);
Parameters
y

An output array of double-precision floating point numbers.

x

An input array of double-precision floating point numbers.

n

A pointer to an integer containing the number of floating point elements to set.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvlog2f

Sets each element y[i] to the base 2 logarithm of x[i] for i in 0..n-1.

void vvlog2f (
   float *,
   const float *,
   const int *
);
Parameters
y

An output array of single-precision floating point numbers.

x

An input array of single-precision floating point numbers.

n

A pointer to an integer containing the number of floating point elements to set.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvlogb

Sets each element y[i] to the exponent of x[i] for i in 0..n-1.

void vvlogb (
   double *,
   const double *,
   const int *
);
Parameters
y

An output array of double-precision floating point numbers.

x

An input array of double-precision floating point numbers.

n

A pointer to an integer containing the number of floating point elements to set.

Discussion

Floating point numbers are internally represented as a mantissa multiplied times a base raised to an exponent. That exponent is returned in the output array.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvlogbf

Sets each element y[i] to the exponent of x[i] for i in 0..n-1.

void vvlogbf (
   float *,
   const float *,
   const int *
);
Parameters
y

An array where results are stored on return.

x

The source array.

n

A pointer to an integer containing the number of elements to process.

Discussion

Floating point numbers are internally represented as a mantissa multiplied times a base raised to an exponent. That exponent is returned in the output array.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvlogf

For each single-precision array element, sets y to the natural logarithm of x.

void vvlogf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvnextafter

Sets each element z[i] to the next machine-representable value from y[i] towards x[i] for i in 0..n-1.

void vvnextafter (
   double *,
   double *,
   const double *,
   const int *
);
Parameters
z

An output array of double-precision floating point numbers.

y

An input array of double-precision floating point numbers.

x

An input array of double-precision floating point numbers.

n

A pointer to an integer containing the number of floating point elements to set.

Discussion

Not all values can be represented as a floating-point value of a given precision. This function sets a value in z[i] that is either minimally larger than the value in y[i] (if x[i] is larger than y[i]) or minimally smaller than the value in y[i] (if x[i] is smaller than y[i]).

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvnextafterf

Sets each element z[i] to the next machine-representable value from y[i] towards x[i] for i in 0..n-1.

void vvnextafterf (
   float *,
   const float *,
   const float *,
   const int *
);
Parameters
z

An array where results are stored on return.

y

An array of floating-point values providing the direction relative to x.

x

An array of floating-point values providing the starting point.

n

A pointer to an integer containing the number of elements to process.

Discussion

Not all values can be represented as a floating-point value of a given precision. This function sets a value in z[i] that is either minimally larger than the value in y[i] (if x[i] is larger than y[i]) or minimally smaller than the value in y[i] (if x[i] is smaller than y[i]).

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvnint

For each double-precision array element, sets y to the nearest integer to x.

void vvnint (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvnintf

For each single-precision array element, sets y to the nearest integer to x.

void vvnintf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvpow

For each double-precision array element, sets z to x raised to the power of y.

void vvpow (
   double *,
   const double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvpowf

For each single-precision array element, sets z to x raised to the power of y.

void vvpowf (
   float *,
   const float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvrec

For each double-precision array element, sets y to the reciprocal of y.

void vvrec (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvrecf

For each single-precision array element, sets y to the reciprocal of y.

void vvrecf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvremainder

Sets z[i] to the remainder relative to a round-to-even division of y[i]/x[i] for each i in 0..n-1.

void vvremainder (
   double *,
   double *,
   const double *,
   const int *
);
Parameters
z

An array for storing the results.

y

An array of divisors.

x

An array of dividends.

n

A pointer to an integer containing the number of elements to process.

Discussion

This function performs the equivalent of vnintf for each dividend/divisor pair, then multiplies the result by the divisor, and subtracts the result from the dividend.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvremainderf

Computes the remainder relative to a round-to-even division.

void vvremainderf (
   float *,
   const float *,
   const float *,
   const int *
);
Parameters
results

An array for storing the results.

divisors

An array of divisors.

dividends

An array of dividends.

count

A pointer to an integer containing the number of elements to process.

Discussion

This function performs the equivalent of vnintf for each dividend/divisor pair, then multiplies the result by the divisor, and subtracts the result from the dividend.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvrsqrt

For each double-precision array element, sets y to the reciprocal of the square root of x.

void vvrsqrt (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvrsqrtf

For each single-precision array element, sets y to the reciprocal of the square root of x.

void vvrsqrtf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvsin

For each double-precision array element, sets y to the sine of x.

void vvsin (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvsincos

For each double-precision array element, sets z to the sine of x and y to the cosine of x.

void vvsincos (
   double *,
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvsincosf

For each single-precision array element, sets z to the sine of x and y to the cosine of x.

void vvsincosf (
   float *,
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvsinf

For each single-precision array element, sets y to the sine of x.

void vvsinf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvsinh

For each double-precision array element, sets y to the hyperbolic sine of x.

void vvsinh (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvsinhf

For each single-precision array element, sets y to the hyperbolic sine of x.

void vvsinhf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvsinpi

Sets y[i] to sin(pi * x[i]) for i in 0..n-1.

void vvsinpi (
   double *,
   const double *,
   const int *
);
Parameters
y

An array where results are stored on return.

x

The source array.

n

A pointer to an integer containing the number of elements to process.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvsinpif

Sets y[i] to sin(pi * x[i]) for i in 0..n-1.

void vvsinpif (
   float *,
   const float *,
   const int *
);
Parameters
y

An array where results are stored on return.

x

The source array.

n

A pointer to an integer containing the number of elements to process.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvsqrt

For each double-precision array element, sets y to the square root of x.

void vvsqrt (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvsqrtf

For each single-precision array element, sets y to the square root of x.

void vvsqrtf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvtan

For each double-precision array element, sets y to the tangent of x.

void vvtan (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvtanf

For each single-precision array element, sets y to the tangent of x.

void vvtanf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvtanh

For each double-precision array element, sets y to the hyperbolic tangent of x.

void vvtanh (
   double *,
   const double *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvtanhf

For each single-precision array element, sets y to the hyperbolic tangent of x.

void vvtanhf (
   float *,
   const float *,
   const int *
);
Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvtanpi

Sets y[i] to tan(pi * x[i]) for i in 0..n-1.

void vvtanpi (
   double *,
   const double *,
   const int *
);
Parameters
y

An array where results are stored on return.

x

The source array.

n

A pointer to an integer containing the number of elements to process.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

vvtanpif

Sets y[i] to tan(pi * x[i]) for i in 0..n-1.

void vvtanpif (
   float *,
   const float *,
   const int *
);
Parameters
y

An array where results are stored on return.

x

The source array.

n

A pointer to an integer containing the number of elements to process.

Availability
  • Available in iOS 5.0 and later.
Declared In
vForce.h

Data Types

All data structures passed to vecLib must be naturally aligned. For example, a 32-bit floating-point value must be aligned to a four-byte boundary. Many routines in vecLib generate exceptions on unaligned data.

vUInt8

A 128-bit vector packed with unsigned char values.

typedef vector unsigned char vUInt8;
Availability
  • Available in iOS 4.0 and later.
Declared In
vecLibTypes.h

vSInt8

A 128-bit vector packed with signed char values.

typedef vector signed char vSInt8;
Availability
  • Available in iOS 4.0 and later.
Declared In
vecLibTypes.h

vUInt16

A 128-bit vector packed with unsigned short values.

typedef vector unsigned short vUInt16;
Availability
  • Available in iOS 4.0 and later.
Declared In
vecLibTypes.h

vSInt16

A 128-bit vector packed with signed short values.

typedef vector signed short vSInt16;
Availability
  • Available in iOS 4.0 and later.
Declared In
vecLibTypes.h

vUInt32

A 128-bit vector packed with unsigned int values.

typedef vector unsigned int vUInt32;
Availability
  • Available in iOS 4.0 and later.
Declared In
vecLibTypes.h

vSInt32

A 128-bit vector packed with signed int values.

typedef vector signed int vSInt32;
Availability
  • Available in iOS 4.0 and later.
Declared In
vecLibTypes.h

vUInt64

A 128-bit vector packed with uint64_t values.

typedef vector unsigned int vUInt64;
Availability
  • Available in iOS 7.0 and later.
Declared In
vecLibTypes.h

vSInt64

A 128-bit vector packed with int64_t values.

typedef vector signed int vSInt64;
Availability
  • Available in iOS 7.0 and later.
Declared In
vecLibTypes.h

vFloat

A 128-bit vector packed with float values.

typedef vector float vFloat;
Availability
  • Available in iOS 4.0 and later.
Declared In
vecLibTypes.h

vDouble

A 128-bit vector packed with double values.

typedef double vDouble         __attribute__((__vector_size__ (16)));

vBool32

A 128-bit vector packed with bool int values.

typedef vector bool int vBool32;
Availability
  • Available in iOS 4.0 and later.
Declared In
vecLibTypes.h

__float_complex_t

A single-precision complex number type.

typedef complex float __float_complex_t;
Declared In

__double_complex_t

A double-precision complex number type.

typedef complex double __double_complex_t;
Declared In