formRamp(withInitialValue:increment:result:)
Populates a double-precision vector with monotonically incrementing or decrementing values using an initial value and increment.
Declaration
static func formRamp<V>(withInitialValue initialValue: Double, increment: Double, result: inout V) where V : AccelerateMutableBuffer, V.Element == DoubleParameters
- initialValue:
The initial value of the ramp.
- increment:
The increment, or decrement if negative, between each generated element.
- result:
The array that receives the generated ramp.
Discussion
Use this function to generate and return a vector populated with ramped values.
The following code generates a ramped vector with values in the range 0 ... 7:
let n = 8
let ramp = [Double](unsafeUninitializedCapacity: n) {
buffer, initializedCount in
vDSP.formRamp(withInitialValue: 0,
increment: 1,
result: &buffer)
initializedCount = n
}
// Prints "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]".
print(ramp)