---
title: "subtract(_:_:result:)"
framework: accelerate
role: symbol
role_heading: Type Method
path: "accelerate/vdsp/subtract(_:_:result:)-2p3fa"
---

# subtract(_:_:result:)

Calculates the single-precision element-wise subtraction of two vectors.

## Declaration

```swift
static func subtract<T, U, V>(_ vectorA: U, _ vectorB: T, result: inout V) where T : AccelerateBuffer, U : AccelerateBuffer, V : AccelerateMutableBuffer, T.Element == Float, U.Element == Float, V.Element == Float
```

## Parameters

- `vectorA`: The first input vector, A.
- `vectorB`: The second input vector, B.
- `result`: The output vector, C.

## Discussion

Discussion This function calculates the differences of the first N elements of input vectors A and B, and writes the result to output vector C.  for (n = 0; n < N; ++n)     C[n] = A[n] - B[n];

The following code shows an example of using this function:     let count = 5          let a: [Float] = [10, 20, 30, 40, 50]     let b: [Float] = [ 1,  2,  3,  4,  5]          let c = [Float](unsafeUninitializedCapacity: count) {         buffer, initializedCount in                  vDSP.subtract(a, b,                       result: &buffer)                  initializedCount = count     }          // Prints "[9.0, 18.0, 27.0, 36.0, 45.0]".     print(c)

## See Also

### Subtraction

- [subtract(_:_:)](accelerate/vdsp/subtract(_:_:)-8o5ai.md)
- [subtract(_:_:)](accelerate/vdsp/subtract(_:_:)-9xmo8.md)
- [subtract(_:_:result:)](accelerate/vdsp/subtract(_:_:result:)-1ianx.md)
- [subtract(_:from:count:result:)](accelerate/vdsp/subtract(_:from:count:result:)-4p5xd.md)
- [subtract(_:from:count:result:)](accelerate/vdsp/subtract(_:from:count:result:)-80zi9.md)
- [subtract(multiplication:_:)](accelerate/vdsp/subtract(multiplication:_:)-2hhme.md)
- [subtract(multiplication:_:)](accelerate/vdsp/subtract(multiplication:_:)-9gphg.md)
- [subtract(multiplication:_:)](accelerate/vdsp/subtract(multiplication:_:)-3zm6l.md)
- [subtract(multiplication:_:)](accelerate/vdsp/subtract(multiplication:_:)-6u3sp.md)
- [subtract(multiplication:_:result:)](accelerate/vdsp/subtract(multiplication:_:result:)-9p12h.md)
- [subtract(multiplication:_:result:)](accelerate/vdsp/subtract(multiplication:_:result:)-86gx3.md)
- [subtract(multiplication:_:result:)](accelerate/vdsp/subtract(multiplication:_:result:)-3f2bw.md)
- [subtract(multiplication:_:result:)](accelerate/vdsp/subtract(multiplication:_:result:)-6b91s.md)
- [subtract(multiplication:multiplication:)](accelerate/vdsp/subtract(multiplication:multiplication:)-22a4b.md)
- [subtract(multiplication:multiplication:)](accelerate/vdsp/subtract(multiplication:multiplication:)-1ghyu.md)
