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

# vDSP_svesq

Calculates the sum of squares in a single-precision vector.

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

## Parameters

`__A`

Single-precision real input vector.

`__IA`

Stride for `A`.

`__C`

Single-precision real output scalar.

`__N`

The number of elements to process.

## Discussion

This function calculates the sum of the squares of the first `N` elements of `A` and writes the result to `C`:

![A diagram showing the operation of the vDSP_svesq function. There are three rows. The top row represents the input, vector A. The second row represents the summation operation. The bottom row represents the output, vector C. The diagram has connecting lines from the input vectors to the operation and from the operation to the output vector indicating the relationships between the input and output.](images/com.apple.accelerate/media-3111271@2x.png)

The operation is:

```c
C[0] = sum(A[n] * A[n], 0 <= n < N);
```

The following code shows an example of using [`vDSP_svesq`](/documentation/Accelerate/vDSP_svesq):

```swift
let stride = vDSP_Stride(1)

let a: [Float] = [-1.5, 2.25, 3.6,
                  0.2, -0.1, -4.3]
let n = vDSP_Length(a.count)

var c: Float = .nan

vDSP_svesq(a,
           stride,
           &c,
           n)

// Prints "sum of squares 38.8125"
print(String(format: "sum of squares %.4f", c))
```

---

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)