add(_:_:)
Returns the double-precision element-wise sum of a vector and a scalar value.
Declaration
static func add<U>(_ scalar: Double, _ vector: U) -> [Double] where U : AccelerateBuffer, U.Element == DoubleParameters
- scalar:
The input scalar value,
B. - vector:
The input vector,
A.
Return Value
The output vector, C.
Discussion
This function calculates the element-wise sum of vector A and scalar value B, and writes the result to vector C.
for (n = 0; n < N; ++n)
C[n] = A[n] + B;[Image]
The following code shows an example of using this function:
let a: [Double] = [1, 2, 3, 4, 5]
let b: Double = 10
let c = vDSP.add(b, a)
// Prints "[11.0, 22.0, 33.0, 44.0, 55.0]".
print(c)