add(multiplication:multiplication:)
Returns the single-precision element-wise addition of two vector-scalar products.
Declaration
static func add<T, U>(multiplication multiplicationAB: (a: T, b: Float), multiplication multiplicationCD: (c: U, d: Float)) -> [Float] where T : AccelerateBuffer, U : AccelerateBuffer, T.Element == Float, U.Element == FloatParameters
- multiplicationAB:
A tuple that contains the vector
Aand the scalar valueBinE = (A * B) + (C * D). - multiplicationCD:
A tuple that contains the vector
Cand the scalar valueDinE = (A * B) + (C * D).
Mentioned in
Return Value
The output vector E in E = (A * B) + (C * D).
Discussion
This function calculates the element-wise vector-scalar products of A and B, and C and D, and writes the sum of the products to vector D.
for (n = 0; n < N; ++n)
E[n] = A[n]*B + C[n]*D;[Image]
The following code shows an example of using this function:
let a: [Float] = [ 1, 2, 3, 4, 5]
let b: Float = 10
let c: [Float] = [ 5, 4, 3, 2, 1]
let d: Float = 50
let e = vDSP.add(multiplication: (a, b),
multiplication: (c, d))
// Prints "[260.0, 220.0, 180.0, 140.0, 100.0]".
print(e)