Generates a double-precision vector, by interpolating values from a lookup table.


func vDSP_vtabiD(_ __A: UnsafePointer<Double>, _ __IA: vDSP_Stride, _ __S1: UnsafePointer<Double>, _ __S2: UnsafePointer<Double>, _ __C: UnsafePointer<Double>, _ __M: vDSP_Length, _ __D: UnsafeMutablePointer<Double>, _ __ID: vDSP_Stride, _ __N: vDSP_Length)



Single-precision real input vector.


Address stride for A.


Pointer to double-precision real input scalar: scale factor.


Pointer to double-precision real input scalar: base offset.


Double-precision real input vector: lookup table.


Lookup table size.


Double-precision real output vector.


Stride for D


The number of elements to write to D.


The vDSP_vtabi(_:_:_:_:_:_:_:_:_:) and vDSP_vtabiD(_:_:_:_:_:_:_:_:_:) functions populate a vector, using values from the lookup table, C, based on the offsets from vector A. The functions use linear interpolation to compute output values when an offset isn’t an integer. The following code describes the calculation:

for (n = 0; n < N; ++n)
    p = S1[0] * A[n] + S2[0];
    if (p < 0)
        D[n] = C[0];
    else if (p < M-1)
        q = trunc(p);
        r = p-q;
        D[n] = (1-r)*C[q] + r*C[q+1];
        D[n] = C[M-1];

Parameters S1 and S2 map the anticipated range of input values to the range of the lookup table and are typically assigned values such that:

floor(S1 * minimum input value + S2) = 0
floor(S1 * maximum input value + S2) = M-1

The following code shows a simple lookup table that contains a series of nine square numbers:

let c: [Float] = [1, 4, 9,
                  16, 25, 36,
                  49, 64, 81]

In this example, vDSP_vgen(_:_:_:_:_:) populates the offsets array. The offsets are a ramp of 1024 values, starting at zero and ending at the lookup table’s count minus one:

let n = vDSP_Length(1024)
let stride = vDSP_Stride(1)

var a =  [Float](repeating: 0,
                 count: Int(n))
var base: Float = 0
var end = Float(c.count) - 1

Calling vDSP_vtabi(_:_:_:_:_:_:_:_:_:) populates the output array, d, with the interpolated values from the lookup table:

var s1: Float = 1.0             // Scale.
var s2: Float = 0.0             // Offset.

let m = vDSP_Length(c.count)    // Lookup table size.
var d = [Float](repeating: 0,
                count: Int(n))  // Destination


The following illustrates the values of d:

Visualization of generated vector.

See Also

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software