Contents

divide(_:_:)

Returns the single-precision element-wise division of a scalar value and a vector.

Declaration

static func divide<U>(_ scalar: Float, _ vector: U) -> [Float] where U : AccelerateBuffer, U.Element == Float

Parameters

  • scalar:

    The input scalar value, A.

  • vector:

    The input vector, B.

Mentioned in

Return Value

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 a: Float = 100
    let b: [Float] = [1, 2, 3, 4, 5]
    
    let c = vDSP.divide(a, b)
    
    // Prints "[100.0, 50.0, 33.33, 25.0, 20.0]".
    print(c)

See Also

Division