<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/sparse_matrix_trace_double(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@F@sparse_matrix_trace_double"
  },
  "title" : "sparse_matrix_trace_double(_:_:)"
}
-->

# sparse_matrix_trace_double(_:_:)

Computes the sum along the specified diagonal of the double-precision sparse matrix *A*.

```
func sparse_matrix_trace_double(_ A: sparse_matrix_double!, _ offset: sparse_index) -> Double
```

## Parameters

`A`

The sparse matrix, *A*.

`offset`

Specifies the diagonal to sum.

## Return Value

The computed trace.

## Discussion

The diagonal is specified by the `offset` parameter where zero is the main diagonal, values greater than one refer to diagonals above the main diagonal (`A[i,i+offset]`), and values less than one refer to diagonals below the main diagonal (`A[i-offset, i]`).

If offset is out of the bounds of the matrix `A`, `0` is returned.

> Important:
> Apple provides the BLAS and LAPACK libraries under the Accelerate framework to be in line with LAPACK 3.9.1. Starting with iOS 26, iPadOS 26, macOS 26, tvOS 26, visionOS 26, and watchOS 26, the libraries are in line with LAPACK 3.12.0. These new interfaces provide additional functionality, as well as a new ILP64 interface. To use the new interfaces, define `ACCELERATE_NEW_LAPACK` before including the Accelerate or vecLib headers. For ILP64 interfaces, also define `ACCELERATE_LAPACK_ILP64`. For Swift projects, specify `ACCELERATE_NEW_LAPACK=1` and `ACCELERATE_LAPACK_ILP64=1` as preprocessor macros in Xcode build settings under Apple Clang - Preprocessing > Preprocessor Macros.

---

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)