<!--
{
  "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_slice(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@F@la_vector_slice"
  },
  "title" : "la_vector_slice(_:_:_:_:)"
}
-->

# la_vector_slice(_:_:_:_:)

```
func la_vector_slice(_ vector: la_object_t, _ vector_first: la_index_t, _ vector_stride: la_index_t, _ slice_length: la_count_t) -> la_object_t
```

## Parameters

`vector`

The vector to be sliced.

`vector_first`

The index of the source vector element that will become the first element
of the new slice vector.

`vector_stride`

The offset in the source vector between elements that will be consecutive in
the new slice vector.

`slice_length`

The length of the resulting slice vector.

## Return Value

A new vector with length slice_length whose elements are taken from vector.

## Discussion\abstract Create a slice of a vector.
\discussion The result object is the vector:

[ vector[vector_first], vector[vector_first+vector_stride], …
… , vector[vector_first + (slice_length-1)*vector_stride] ]

Slices provide an efficient means to operate on subvectors and strides.
These are lightweight objects that reference the storage of the vector from
which they originate.  Creating a vector slice does not require any allocation
beyond the object representing the slice, nor does it require copying.

This function supports slicing a vector, or a matrix that has only one row
or only one column.  If the object is not a matrix or vector, or if it is
a matrix with both dimensions larger than one, the returned object will have
status LA_INVALID_PARAMETER_ERROR.

If the slice references indices that are less than zero or greater than or
equal to the length of the vector, LA_SLICE_OUT_OF_BOUNDS_ERROR is returned.

Always return a vector with the same orientation as the input.  If input is
vector_length x 1, output is vector_length x 1 and if input is
1 x vector_length, output is 1 x vector_length.

---

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)