sumOfSquares(_:)
Returns the single-precision vector sum of squares.
Declaration
static func sumOfSquares<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 squares of the elements of a supplied vector.
The following is an example of using sumOfSquares(_:):
let a: [Float] = [-1.5, 2.25, 3.6,
0.2, -0.1, -4.3]
let sumOfSquares = vDSP.sumOfSquares(a)
// Prints "sum of squares 38.8125"
print(String(format: "sum of squares %.4f", sumOfSquares))