sumOfMagnitudes(_:)
Returns the single-precision vector sum of magnitudes.
Declaration
static func sumOfMagnitudes<U>(_ vector: U) -> Float where U : AccelerateBuffer, U.Element == FloatParameters
- 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: [Float] = [-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))