Multiplies the difference between a single-precision vector and a single-precision scalar value by a single-precision vector.


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



Single-precision real input vector.


Stride for A.


Pointer to single-precision real input scalar.


Single-precision real input vector.


Stride for C.


Single-precision real output vector.


Stride for D.


The number of elements to process.


This function calculates the products of the first N elements of A and the scalar value B, subtracts the corresponding value in C from each product, and writes the result to D:

A diagram showing the operation of the vDSP_vsmsb function. There are five rows. The top two rows represents the first two inputs, vector A and scalar B. The third row represents the intermediate result of the first two inputs. The forth row represents the third input, vector C. The bottom row represents the output, vector D. The diagram has connecting lines from the input vectors to the output vector indicating the relationships between the inputs and output.

The operation is:

 for (n = 0; n < N; ++n)
    D[n] = A[n] * B - C[n];

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

let stride = vDSP_Stride(1)

let a: [Float] = [10, 20, 30, 40, 50]
var b = Float(2)

let c: [Float] = [1, 2, 3, 4, 5]

let n = vDSP_Length(a.count)

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

vDSP_vsmsb(a, stride,
           c, stride,
           &d, stride,

// Prints "[19.0, 38.0, 57.0, 76.0, 95.0]"

See Also

Ternary (Vector-Vector-Scalar) Multiply-Subtract Operations

func vDSP_vsmsbD(UnsafePointer<Double>, vDSP_Stride, UnsafePointer<Double>, UnsafePointer<Double>, vDSP_Stride, UnsafeMutablePointer<Double>, vDSP_Stride, vDSP_Length)

Multiplies the difference between a double-precision vector and a double-precision scalar value by a double-precision vector.