Function

vDSP_dotpr

Calculates the dot product of a single-precision vector.

Declaration

void vDSP_dotpr(const float *__A, vDSP_Stride __IA, const float *__B, vDSP_Stride __IB, float *__C, vDSP_Length __N);

Parameters

__A

Single-precision real input vector A.

__IA

The stride within A.

__B

Single-precision real input vector B.

__IB

The stride within B.

__C

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

__N

The number of elements to process.

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

vDSP_dotprD

Calculates the dot product of a double-precision vector.

vDSP_dotpr_s1_15

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

vDSP_dotpr_s8_24

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

vDSP_dotpr2

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

vDSP_dotpr2D

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

vDSP_dotpr2_s1_15

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

vDSP_dotpr2_s8_24

Calculates the dot product of a fixed-point 8.24 format, stereo vector.

vDSP_zdotpr

Calculates the complex dot product of two single-precision complex vectors.

vDSP_zdotprD

Calculates the complex dot product of two double-precision complex vectors.

vDSP_zidotpr

Calculates the inner (conjugate) product of a single-precision complex vector.

vDSP_zidotprD

Calculates the inner (conjugate) product of a double-precision complex vector.

vDSP_zrdotpr

Calculates the dot product of a single-precision complex-real vector.

vDSP_zrdotprD

Calculates the dot product of a double-precision complex-real vector.

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