---
title: vDSP_svemg
framework: accelerate
role: symbol
role_heading: Function
path: accelerate/vdsp_svemg
---

# vDSP_svemg

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

## Declaration

```occ
extern void vDSP_svemg(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

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

The operation is: C[0] = sum(|A[n]|, 0 <= n < N); The following code shows an example of using vDSP_svemg: 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_svemg(a,            stride,            &c,            n)

// Prints "sum of magnitudes 11.9500" print(String(format: "sum of magnitudes %.4f", c))

## See Also

### Vector Summation

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