Function

vDSP_maxmgvi(_:_:_:_:_:)

Calculates the maximum magnitude and corresponding index in a single-precision vector.

Parameters

__A

Single-precision real input vector.

__I

Stride for A.

__C

Output scalar.

__IC

Output scalar index.

__N

The number of elements to process. If N is zero (0), this function returns -INFINITY in C, and the value in IC is undefined.

Discussion

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

The index is the actual array index, not the pre-stride index. If vector A contains more than one instance of the maximum value, IC contains the index of the first instance.

The operation is:

The following code shows an example of using vDSP_maxmgv(_:_:_:_:):

Maximum Calculation

static func maximum<U>(U) -> Double

Returns the maximum element in a double-precision vector.

static func maximum<U>(U) -> Float

Returns the maximum element in a single-precision vector.

static func maximumMagnitude<U>(U) -> Double

Returns the maximum magnitude element in a double-precision vector.

static func maximumMagnitude<U>(U) -> Float

Returns the maximum magnitude element in a single-precision vector.

static func indexOfMaximum<U>(U) -> (UInt, Double)

Returns the maximum element, and its index, in a double-precision vector.

static func indexOfMaximum<U>(U) -> (UInt, Float)

Returns the maximum element, and its index, in a signal-precision vector.

static func indexOfMaximumMagnitude<U>(U) -> (UInt, Double)

Returns the maximum magnitude element, and its index, in a double-precision vector.

static func indexOfMaximumMagnitude<U>(U) -> (UInt, Float)

Returns the maximum magnitude element, and its index, in a single-precision vector.

func vDSP_maxmgv(UnsafePointer<Float>, vDSP_Stride, UnsafeMutablePointer<Float>, vDSP_Length)

Calculates the maximum magnitude in a single-precision vector.