Calculates the minimum magnitude and corresponding index in a single-precision vector.
SDKs
- iOS 4.0+
- macOS 10.4+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Accelerate
Declaration
func vDSP_minmgvi(_ __A: Unsafe Pointer<Float>, _ __IA: v DSP _Stride, _ __C: Unsafe Mutable Pointer<Float>, _ __I: Unsafe Mutable Pointer<v DSP _Length>, _ __N: v DSP _Length)
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
inC
, and the value inIC
is undefined.
Discussion
This function calculates the minimum 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 minimum value, IC contains the index of the first instance.
The operation is:
*C = -INFINITY;
for (n = 0; n < N; ++n)
{
if (*C < |A[n * I]|)
{
*C = |A[n * I]|;
*IC = n * I;
}
}
The following code shows an example of using v
.
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_minmgvi(a,
stride,
&c,
&i,
n)
print("min magnitude", c,
"index", i) // Prints "min magnitude 0.1 index 4"