<!--
{
  "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/sum(_:)-6jamg",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4vDSPO3sumySdxAA0A6BufferRzSd7ElementRtzlFZ"
  },
  "title" : "sum(_:)"
}
-->

# sum(_:)

Returns the double-precision vector sum.

```
static func sum<U>(_ vector: U) -> Double where U : AccelerateBuffer, U.Element == Double
```

## Parameters

`vector`

The vector to sum.

## Discussion

This function calculates and returns the sum of the elements of a supplied vector.

The following is an example of using [`sum(_:)`](/documentation/Accelerate/vDSP/sum(_:)-8hq9):

```swift
let a: [Double] = [-1.5, 2.25, 3.6,
                   0.2, -0.1, -4.3]

let sum = vDSP.sum(a)

// Prints "sum 0.1500"
print(String(format: "sum %.4f", sum))
```

---

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)