<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vDSP/formRamp(withInitialValue:multiplyingBy:increment:result:)-p7s4",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4vDSPO8formRamp16withInitialValue13multiplyingBy9increment6resultySdz_xSdq_ztAA0A6BufferRzAA0a7MutableL0R_Sd7ElementRtzSdAKRt_r0_lFZ"
  },
  "title" : "formRamp(withInitialValue:multiplyingBy:increment:result:)"
}
-->

# formRamp(withInitialValue:multiplyingBy:increment:result:)

Populates a double-precision vector that contains monotonically incrementing or decrementing values, and multiplies that vector by a source vector.

```
static func formRamp<U, V>(withInitialValue initialValue: inout Double, multiplyingBy vector: U, increment: Double, result: inout V) where U : AccelerateBuffer, V : AccelerateMutableBuffer, U.Element == Double, V.Element == Double
```

## Parameters

`initialValue`

On input, the initial value of the ramp. On output, the next value in the ramp.

`vector`

The input vector that the function multiplies by the ramp.

`increment`

The increment, or decrement if negative, between each generated element.

`result`

The result.

## Discussion

Use this function to generate and return a vector populated with ramped values with each element multiplied by the corresponding element in a second vector.

The following code generates a ramped vector with values in the range `0 ... 7`. The function multiplies elements at even indices by `10` and multiplies elements at odd indices by `100`.

```swift
    let n = 8
    
    var initialValue: Double = 0
    let increment: Double = 1
    
    let ramp = [Double](unsafeUninitializedCapacity: n) {
        buffer, initializedCount in
        
        vDSP.formRamp(withInitialValue: &initialValue,
                      multiplyingBy: [10, 100, 10, 100, 10, 100, 10, 100],
                      increment: increment,
                      result: &buffer)
        
        initializedCount = n
    }
    
    // Prints "[0.0, 100.0, 20.0, 300.0, 40.0, 500.0, 60.0, 700.0]".
    print(ramp)
    
    // Prints "8".
    print(initialValue)
```

---

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)