<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vDSP/add(multiplication:multiplication:)-8rjh8",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4vDSPO3add14multiplicationAESaySfGx1a_Sf1bt_q_1c_Sf1dttAA0A6BufferRzAaKR_Sf7ElementRtzSfALRt_r0_lFZ"
  },
  "title" : "add(multiplication:multiplication:)"
}
-->

# add(multiplication:multiplication:)

Returns the single-precision element-wise addition of two vector-scalar products.

```
static func add<T, U>(multiplication multiplicationAB: (a: T, b: Float), multiplication multiplicationCD: (c: U, d: Float)) -> [Float] where T : AccelerateBuffer, U : AccelerateBuffer, T.Element == Float, U.Element == Float
```

## Parameters

`multiplicationAB`

A tuple that contains the vector `A` and the scalar value `B` in `E = (A * B) + (C * D)`.

`multiplicationCD`

A tuple that contains the vector `C` and the scalar value `D` in `E = (A * B) + (C * D)`.

## Return Value

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

## 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`.

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

![A diagram showing the operation of this function. There are four rows. The top row represents the input vectors, A and C, with three boxes each, and the scalar values, B and D, with one box each. The second row represents the operations that multiply A and B, as well as the operations that multiply C and D, with three boxes each. The third row represents the addition operation as three boxes. The bottom row represents the output vector E as three boxes. The diagram has connecting lines from the input vectors to the operations, and from the operations to the output vector. ](images/com.apple.accelerate/media-4389067@2x.png)

The following code shows an example of using this function:

```swift
    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 = vDSP.add(multiplication: (a, b),
                     multiplication: (c, d))
    
    // Prints "[260.0, 220.0, 180.0, 140.0, 100.0]".
    print(e)
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)