Calculates the dot product of a fixed-point 1.15 format vector.


func vDSP_dotpr_s1_15(_ __A: UnsafePointer<Int16>, _ __IA: vDSP_Stride, _ __B: UnsafePointer<Int16>, _ __IB: vDSP_Stride, _ __C: UnsafeMutablePointer<Int16>, _ __N: vDSP_Length)



Single-precision fixed-point input vector A.


The stride within vector A.


Single-precision fixed-point input vector B.


The stride within vector B.


Pointer to an allocated variable of type short; on return, it contains the dot product.


The number of elements.


The functions in this group 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 vDSP_dotpr(_:_:_:_:_:_:) calculates the luminosity and writes the result to c:

let n = vDSP_Length(a.count)
var c: Float = .nan

let stride = vDSP_Stride(1)

vDSP_dotpr(a, stride,
           b, stride,

print(c)    // Prints "141.9"

See Also

Dot Product Calculation

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

Returns the double-precision dot product of two vectors.

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

Returns the single-precision dot product of two vectors.

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