Contents

vDSP_vadd

Adds two single-precision vectors.

Declaration

void vDSP_vadd(const float *__A, vDSP_Stride __IA, const float *__B, vDSP_Stride __IB, float *__C, vDSP_Stride __IC, vDSP_Length __N);

Parameters

  • __A:

    The single-precision real input vector A.

  • __IA:

    The stride for input vector A.

  • __B:

    The single-precision real input vector B.

  • __IB:

    The stride for input vector B.

  • __C:

    The single-precision real output vector.

  • __IC:

    The stride for output vector C.

  • __N:

    The number of elements to add.

Discussion

This function calculates the sums of the first N elements of input vectors A and B, writing the result to output vector C:

[Image]

The operation is:

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

The following code shows an example of using vDSP_vadd:

let stride = vDSP_Stride(1)

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

let n = vDSP_Length(a.count)

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

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

// Prints "[11.0, 22.0, 33.0, 44.0, 55.0]".
print(c)

See Also

Vector Arithmetic Functions