linearInterpolate(values:atIndices:result:)
Computes the single-precision linearly interpolated values of a vector at the specified indices.
Declaration
static func linearInterpolate<T, U, V>(values: T, atIndices indices: U, result: inout V) where T : AccelerateBuffer, U : AccelerateBuffer, V : AccelerateMutableBuffer, T.Element == Float, U.Element == Float, V.Element == FloatParameters
- values:
The values to interpolate.
- indices:
The indices to the output vector.
- result:
The destination vector that receives the result.
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 count = Int(indices.last!) + 1
let result = [Float](unsafeUninitializedCapacity: count) {
buffer, initializedCount in
vDSP.linearInterpolate(values: values,
atIndices: indices,
result: &buffer)
initializedCount = count
}
// Prints "[0.0, 25.0, 50.0, 75.0, 100.0]".
print(result)