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

# sparse_pack_vector_float(_:_:_:_:_:_:)

Packs nonzero values from a single-precision dense vector to a destination array.

```
func sparse_pack_vector_float(_ N: sparse_dimension, _ nz: sparse_dimension, _ x: UnsafePointer<Float>!, _ incx: sparse_stride, _ y: UnsafeMutablePointer<Float>!, _ indy: UnsafeMutablePointer<sparse_index>!) -> Int
```

## Parameters

`N`

The number of elements in the dense vector *x*.

`nz`

The number of nonzero values to collect.  If less than `nz` nonzero elements are found in the `N` elements of *x*, then the last `nz - actual_nonzero_count` of `y` and `indy` are unused.

`x`

Pointer to the dense vector *x*.

`incx`

Increment between valid values in the dense vector *x*. Negative strides are supported.

`y`

The destination dense storage of nonzero values of *x*. Expected to be of size `nz` elements.

`indy`

The destination dense storage of nonzero indices of *x*.  Expected to be of size `nz` elements.

## Return Value

The number of nonzero values written. On success, `y` and `indy` are updated with up to the first `nz` nonzero indices.

## Discussion

Pack the first `nz` nonzero values and indices from the dense vector *x* and place them in `y` and `indy`. If less than `nz` nonzero elements are found in the `N` elements of `x`, then the last `nz - actual_nonzero_count` elements of `y` and `indy` are unused. The number of indices written can range from `0` to `nz` values and the number written 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)