vDSP_vsmsmaD
Calculates the double-precision element-wise addition of two vector-scalar products, using the specified stride.
Declaration
extern void vDSP_vsmsmaD(const double *__A, vDSP_Stride __IA, const double *__B, const double *__C, vDSP_Stride __IC, const double *__D, double *__E, vDSP_Stride __IE, vDSP_Length __N);Parameters
- __A:
The input vector
AinE = (A * B) + (C * D). - __IA:
The distance between the elements in the input vector
A. - __B:
The input scalar value
BinE = (A * B) + (C * D). - __C:
The input vector
CinE = (A * B) + (C * D). - __IC:
The distance between the elements in the input vector
C. - __D:
The input scalar value
DinE = (A * B) + (C * D). - __E:
The output vector
DinE = (A * B) + (C * D). - __IE:
The distance between the elements in the output vector
E. - __N:
The number of elements that the function processes.
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 stride = 1
let count = 5
let a: [Double] = [ 1, 2, 3, 4, 5]
let b: Double = 10
let c: [Double] = [ 5, 4, 3, 2, 1]
let d: Double = 50
let e = [Double](unsafeUninitializedCapacity: count) {
buffer, initializedCount in
vDSP_vsmsmaD(a, stride,
[b],
c, stride,
[d],
buffer.baseAddress!, stride,
vDSP_Length(count))
initializedCount = count
}
// Prints "[260.0, 220.0, 180.0, 140.0, 100.0]".
print(e)