Generic Type Method


Returns the single-precision dot product of two vectors.


static func dot<U>(_ vectorA: U, _ vectorB: U) -> Float where U : AccelerateBuffer, U.Element == Float



The first vector of the dot product.


The second vector of the dot product.


The single- and double-precision dot(_:_:) functions calculate the dot product of two vectors, using the following operation:

C[0] = sum(A[n] * B[n], 0 <= n < N);

The following example shows how you calculate the luminosity of a color using the Rec. 709 luma coefficients for the color-to-grayscale conversion. Array a defines the color, 0xDa70D6, and array b defines the coefficients:

let a: [Float] = [0xDA, 0x70, 0xD6]
let b: [Float] = [0.2126, 0.7152, 0.0722]

Passing these values to dot(_:_:) returns the luminosity:

let result =, b)

print(result)   // Prints "141.9"

See Also

Dot Product Calculation

static func dot<U>(U, U) -> Double

Returns the double-precision dot product of two vectors.