Function

vDSP_maxmgv(_:_:_:_:)

Calculates the maximum magnitude in a single-precision vector.

Declaration

func vDSP_maxmgv(_ __A: UnsafePointer<Float>, _ __IA: vDSP_Stride, _ __C: UnsafeMutablePointer<Float>, _ __N: vDSP_Length)

Parameters

__A

Single-precision real input vector.

__I

Stride for A.

__C

Output scalar.

__N

The number of elements to process. If N is zero (0), this function returns -INFINITY.

Discussion

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

A diagram showing the operation of the vDSP_maxmgv function. There are three rows. The top row represents the input, vector A. The second row represents the maximum magnitude value operation. The bottom row represents the output, vector C. The diagram has connecting lines from the input vectors to the operation and from the operation to the output vector indicating the relationships between the input and output.

The operation is:

*C = -INFINITY;
for (n = 0; n < N; ++n)
    if (*C < |A[n*I]|)
        *C = |A[n*I]|;

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

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

vDSP_maxmgv(a,
            stride,
            &c,
            n)

print("max magnitude", c) // Prints "max magnitude 4.3"

See Also

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_maxmgvi(UnsafePointer<Float>, vDSP_Stride, UnsafeMutablePointer<Float>, UnsafeMutablePointer<vDSP_Length>, vDSP_Length)

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software