multiply(addition:addition:result:)
Calculates the single-precision element-wise product of the sums of two pairs of vectors.
Declaration
static func multiply<S, T, U, V>(addition additionAB: (a: S, b: T), addition additionCD: (c: U, d: U), result: inout V) where S : AccelerateBuffer, T : AccelerateBuffer, U : AccelerateBuffer, V : AccelerateMutableBuffer, S.Element == Float, T.Element == Float, U.Element == Float, V.Element == FloatParameters
- additionAB:
A tuple that contains the vectors
AandBinE = (A + B) * (C + D). - additionCD:
A tuple that contains the vectors
CandDinE = (A + B) * (C + D). - result:
The output vector
EinE = (A + B) * (C + D).
Discussion
This function calculates the products of the first N elements of the addition of vectors A and B and the addition of vectors C and D.
for (n = 0; n < N; ++n)
E[n] = (A[n]+B[n]) * (C[n]+D[n]); [Image]
The following code shows an example of using this function:
let count = 5
let a: [Float] = [ 1, 2, 3, 4, 5]
let b: [Float] = [10, 20, 30, 40, 50]
let c: [Float] = [ 5, 4, 3, 2, 1]
let d: [Float] = [50, 40, 30, 20, 10]
let e = [Float](unsafeUninitializedCapacity: count) {
buffer, initializedCount in
vDSP.multiply(addition: (a, b),
addition: (c, d),
result: &buffer)
initializedCount = count
}
// Prints "[605.0, 968.0, 1089.0, 968.0, 605.0]".
print(e)
See Also
Multiplication
multiply(_:_:)multiply(_:_:)multiply(_:_:)multiply(_:_:)multiply(_:_:result:)multiply(_:_:result:)multiply(_:_:result:)multiply(_:_:result:)multiply(_:by:count:useConjugate:result:)multiply(_:by:count:useConjugate:result:)multiply(_:by:result:)multiply(_:by:result:)multiply(addition:_:)multiply(addition:_:)multiply(addition:_:)