Generates a double-precision vector by extrapolation and interpolation.


func vDSP_vgenpD(_ __A: UnsafePointer<Double>, _ __IA: vDSP_Stride, _ __B: UnsafePointer<Double>, _ __IB: vDSP_Stride, _ __C: UnsafeMutablePointer<Double>, _ __IC: vDSP_Stride, _ __N: vDSP_Length, _ __M: vDSP_Length)



Double-precision real input vector.


Address stride for A.


Double-precision real input vector.


Address stride for B.


Double-precision real output vector.


Address stride for C.


Element count for C.


Element count for A and B.


The vDSP_vgenp(_:_:_:_:_:_:_:_:) and vDSP_vgenpD(_:_:_:_:_:_:_:_:) functions populate a vector, by linearly interpolating between a series of index-value pairs. The following pseudocode describes the calculation:

for (n = 0; n < N; ++n)
    If n <= B[0],  then C[n] = A[0].
    If B[M-1] < n, then C[n] = A[M-1].
        Let m be such that B[m] < n <= B[m+1].
        C[n] = A[m] + (A[m+1]-A[m]) * (n-B[m]) / (B[m+1]-B[m]).

The input vector A provides a series of values, and the input vector B provides the indices in the output vector, C, for the corresponding value in A. The indices must increase monotonically.

For example, the following code defines five value-index pairs:

let a: [Float] = [0, 0.25, 1, 0.25, 0]
let b: [Float] = [0, 256, 512, 768, 1024]

Passing these arrays to vDSP_vgenp(_:_:_:_:_:_:_:_:) populates the output array, c, with the linearly interpolated values:

let n = vDSP_Length(1024)

var c = [Float](repeating: 0,
                count: Int(n))

let stride = vDSP_Stride(1)

vDSP_vgenp(a, stride,
           b, stride,
           &c, stride,

The following illustrates the values of c:

Visualization of generated vector.

See Also

Vector Generation by Extrapolation and Interpolation

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