Function

vDSP_vmul(_:_:_:_:_:_:_:)

Multiplies two single-precision vectors.

Declaration

func vDSP_vmul(_ __A: UnsafePointer<Float>, _ __IA: vDSP_Stride, _ __B: UnsafePointer<Float>, _ __IB: vDSP_Stride, _ __C: UnsafeMutablePointer<Float>, _ __IC: vDSP_Stride, _ __N: vDSP_Length)

Parameters

__A

Single-precision real input vector.

__IA

Stride for A.

__B

Single-precision real input vector.

__IB

Stride for B.

__C

Single-precision real output vector.

__IC

Stride for C.

__N

The number of elements to process.

Discussion

This function calculates the products of the first N elements of input vectors A and B, writing the result to output vector C:

A diagram showing the operation of the vDSP_vmul function. There are three rows. The top row represents the first input, vector A. The second row represents the second input, vector B. The bottom row represents the output, vector C. The diagram has connecting lines from the input vectors to the output vector indicating the relationships between the inputs and output.

The operation is:

 for (n = 0; n < N; ++n)
    C[n] = A[n] * B[n];

The following code shows an example of using vDSP_vmul(_:_:_:_:_:_:_:):

let stride = vDSP_Stride(1)

let a: [Float] = [10, 20, 30, 40, 50]
let b: [Float] = [ 1,  2,  3,  4,  5]

let n = vDSP_Length(a.count)

var c = [Float](repeating: 0,
                count: a.count)

vDSP_vmul(b, stride,
          a, stride,
          &c, stride,
          n)

// Prints "[10.0, 40.0, 90.0, 160.0, 250.0]"
print(c)

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