Contents

indexOfMaximumMagnitude(_:)

Returns the maximum magnitude and corresponding index in a double-precision vector.

Declaration

static func indexOfMaximumMagnitude<U>(_ vector: U) -> (UInt, Double) where U : AccelerateBuffer, U.Element == Double

Parameters

  • vector:

    The input vector.

Return Value

A tuple that contains the maximum magnitude and corresponding index.

Discussion

This function calculates the maximum magnitude and its corresponding index of the first N elements of the input vector and writes the results to the output scalar parameters, C and I, respectively.

[Image]

The following code shows an example of using this function:

let a: [Double] = [-1.5, 2.25, 3.6,
                   0.2, -0.1, -4.3]

let indexOfMaximumMagnitude = vDSP.indexOfMaximumMagnitude(a)

// Prints "indexOfMaximumMagnitude (5, 4.3)".
print("indexOfMaximumMagnitude", indexOfMaximumMagnitude) 

See Also

Type Methods