Function

vDSP_vasbm(_:_:_:_:_:_:_:_:_:_:_:)

Multiplies the sum of two single-precision vectors by the difference of two single-precision vectors.

Declaration

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

Parameters

__A

Single-precision real input vector.

__IA

Stride for A.

__B

Single-precision real input vector.

__IB

Stride for B.

__C

Single-precision real input vector.

__IC

Stride for C.

__D

Single-precision real input vector.

__ID

Stride for D.

__E

Single-precision real output vector.

__IE

Stride for E.

__N

The number of elements to process.

Discussion

This function calculates the sums of the first N elements of A and B, the differences of the first N elements of C and D, multiplies the corresponding results, and writes the product to E:

A diagram showing the operation of the vDSP_vasbm function. There are four rows and the top three rows are composed of two columns. The top two rows of the left column represent the input vectors A and B. The top two rows of the right column represent the input vectors C and D. The third row in both columns represent the intermediate result of the respective inputs. The bottom row represents the output vector, E. The diagram has connecting lines from the inputs to the output vector indicating the relationships between the inputs and output.

The operation is:

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

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

let stride = vDSP_Stride(1)

let a: [Float] = [10, 20, 30, 40, 50]
let b: [Float] = [ 1,  2,  3,  4,  5]

let c: [Float] = [0.75, 1, 1.5, 2, 2]
let d: [Float] = [0.25, 1, 0.5, 1, 2]

let n = vDSP_Length(a.count)

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

vDSP_vasbm(a, stride,
           b, stride,
           c, stride,
           d, stride,
           &e, stride,
           n)

// Prints "[5.5, 0.0, 33.0, 44.0, 0.0]"
print(e)

See Also

Quaternary Add-Subtract-Multiply Operations

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software