Generic Type Method

# linearInterpolate(elementsOf:using:)

Returns the interpolation between the neighboring elements of a double-precision vector.

## Parameters

`vector`

An array that contains the values to interpolate.

`controlVector`

An array that defines the interpolation: integer parts are indices into `vector` and fractional parts are interpolation constants.

## Discussion

Single-precision and double-precision `linearInterpolate(elementsOf:using:)` functions return an array of an arbitrary length that's constructed from the linearly interpolated values in a source array. Pass `linearInterpolate(elementsOf:using:)` a control vector that defines the interpolation: the integer part of each element in the control vector is the zero-based index of the first element of a pair of adjacent values in the source array, and the fractional part defines the linear interpolation between the values at those indices.

For example, the following code generates a five-element vector by interpolating three values:

On return, `result` contains `[100.0, 150.0, 200.0, 250.0, 300.0]`.

To compute longer interpolation results, use `ramp(in:count:)` to generate the control vector. The following code creates 1024 interpolated values from 10 source values:

The following figure visualizes the elements in `result`.

By changing the technique used to form the fractional parts of the control vector, you change the interpolation between the values in the source vector. The following code uses a sigmoid function—that is, a function that has an "S" shaped curve—to populate the control vector:

The following figure visualizes the elements in `result` using hyperbolic tangent for the sigmoid function.

## See Also

### Single-Vector Linear Interpolation

Use Linear Interpolation to Construct New Data Points

Fill the gaps in arrays of numerical data using linear interpolation.

`static func linearInterpolate<T, U>(elementsOf: T, using: U) -> [Float]`

Returns the interpolation between the neighboring elements of a single-precision vector.

`static func linearInterpolate<T, U, V>(elementsOf: T, using: U, result: inout V)`

Calculates the interpolation between the neighboring elements of a double-precision vector.

`static func linearInterpolate<T, U, V>(elementsOf: T, using: U, result: inout V)`

Calculates the interpolation between the neighboring elements of a single-precision vector.

`func vDSP_vlint(UnsafePointer<Float>, UnsafePointer<Float>, vDSP_Stride, UnsafeMutablePointer<Float>, vDSP_Stride, vDSP_Length, vDSP_Length)`

Calculates the interpolation between the neighboring elements of a single-precision vector using the specified stride.

`func vDSP_vlintD(UnsafePointer<Double>, UnsafePointer<Double>, vDSP_Stride, UnsafeMutablePointer<Double>, vDSP_Stride, vDSP_Length, vDSP_Length)`

Calculates the interpolation between the neighboring elements of a double-precision vector using the specified stride.