Contents

vDSP_vgenp

Generates the single-precision linearly interpolated values of a vector at the specified indices.

Declaration

extern void vDSP_vgenp(const float *__A, vDSP_Stride __IA, const float *__B, vDSP_Stride __IB, float *__C, vDSP_Stride __IC, vDSP_Length __N, vDSP_Length __M);

Parameters

  • __A:

    The input vector that defines the values that the function interpolates.

  • __IA:

    The distance between the elements in the values vector.

  • __B:

    The input vector that defines the indices at which the function interpolates.

  • __IB:

    The distance between the elements in the indices vector.

  • __C:

    The output vector.

  • __IC:

    The distance between the elements in the output vector.

  • __N:

    The number of elements that the function processes.

  • __M:

    The number of elements in the values and indices input vectors.

Mentioned in

Discussion

The following code creates a five-element vector from two values using linear interpolation. The last index in indices determines the length of the operation result.

    let values: [Float] = [0, 100]
    let indices: [Float] = [0, 4]
    
    let n = Int(indices.last! + 1)
    let m = values.count
    
    let stride = 1
    
    let interpolatedValues = [Float](unsafeUninitializedCapacity: n) {
        buffer, initializedCount in
        
        vDSP_vgenp(values, stride,
                   indices, stride,
                   buffer.baseAddress!, stride,
                   vDSP_Length(n),
                   vDSP_Length(m))
        
        initializedCount = n
    }
    
    // Prints "[0.0, 25.0, 50.0, 75.0, 100.0]".
    print(interpolatedValues)

See Also

Vector generation by extrapolation and interpolation