divide(_:_:result:)
Calculates the double-precision element-wise division of a vector and a scalar value.
Declaration
static func divide<U, V>(_ vector: U, _ scalar: Double, result: inout V) where U : AccelerateBuffer, V : AccelerateMutableBuffer, U.Element == Double, V.Element == DoubleParameters
- vector:
The input vector,
A. - scalar:
The input scalar value,
B. - result:
The output vector,
C.
Discussion
This function calculates the element-wise division 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 count = 5
let a: [Double] = [1, 2, 3, 4, 5]
let b: Double = 10
let c = [Double](unsafeUninitializedCapacity: count) {
buffer, initializedCount in
vDSP.divide(a, b,
result: &buffer)
initializedCount = count
}
// Prints "[0.1, 0.2, 0.3, 0.4, 0.5]".
print(c)