Function

vDSP_meamgv

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

Declaration

void vDSP_meamgv(const float *__A, vDSP_Stride __IA, float *__C, vDSP_Length __N);

Parameters

__A

Single-precision real input vector.

__I

Stride for A.

__C

Output scalar.

__N

The number of elements to process. If N is zero (0), this function returns -INFINITY.

Discussion

This function calculates the mean magnitude of the first N elements of A and writes the result to C:

A diagram showing the operation of the vDSP_meamgv function. There are three rows. The top row represents the input, vector A. The second row represents the averaging 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.

The operation is:

C[0] = sum(|A[n]|, 0 <= n < N) / N;

The following code shows an example of using vDSP_meanv:

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_meamgv(a,
            stride,
            &c,
            n)

print(String(format: "mean magnitude %.4f", c)) // Prints "mean magnitude 1.9917"

See Also

Mean Calculation

vDSP_meanv

Calculates the mean value in a single-precision vector.

vDSP_meanvD

Calculates the mean value in a double-precision vector.

vDSP_meamgvD

Calculates the mean of magnitudes in a double-precision vector.

vDSP_measqv

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

vDSP_measqvD

Calculates the mean of squares in a double-precision vector.

vDSP_mvessq

Calculates the mean of signed squares in a single-precision vector.

vDSP_mvessqD

Calculates the mean of signed squares in a double-precision vector.

vDSP_rmsqv

Calculates the root mean square of a single-precision vector.

vDSP_rmsqvD

Calculates the root mean square of a double-precision vector.