Contents

indexOfMaximum(_:)

Returns the maximum value and corresponding index in a single-precision vector.

Declaration

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

Parameters

  • vector:

    The input vector.

Mentioned in

Return Value

A tuple that contains the maximum value and corresponding index.

Discussion

This function calculates the maximum value 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: [Float] = [-1.5, 2.25, 3.6,
                  0.2, -0.1, -4.3]

let indexOfMaximum = vDSP.indexOfMaximum(a)
print("indexOfMaximum", indexOfMaximum) // Prints "indexOfMaximum (2, 3.6)".

See Also

Type Methods