<!--
{
  "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_vgathra",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@F@vDSP_vgathra"
  },
  "title" : "vDSP_vgathra"
}
-->

# vDSP_vgathra

Generates a gathered copy of the specified single-precision vector using a vector that defines the pointers to the values to keep.

```
extern void vDSP_vgathra(const float * const*__A, vDSP_Stride __IA, float *__C, vDSP_Stride __IC, vDSP_Length __N);
```

## Parameters

`__A`

The input vector that contains the pointers to the source values.

`__IA`

The distance between the elements in the input 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 input vector.

## Discussion

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

```swift
    let source: [Float] = [10, 20,
                           30, 40,
                           50, 60,
                           70, 80]
    
    let stride = 1
    
    let result = source.withUnsafeBufferPointer { srcPtr in
        
        let pointers = [srcPtr.baseAddress!.advanced(by: 0),
                        srcPtr.baseAddress!.advanced(by: 2),
                        srcPtr.baseAddress!.advanced(by: 4),
                        srcPtr.baseAddress!.advanced(by: 6)]
        
        let n = pointers.count
        
        return [Float](unsafeUninitializedCapacity: n) {
            buffer, initializedCount in
            
            vDSP_vgathra(pointers, 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)