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

# vDSP_vcmprsD

Generates a compressed copy of the specified double-precision vector using the nonzero values in a gating vector.

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

## Parameters

`__A`

The input vector that defines the source values.

`__IA`

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

`__B`

The input vector that defines the gating values.

`__IB`

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

## Discussion

The following code shows an example of compressing the values in `source` using the nonzero values in `gatingVector`:

```swift
    let source: [Double] = [1, 2,
                            3, 4,
                            5, 6,
                            7, 8]

    let gatingVector: [Double] = [-1, 0,
                                  1, 0,
                                  0.001, 0,
                                  10, 0]
    
    let n = vDSP_Length(source.count)
    let stride = 1
    
    let resultCount = gatingVector.filter { !$0.isZero }.count
    
    let result = [Double](unsafeUninitializedCapacity: resultCount) {
        buffer, initializedCount in
        
        vDSP_vcmprsD(source, stride,
                    gatingVector, stride,
                    buffer.baseAddress!, stride,
                    n)
        
        initializedCount = resultCount
    }
    
    // Prints "[1.0, 3.0, 5.0, 7.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)