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

# vDSP_vdist

Calculates the single-precision hypotenuses of right triangles with legs that are the lengths of corresponding elements of two pairs of vectors.

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

## Parameters

`__A`

A vector that contains the lengths of the first set of legs of the triangles.

`__IA`

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

`__B`

A vector that contains the lengths of the second set of legs of the triangles.

`__IB`

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

`__C`

The output vector.

`__IC`

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

`__N`

The number of elements to process.

## Discussion

The [`vDSP_vdist`](/documentation/Accelerate/vDSP_vdist) and [`vDSP_vdistD`](/documentation/Accelerate/vDSP_vdistD) functions calculate the square roots of the sum of the squares of corresponding elements of vectors `A` and `B`, using the following operation:

```objc
for (n = 0; n < N; ++n)
    C[n] = sqrt(A[n]*A[n] + B[n]*B[n]);
```

For example, the following code calculates the hypotenuse of four Pythagorean triples:

```swift
let a: [Float] = [3, 6, 5, 9]
let b: [Float] = [4, 8, 12, 12]

var c: [Float] = [0, 0, 0, 0]

let stride = vDSP_Stride(1)

vDSP_vdist(a, stride,
           b, stride,
           &c, stride,
           vDSP_Length(c.count))
```

On return, `c` contains `[5.0, 10.0, 13.0, 15.0]`.

---

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)