---
title: "linearInterpolate(_:_:using:result:)"
framework: accelerate
role: symbol
role_heading: Type Method
path: "accelerate/vdsp/linearinterpolate(_:_:using:result:)-55avl"
---

# linearInterpolate(_:_:using:result:)

Calculates the linear interpolation between the supplied single-precision vectors.

## Declaration

```swift
static func linearInterpolate<T, U, V>(_ vectorA: T, _ vectorB: U, using interpolationConstant: Float, result: inout V) where T : AccelerateBuffer, U : AccelerateBuffer, V : AccelerateMutableBuffer, T.Element == Float, U.Element == Float, V.Element == Float
```

## Discussion

Discussion Single-precision and double-precision linearInterpolate(_:_:using:result:) functions calculate a vector that’s the element-wise linear interpolation between the two supplied vectors. For example, the following code creates two arrays, vectorA and vectorB, that contain sine waves: let n = 1024

let vectorA: [Float] = (0 ... n).map {     return 2 + sin(Float($0) * 0.07) }

let vectorB: [Float] = (0 ... n).map {     return -2 + sin(Float($0) * 0.03) } Use linearInterpolate(_:_:using:) with an interpolation constant of 0.5 to generate a new vector that’s the average of the two sine waves: let result = vDSP.linearInterpolate(vectorA, vectorB,                                     using: 0.5) The following figure visualizes the two source vectors: the blue lines at the top and bottom, and the interpolation result: the red line in the center:

## See Also

### Vector-to-Vector Linear Interpolation

- [linearInterpolate(_:_:using:)](accelerate/vdsp/linearinterpolate(_:_:using:)-3j5d2.md)
- [linearInterpolate(_:_:using:)](accelerate/vdsp/linearinterpolate(_:_:using:)-71as1.md)
- [linearInterpolate(_:_:using:result:)](accelerate/vdsp/linearinterpolate(_:_:using:result:)-6o7a9.md)
