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

# vDSP_zvabs

Calculates the absolute value of each element in the supplied single-precision complex vector using the specified stride.

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

## Parameters

`__A`

The input vector `A`.

`__IA`

The distance between the elements in the input vector `A`.

`__C`

On output, the absolute values of the elements in the input vector.

`__IC`

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

`__N`

The number of elements that the function processes.

## Discussion

This function returns the square roots of the sum of the squares of the real and imaginary parts of each complex element.

For example, the following code calculates the absolute values of four complex numbers:

```swift
    let stride = 1
    let n = 4
    
    let reals = UnsafeMutableBufferPointer<Float>.allocate(capacity: n)
    _ = reals.initialize(from: [ -3, -6, 5, 9 ])
    
    let imaginaries = UnsafeMutableBufferPointer<Float>.allocate(capacity: n)
    _ = imaginaries.initialize(from: [ 4, -8, -12, 12 ])
    
    var values = DSPSplitComplex(realp: reals.baseAddress!,
                                 imagp: imaginaries.baseAddress!)
    
    
    let absoluteValues = [Float](unsafeUninitializedCapacity: n) {
        buffer, initializedCount in
        
        vDSP_zvabs(&values, stride,
                   buffer.baseAddress!, stride,
                   vDSP_Length(n))
        
        initializedCount = n
    }
    
    // Prints "[5.0, 10.0, 13.0, 15.0]".
    print(absoluteValues)
```

---

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)