Function

vDSP_dotpr2D(_:_:_:_:_:_:_:_:_:)

Calculates the dot product of a double-precision stereo vector.

Declaration

func vDSP_dotpr2D(_ __A0: UnsafePointer<Double>, _ __IA0: vDSP_Stride, _ __A1: UnsafePointer<Double>, _ __IA1: vDSP_Stride, _ __B: UnsafePointer<Double>, _ __IB: vDSP_Stride, _ __C0: UnsafeMutablePointer<Double>, _ __C1: UnsafeMutablePointer<Double>, _ __N: vDSP_Length)

Parameters

__A0

Double-precision input vector for first channel.

__IA0

The stride within vector A0.

__A1

Double-precision input vector for second channel.

__IA1

The stride within vector A1.

__B

Double-precision input vector for both channels.

__IB

The stride within vector B.

__C0

Pointer to an allocated variable of type double; on return, it contains the dot product of A0 and B.

__C1

Pointer to an allocated variable of type double; on return, it contains the dot product of A1 and B.

__N

The number of elements in each of the input and output vectors.

Discussion

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,
           &c,
           n)

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.