<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.2.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vDSP_vsubD",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@F@vDSP_vsubD"
  },
  "title" : "vDSP_vsubD"
}
-->

# vDSP_vsubD

Calculates the double-precision element-wise subtraction of two vectors, using the specified stride.

```
extern void vDSP_vsubD(const double *__B, vDSP_Stride __IB, const double *__A, vDSP_Stride __IA, double *__C, vDSP_Stride __IC, vDSP_Length __N);
```

## Parameters

`__B`

The first input vector, `B`.

`__IB`

The distance between the elements in the first input vector.

`__A`

The second input vector, `A`.

`__IA`

The distance between the elements in the second input vector.

`__C`

The output vector, `C`.

`__IC`

The distance between the elements in the output vector.

`__N`

The number of elements that the function processes.

## Discussion

This function calculates the differences of the first `N` elements of input vectors `A` and `B`, and writes the result to output vector `C`.

```swift
 for (n = 0; n < N; ++n)
    C[n] = A[n] - B[n];
```

![A diagram showing the operation of this function. There are three rows. The top row represents the input vectors, A and B, with three boxes of each. The middle row represents the operation as three boxes with minus signs. The bottom row represents the output vector C as three boxes. The diagram has connecting lines from the input vectors to the operation, and from the operation to the output vectors.](images/com.apple.accelerate/media-4336897@2x.png)

The following code shows an example of using this function:

```swift
let stride = 1
let count = 5

let a: [Double] = [10, 20, 30, 40, 50]
let b: [Double] = [ 1,  2,  3,  4,  5]

let c = [Double](unsafeUninitializedCapacity: count) {
    buffer, initializedCount in
    
    vDSP_vsubD(b, stride,
               a, stride,
               buffer.baseAddress!, stride,
               vDSP_Length(count))
    
    initializedCount = count
}

// Prints "[9.0, 18.0, 27.0, 36.0, 45.0]".
print(c)
```

---

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)