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

# la_vector_from_matrix_diagonal(_:_:)

Creates a vector from the specified diagonal of the matrix.

```
func la_vector_from_matrix_diagonal(_ matrix: la_object_t, _ matrix_diagonal: la_index_t) -> la_object_t
```

## Parameters

`matrix`

Matrix from which to create the vector.

`matrix_diagonal`

The index of the diagonal to create the vector from.

## Return Value

The resulting vector is a length x 1 vector where length is `min(rows(matrix),cols(matrix)-abs(matrix_diagonal)`

## Discussion

Creates a vector from the specified diagonal of the matrix.  If the value for
`matrix_diagonal` is less than zero and `abs(matrix_diagonal) > rows(matrix)-1`,
or if `matrix_diagonal` is greater than zero and `matrix_diagonal >  cols(matrix)-1`, `LA_INVALID_PARAMETER_ERROR` is returned.

If matrix is a splat, `LA_INVALID_PARAMETER_ERROR` is returned.

Always returns a `vector_length x 1` vector.

---

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)