divide(_:_:result:)
Calculates the double-precision element-wise division of a scalar value and a vector.
Declaration
static func divide<U, V>(_ scalar: Double, _ vector: U, result: inout V) where U : AccelerateBuffer, V : AccelerateMutableBuffer, U.Element == Double, V.Element == DoubleParameters
- scalar:
The input scalar value,
A. - vector:
The input vector,
B. - result:
The output vector,
C.
Discussion
This function calculates the element-wise division of scalar value A and vector B, and writes the result to vector C.
for (n = 0; n < N; ++n)
C[n] = A / B[n];[Image]
The following code shows an example of using this function:
let count = 5
let a: Double = 100
let b: [Double] = [1, 2, 3, 4, 5]
let c = [Double](unsafeUninitializedCapacity: count) {
buffer, initializedCount in
vDSP.divide(a, b,
result: &buffer)
initializedCount = count
}
// Prints "[100.0, 50.0, 33.33, 25.0, 20.0]".
print(c)