Function

vDSP_vsdiv(_:_:_:_:_:_:)

Divides a single-precision vector by a single-precision scalar value.

Declaration

func vDSP_vsdiv(_ __A: UnsafePointer<Float>, _ __IA: vDSP_Stride, _ __B: UnsafePointer<Float>, _ __C: UnsafeMutablePointer<Float>, _ __IC: vDSP_Stride, _ __N: vDSP_Length)

Parameters

__A

Single-precision real input vector.

__IA

Stride for A.

__B

Pointer to single-precision real input scalar.

__C

Single-precision real output vector.

__IC

Stride for C.

__N

The number of elements to process.

Discussion

This function calculates the first N elements of A divided by the scalar value B, writing the result to C:

The operation is:

 for (n = 0; n < N; ++n)
    C[n] = A[n] / B;

The following code shows an example of using vDSP_vsdiv(_:_:_:_:_:_:):

let stride = vDSP_Stride(1)

let a: [Float] = [1, 2, 4, 5]
var b: Float = 2

let n = vDSP_Length(a.count)

var c = [Float](repeating: 0,
                count: a.count)

vDSP_vsdiv(a, stride,
           &b,
           &c, stride,
           n)

// Prints "[0.5, 1.0, 2.0, 2.5]"
print(c)