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

# vvcopysign(_:_:_:_:)

Copies an array, setting the sign of each element based on a second array of double-precision values.

```
func vvcopysign(_: UnsafeMutablePointer<Double>, _: UnsafePointer<Double>, _: UnsafePointer<Double>, _: UnsafePointer<Int32>)
```

## Discussion

### Parameters:

- parameter 1: The output array, *z*.
- parameter 2: The magnitude input array, *y*.
- parameter 3: The sign input array, *x*.
- parameter 4: The number of elements in the arrays.

The following code shows an example of using [`vvcopysign(_:_:_:_:)`](/documentation/Accelerate/vvcopysign(_:_:_:_:)).

```swift
var x: [Double] = [-1, -1, 1, 1]
var y: [Double] = [1.2, 5.5, -16, 26.0]
var z = [Double](repeating: 0, count: x.count)
var n = Int32(x.count)
 
vvcopysign(&z, &y, &x, &n)
 
print(z) // [-1.2, -5.5, 16.0, 26.0]
```

---

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)