---
title: vDSP_sve_svesq
framework: accelerate
role: symbol
role_heading: Function
path: accelerate/vdsp_sve_svesq
---

# vDSP_sve_svesq

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

## Declaration

```occ
extern void vDSP_sve_svesq(const float *__A, vDSP_Stride __IA, float *__Sum, float *__SumOfSquares, vDSP_Length __N);
```

## Parameters

- `__A`: Single-precision input vector.
- `__IA`: Stride for the input vector.
- `__Sum`: Single-precision sum (scalar) of the elements of A.
- `__SumOfSquares`: Single-precision sum (scalar) of the squares of the elements of A.
- `__N`: Number of elements in A.

## Discussion

Discussion This function calculates the sum of values and the sum of squares of the first N elements of A and writes the result to Sum and SumOfSquares respectively:

The operation is: Sum          = sum(A[n],      0 <= n < N); SumOfSquares = sum(A[n] ** 2, 0 <= n < N); The following code shows an example of using vDSP_sve_svesq: 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 sum: Float = .nan var sumOfSquares: Float = .nan

vDSP_sve_svesq(a,                stride,                &sum,                &sumOfSquares,                n)

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

## See Also

### Vector Summation

- [vDSP_sve](accelerate/vdsp_sve.md)
- [vDSP_sveD](accelerate/vdsp_sved.md)
- [vDSP_svemg](accelerate/vdsp_svemg.md)
- [vDSP_svemgD](accelerate/vdsp_svemgd.md)
- [vDSP_svesq](accelerate/vdsp_svesq.md)
- [vDSP_svesqD](accelerate/vdsp_svesqd.md)
- [vDSP_sve_svesqD](accelerate/vdsp_sve_svesqd.md)
- [vDSP_svs](accelerate/vdsp_svs.md)
- [vDSP_svsD](accelerate/vdsp_svsd.md)
