Function

vDSP_vgenD(_:_:_:_:_:)

Generates a double-precision, tapered-ramped vector.

Declaration

func vDSP_vgenD(_ __A: UnsafePointer<Double>, _ __B: UnsafePointer<Double>, _ __C: UnsafeMutablePointer<Double>, _ __IC: vDSP_Stride, _ __N: vDSP_Length)

Parameters

__A

Pointer to double-precision real input scalar: base value.

__B

Pointer to double-precision real input scalar: end value.

__C

Double-precision real output vector.

__IC

Address stride for C.

__N

The number of elements to process.

Discussion

The vDSP_vgenp(_:_:_:_:_:_:_:_:) and vDSP_vgenD(_:_:_:_:_:) functions populate a vector by linearly interpolating between the base and end-value parameters, using the following operation:

 for (n = 0; n < N; ++n)
    C[n] = A[0] + (B[0] - A[0]) * n/(N-1);

For example, the following code fills an array with the ramped values from 0 to 1024:

let n = vDSP_Length(1024)
let stride = vDSP_Stride(1)

var a: Float = 0
var b: Float = 1024

var c = [Float](repeating: 0,
                count: Int(n))

vDSP_vgen(&a,
          &b,
          &c,
          stride,
          n)

The following illustrates the values of c:

Visualization of generated vector.

See Also

Vector Generation with Tapered Ramps

static func ramp(in: ClosedRange<Double>, count: Int) -> [Double]

Returns a double-precision vector containing monotonically incrementing or decrementing values within a specified range.

static func ramp(in: ClosedRange<Float>, count: Int) -> [Float]

Returns a single-precision vector containing monotonically incrementing or decrementing values within a specified range.

static func formRamp<V>(in: ClosedRange<Double>, result: inout V)

Fills a double-precision vector with monotonically incrementing or decrementing values within a specified range.

static func formRamp<V>(in: ClosedRange<Float>, result: inout V)

Fills a single-precision vector with monotonically incrementing or decrementing values within a specified range.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software