<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vDSP/linearInterpolate(values:atIndices:result:)-7nre0",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4vDSPO17linearInterpolate6values9atIndices6resultyx_q_q0_ztAA0A6BufferRzAaHR_AA0a7MutableI0R0_Sd7ElementRtzSdAJRt_SdAJRt0_r1_lFZ"
  },
  "title" : "linearInterpolate(values:atIndices:result:)"
}
-->

# linearInterpolate(values:atIndices:result:)

Computes the double-precision linearly interpolated values of a vector at the specified indices.

```
static func linearInterpolate<T, U, V>(values: T, atIndices indices: U, result: inout V) where T : AccelerateBuffer, U : AccelerateBuffer, V : AccelerateMutableBuffer, T.Element == Double, U.Element == Double, V.Element == Double
```

## Parameters

`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.

```swift
let values: [Double] = [0, 100]
let indices: [Double] = [0, 4]

let count = Int(indices.last!) + 1

let result = [Double](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)
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)