Contents

vDSP_maxvi

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

Declaration

extern void vDSP_maxvi(const float *__A, vDSP_Stride __IA, float *__C, vDSP_Length *__I, vDSP_Length __N);

Parameters

  • __A:

    The input vector, A.

  • __IA:

    The distance between the elements in the input vector.

  • __C:

    The output scalar value, C. If N is zero, the function sets C to -infinity.

  • __I:

    The output scalar value, I. If N is zero, the function sets I to 0.

  • __N:

    The number of elements that the function processes.

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 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
    var i: vDSP_Length = 0
    
    vDSP_maxvi(a,
               stride,
               &c,
               &i,
               n)
    
    print("max", c,
          "index", i) // Prints "max 3.6 index 2".

See Also

Calculating the index of the maximum value of a vector