<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vDSP/fill(_:with:)-7gfq3",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4vDSPO4fill_4withyxz_SftAA0A13MutableBufferRzSf7ElementRtzlFZ"
  },
  "title" : "fill(_:with:)"
}
-->

# fill(_:with:)

Populates a single-precision vector with a specified scalar value.

```
static func fill<V>(_ vector: inout V, with value: Float) where V : AccelerateMutableBuffer, V.Element == Float
```

## Parameters

`vector`

The vector to populate with the specified value.

`value`

The value to populate.

## Discussion

This function populates a vector with a specified scalar value.

The following code shows how to set each element of vector `c` to pi:

```swift
let a = Float.pi

var c = [Float](repeating: .nan,
                count: 10)

vDSP.fill(&c,
          with: a)

// Prints "[3.1415925, 3.1415925, 3.1415925,
//          3.1415925, 3.1415925, 3.1415925,
//          3.1415925, 3.1415925, 3.1415925,
//          3.1415925]"
print(c)
```

---

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)