Contents

vDSP_vsmsma

Calculates the single-precision element-wise addition of two vector-scalar products, using the specified stride.

Declaration

extern void vDSP_vsmsma(const float *__A, vDSP_Stride __IA, const float *__B, const float *__C, vDSP_Stride __IC, const float *__D, float *__E, vDSP_Stride __IE, vDSP_Length __N);

Parameters

  • __A:

    The input vector A in E = (A * B) + (C * D).

  • __IA:

    The distance between the elements in the input vector A.

  • __B:

    The input scalar value B in E = (A * B) + (C * D).

  • __C:

    The input vector C in E = (A * B) + (C * D).

  • __IC:

    The distance between the elements in the input vector C.

  • __D:

    The input scalar value D in E = (A * B) + (C * D).

  • __E:

    The output vector D in E = (A * B) + (C * D).

  • __IE:

    The distance between the elements in the output vector E.

  • __N:

    The number of elements that the function processes.

Discussion

This function calculates the element-wise vector-scalar products of A and B, and C and D, and writes the sum of the products to vector D.

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

[Image]

The following code shows an example of using this function:

    let stride = 1
    let count = 5
    
    let a: [Float] = [ 1,  2,  3,  4,  5]
    let b: Float = 10
    let c: [Float] = [ 5,  4,  3,  2,  1]
    let d: Float = 50
    
    let e = [Float](unsafeUninitializedCapacity: count) {
        buffer, initializedCount in
        
        vDSP_vsmsma(a, stride,
                    [b],
                    c, stride,
                    [d],
                    buffer.baseAddress!, stride,
                    vDSP_Length(count))
        
        initializedCount = count
    }
    
    // Prints "[260.0, 220.0, 180.0, 140.0, 100.0]".
    print(e)

See Also

Vector-scalar-vector-scalar multiply-multiply-add operations