Multiplies a single-precision vector by the sum of two single-precision vectors.


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



Single-precision real input vector.


Stride for A.


Single-precision real input vector.


Stride for B.


Single-precision real input vector.


Stride for C


Single-precision real output vector.


Stride for D.


Number of elements to add.


This function calculates the sums of the first N elements of A and B, multiplies each sum by the corresponding value in C, and writes the result to D:

A diagram showing the operation of the vDSP_vam function. There are five rows. The top two rows represents the first two inputs, vector A and vector B. The third row represents the intermediate result of the first two inputs. The forth row represents the third input, vector C. The bottom row represents the output, vector D. 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)
    D[n] = (A[n] + B[n]) * C[n];

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

let stride = vDSP_Stride(1)

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

let n = vDSP_Length(a.count)

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

vDSP_vam(a, stride,
         b, stride,
         c, stride,
         &d, stride,

// Prints "[22.0, 11.0, 66.0, 22.0, 110.0]"

See Also