---
title: "add(_:_:result:)"
framework: accelerate
role: symbol
role_heading: Type Method
path: "accelerate/vdsp/add(_:_:result:)-2531u"
---

# add(_:_:result:)

Calculates the single-precision element-wise sum of a vector and a scalar value.

## Declaration

```swift
static func add<U, V>(_ scalar: Double, _ vector: U, result: inout V) where U : AccelerateBuffer, V : AccelerateMutableBuffer, U.Element == Double, V.Element == Double
```

## Parameters

- `scalar`: The input scalar value, B.
- `vector`: The input vector, A.
- `result`: The output vector, C.

## Discussion

Discussion This function calculates the element-wise sum of vector A and scalar value B, and writes the result to vector C.  for (n = 0; n < N; ++n)     C[n] = A[n] + B;

The following code shows an example of using this function:     let count = 5          let a: [Double] = [1, 2, 3, 4, 5]     let b: Double = 10          let c = [Double](unsafeUninitializedCapacity: count) {         buffer, initializedCount in                  vDSP.add(b, a,                   result: &buffer)                  initializedCount = count     }          // Prints "[11.0, 22.0, 33.0, 44.0, 55.0]".     print(c)

## See Also

### Addition

- [add(_:_:)](accelerate/vdsp/add(_:_:)-9mv1a.md)
- [add(_:_:)](accelerate/vdsp/add(_:_:)-2ftxc.md)
- [add(_:_:)](accelerate/vdsp/add(_:_:)-53nh9.md)
- [add(_:_:)](accelerate/vdsp/add(_:_:)-7swvf.md)
- [add(_:_:result:)](accelerate/vdsp/add(_:_:result:)-2w0o9.md)
- [add(_:_:result:)](accelerate/vdsp/add(_:_:result:)-338hl.md)
- [add(_:_:result:)](accelerate/vdsp/add(_:_:result:)-3vzwi.md)
- [add(_:to:count:result:)](accelerate/vdsp/add(_:to:count:result:)-g1dk.md)
- [add(_:to:count:result:)](accelerate/vdsp/add(_:to:count:result:)-75np9.md)
- [add(multiplication:_:)](accelerate/vdsp/add(multiplication:_:)-4e3tj.md)
- [add(multiplication:_:)](accelerate/vdsp/add(multiplication:_:)-1bsuq.md)
- [add(multiplication:_:)](accelerate/vdsp/add(multiplication:_:)-9dxlr.md)
- [add(multiplication:_:)](accelerate/vdsp/add(multiplication:_:)-4667v.md)
- [add(multiplication:_:)](accelerate/vdsp/add(multiplication:_:)-3tw93.md)
- [add(multiplication:_:)](accelerate/vdsp/add(multiplication:_:)-7aut1.md)
