Contents

sumOfMagnitudes(_:)

Returns the double-precision vector sum of magnitudes.

Declaration

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

Parameters

  • vector:

    The vector to sum.

Discussion

This function calculates and returns the sum of the magnitudes of the elements of a supplied vector.

The following is an example of using sumOfMagnitudes(_:):

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

let sumOfMagnitudes = vDSP.sumOfMagnitudes(a)

// Prints "sum of magnitudes 11.9500"
print(String(format: "sum of magnitudes %.4f", sumOfMagnitudes))

See Also

Type Methods