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

# la_matrix_slice(_:_:_:_:_:_:_:)

```
func la_matrix_slice(_ matrix: la_object_t, _ matrix_first_row: la_index_t, _ matrix_first_col: la_index_t, _ matrix_row_stride: la_index_t, _ matrix_col_stride: la_index_t, _ slice_rows: la_count_t, _ slice_cols: la_count_t) -> la_object_t
```

## Parameters

`matrix`

The matrix to be sliced.

`matrix_first_row`

The index of the row of the source matrix containing the first element of
new slice matrix.

`matrix_first_col`

The index of the column of the source matrix containing the first element
of the slice matrix.

`matrix_row_stride`

The offset in the source matrix between rows that will be consecutive in
the slice matrix.

`matrix_col_stride`

The offset in the source matrix between columns that will be consecutve in
the slice matrix.

`slice_rows`

The number of rows in the slice matrix.

`slice_cols`

The number of columns in the slice matrix.

## Return Value

A new matrix with size slice_rows x slice_cols whose elements are taken
from the source matrix.

## Discussion\abstract Create a slice of a matrix.
\discussion The result object is the slice_rows x slice_cols matrix whose i,jth entry is:

matrix[matrix_first_row + i*matrix_row_stride,
matrix_first_col + j*matrix_col_stride]

Slices provide an efficient means to operate on tiles and strides.  These are
lightweight objects that reference the storage of the matrix from which they
originate.  In most cases, creating a slice does not require any allocation
beyond the object representing the slice, nor require copying.  In some
less common cases, a copy may be required.

This function supports slicing a vector (interpreted as
rows(matrix) x cols(matrix)) or a matrix.  If the object is not a matrix or
vector, 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 dimensions of the matrix, LA_SLICE_OUT_OF_BOUNDS_ERROR is
returned.

---

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)