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

# vDSP_vgathrD

Generates a gathered copy of the specified double-precision vector using a vector that defines the one-based indices to keep.

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

## Parameters

`__A`

The input vector that defines the source values.

`__B`

The input vector that defines the indices.

`__IB`

The distance between the elements in the indices vector.` `

`__C`

The output vector.

`__IC`

The distance between the elements in the output vector.` `

`__N`

The number of elements in the output vector and the number of elements in the indices vector.

## Discussion

The following code shows an example of gathering the values in `source` using the values in `indices`:

```swift
    let source: [Double] = [10, 20,
                            30, 40,
                            50, 60,
                            70, 80]
    
    let indices: [UInt] = [1, 3, 5, 7]
    
    let n = indices.count
    let stride = 1
    
    let result = [Double](unsafeUninitializedCapacity: n) {
        buffer, initializedCount in
        
        vDSP_vgathrD(source,
                     indices, stride,
                     buffer.baseAddress!, stride,
                     vDSP_Length(n))
        
        initializedCount = n
    }
    
    // Prints "[10.0, 30.0, 50.0, 70.0]".
    print(result)
```

---

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)