Function

vDSP_vramp(_:_:_:_:_:)

Generates a single-precision ramped vector.

Declaration

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

Parameters

__A

Pointer to single-precision real input scalar: initial value.

__B

Pointer to single-precision real input scalar: increment (or decrement if negative).

__C

Single-precision real output vector.

__IC

Address stride for C.

__N

The number of elements to process.

Discussion

This vDSP_vramp(_:_:_:_:_:) and vDSP_vrampD(_:_:_:_:_:) functions populate a vector with monotonically incrementing or decrementing values using the following operation:

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

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

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

var a: Float = 0
var b: Float = 1

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

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

The following illustrates the values of c:

Graph illustrating an array filled with values starting at zero and linearly increasing to 1023.

See Also

Vector Generation with Ramps

static func ramp(withInitialValue: Double, increment: Double, count: Int) -> [Double]

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

static func ramp(withInitialValue: Float, increment: Float, count: Int) -> [Float]

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

static func formRamp<V>(withInitialValue: Double, increment: Double, result: inout V)

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

static func formRamp<V>(withInitialValue: Float, increment: Float, result: inout V)

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

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